Jump to content

Photo

I've forgotten how to dim correctly


6 replies to this topic

#1 Retro Lord OFFLINE  

Retro Lord

    Moonsweeper

  • 363 posts
  • Location:Sweden

Posted Mon Jun 15, 2015 12:08 PM

It's been ages since I made any games. And I just started again and I realised I've forgot how to dim.

 

The situation is like this:

You are a car, driving along, avoiding other cars and running over zombies, when a car or zombie leaves the screen a counter goes up and it gradually turns into night. When it's night you go to a separate screen that gives you 100 bonus points. Now, it is at this point I need the dim that makes the car/zombie that is player1 to move faster.

 

The skeletal structure is:

 if r=0 then player1y=player1y-1

 if r=1 then player1y=player1y-2

 if r=2 then player1y=player1y-3

 if r=3 then r=0

 

Any pointers?

 

.bas = Attached File  default.bas   3.3KB   91 downloads

 

The code should be easely understandable, but if you want me too clearify things just tell me to.

  rem CODE INSPIRED BY Atarius Maximus at http://www.atariage.com/forums/index.php?showtopic=109288

 set kernel_option no_blank_lines

newstart

 s=0
  player0x = 70
  player0y = 70

 f=10
main
  rem POSSIBLY INEFFICIENT CODE, SEPARATE COLOR INFO FOR EACH FRAME...
  if f = 10 then player0:
        %00000000
        %00111100
        %10111101
        %10100101
        %11100111
        %10100101
        %10100101
        %00111100
        %00111100
        %00011000
        %00011000
        %01011010
        %01011010
        %01111110
        %01011010
        %01011010
end


 COLUP0=$1E

  if g = 10 then player1:
        %00000000
        %00111100
        %10111101
        %10100101
        %11100111
        %10100101
        %10100101
        %00111100
        %00111100
        %00011000
        %00011000
        %01011010
        %01011010
        %01111110
        %01011010
        %01011010
end


  if g = 20 then player1:
        %00000000
        %00100100
        %00100100
        %00100100
        %00100100
        %00011000
        %00011000
        %01011010
        %01011010
        %01111110
        %00000000
        %00011000
        %00011000
        %00011000
        %00000000
        %00000000
end

 if g = 30 then player1:
        %00011000
        %00011000
        %00011000
        %00011000
        %01111110
        %01111110
        %00011000
        %00011000
        %00000000
        %00000000
        %00000000
        %00000000
        %00000000
        %00000000
        %00000000
        %00000000
end

 if g=10 then COLUP1=$86
 if g=20 then COLUP1=$D8
 if g=30 then COLUP1=rand

 COLUPF=$04

 playfield:
 .........XXXXXXXXXXXXXX.........
 .........XXXXXXXXXXXXXX.........
 .........XXXXXXXXXXXXXX.........
 .........XXXXXXXXXXXXXX.........
 .........XXXXXXXXXXXXXX.........
 .........XXXXXXXXXXXXXX.........
 .........XXXXXXXXXXXXXX.........
 .........XXXXXXXXXXXXXX.........
 .........XXXXXXXXXXXXXX.........
 .........XXXXXXXXXXXXXX.........
 .........XXXXXXXXXXXXXX.........
end



 a=a+1

  drawscreen

 if r=0 then player1y=player1y+1
 if r=1 then player1y=player1y+2
 if r=2 then player1y=player1y+3

 if s=0 then COLUBK=$DE
 if s=1 then COLUBK=$DC
 if s=2 then COLUBK=$DA
 if s=3 then COLUBK=$D8
 if s=4 then COLUBK=$D6
 if s=5 then COLUBK=$D4
 if s=6 then COLUBK=$D2
 if s=7 then COLUBK=$D0
 if s=8 then COLUBK=$00
 if s=9 then goto WIN : r=r+1

 if player1y>90 then s=s+1 : score=score+1 : b=(rand&2) : player1y=10 : player1x=rand

 if player1x<70 then player1x=rand : player1y=0
 if player1x>95 then player1x=rand : player1y=0

 if g=20 && collision(player0,player1) then score=score+10 : b=(rand&2) : player1y=10 : player1x=rand

 if g=10 && collision(player0,player1) then goto LOSE

 if b=0 then g=10
 if b=1 then g=10
 if b=2 then g=20


  if joy0right then player0x = player0x + 1
  if joy0left then player0x = player0x - 1
  if joy0up then player0y = player0y - 1
  if joy0down then player0y = player0y + 1

  goto main

LOSE

 COLUPF=$04
 COLUBK=rand

 drawscreen

 if switchreset then reboot

 goto LOSE




WIN

 COLUPF=$04
 COLUBK=rand

 q=q+1

 drawscreen

 if q=60 then score=score+100
 if q=120 then goto newstart

 goto WIN


#2 graywest OFFLINE  

graywest

    Moonsweeper

  • 254 posts
  • Location:Indianapolis, IN

Posted Mon Jun 15, 2015 7:25 PM

Dim allows you to set a descriptive name for a variable.

 

dim Something = a 

 

Something = Something + 1

a = a + 1

 

The last two lines do the same thing if you use the "dim" statement to assign the name "Something" to variable a.



#3 Random Terrain OFFLINE  

Random Terrain

    Visual batari Basic User

  • 28,179 posts
  • Controlled Randomness
    Replay Value
    Nonlinear
  • Location:North Carolina (USA)

Posted Mon Jun 15, 2015 8:13 PM

Dim allows you to set a descriptive name for a variable.

 

dim Something = a 

 

Something = Something + 1

a = a + 1

 

The last two lines do the same thing if you use the "dim" statement to assign the name "Something" to variable a.

 

I think he might be talking about this:

 

randomterrain.com/atari-2600-memories-batari-basic-commands.html#fixedpoint



#4 Retro Lord OFFLINE  

Retro Lord

    Moonsweeper

  • Topic Starter
  • 363 posts
  • Location:Sweden

Posted Tue Jun 16, 2015 4:43 AM

Thank you all for the help, got things the way I want now, you'r awesome =)



#5 freshbrood OFFLINE  

freshbrood

    Star Raider

  • 56 posts

Posted Wed Feb 24, 2016 2:17 PM

Hi everyone. 

 

I was unclear on how to use dim. 

 

So, if I'm clear; it's only real purpose is to let us keep track of variables easier- instead of remember what "a" or "e" was keeping track of..

 

Is that right? And, if so.. wouldn't excessive use of dim commands actually INCREASE code size slightly? 
 

I mean "a" obviously uses less characters/bytes than "something". Yes?



#6 RevEng ONLINE  

RevEng

    River Patroller

  • 4,700 posts
  • Bitnik
  • Location:Canada

Posted Wed Feb 24, 2016 2:39 PM

The variable names don't contribute to the ROM usage. There's only one effect of using more descriptive variable names - your source code becomes easier to read.

#7 Random Terrain OFFLINE  

Random Terrain

    Visual batari Basic User

  • 28,179 posts
  • Controlled Randomness
    Replay Value
    Nonlinear
  • Location:North Carolina (USA)

Posted Wed Feb 24, 2016 9:20 PM

The variable names don't contribute to the ROM usage. There's only one effect of using more descriptive variable names - your source code becomes easier to read.

 
Added that to the bB page:
 
randomterrain.com/atari-2600-memories-batari-basic-commands.html#dim_descriptive_names






0 user(s) are browsing this forum

0 members, 0 guests, 0 anonymous users