Jump to content
IGNORED

Dragon Slayer - Let's make it happen


Rabbit 2600

Recommended Posts

A new issue has surfaced. I'm atempting to get the player to go to screen 2 after killing a certain number of dragons. And I wrote this up but I get a syntax error, what am I doing wrong?

     if _Kill_Counter= 20 then _Kill_Counter= 0

 _Kill_Counter = _Kill_Counter +1

 if _Kill_Counter = 20 : then goto __Boss_Screen_Loop
end

 

 

 

 

The whole code

     set tv pal
     set romsize 4k


     rem  ****************************************************************
     rem  ****************************************************************
     rem  *
     rem  *  Fixes it so "then goto" is usually unnecessary.
     rem  *
     set smartbranching on






     rem  ****************************************************************
     rem  ****************************************************************
     rem  *
     rem  *  Create aliases for variables.
     rem  *
     rem  ****************************************************************
     rem  `
     rem  `  (You can have more than one alias for each variable.)
     rem  `
     rem  ````````````````````````````````````````````````````````````````

     rem  ````````````````````````````````````````````````````````````````
     rem  `
     rem  `  Enemy Animation Counter
     rem  `
     rem  ````````````````````````````````````````````````````````````````
     rem  `
     dim _Enemy_Anim_Counter = f
     dim _Player_Anim_Counter = b
     dim _Kill_Counter = a
     rem  ````````````````````````````````````````````````````````````````
     rem  ````````````````````````````````````````````````````````````````
     rem  `
     rem  `  BitOp variables 01 (controls all 8 bits).
     rem  `
     rem  ````````````````````````````````````````````````````````````````
     rem  `
     dim _BitOp_01 = q


     rem  ````````````````````````````````````````````````````````````````
     rem  `
     rem  `  Debounce fire button (first of 8 bits).
     rem  `
     rem  ````````````````````````````````````````````````````````````````
     rem  `
     dim _Bit0_Debounce_Fire = q


     rem  ````````````````````````````````````````````````````````````````
     rem  `
     rem  `  Debounce reset switch (second of 8 bits).
     rem  `
     rem  ````````````````````````````````````````````````````````````````
     rem  `
     dim _Bit1_Debounce_Reset = q


     rem  ````````````````````````````````````````````````````````````````
     rem  `  Makes better random numbers.
     rem  `
     rem  ````````````````````````````````````````````````````````````````
     rem  `
     dim rand16 = z



     rem  ****************************************************************
     rem  ****************************************************************
     rem  *
     rem  *  Enable pfscore bars.
     rem  *
     rem  ****************************************************************
     rem  *
     const pfscore=1




     rem  ****************************************************************
     rem  ****************************************************************
     rem  *
     rem  *
     rem  *  Program Start/Restart
     rem  *
     rem  *  Clears and sets up variables (among other things).
     rem  *
     rem  *
     rem  ****************************************************************
     rem  ****************************************************************
__Start_Restart



     rem  ****************************************************************
     rem  *
     rem  *  Clears most variables, except for z.
     rem  *
     rem  ````````````````````````````````````````````````````````````````
     rem  `
     for temp5 = 0 to 24 : a[temp5] = 0 : next


     rem  ****************************************************************
     rem  *
     rem  *  Makes sure sprites are off the screen.
     rem  *
     rem  ````````````````````````````````````````````````````````````````
     rem  `
     player0y = 255 : player1y = 255



     rem  ****************************************************************
     rem  *
     rem  *  Missile setup.
     rem  *
     rem  ````````````````````````````````````````````````````````````````
     rem  `
     missile0height = 4  : missile0y = 255

     missile1height = 4  : missile1y = 255



     rem  ****************************************************************
     rem  *
     rem  *  Ball setup.
     rem  *
     rem  ````````````````````````````````````````````````````````````````
     rem  `
     ballheight = 4 : ballx = 255 : bally = 255
     CTRLPF = $21



     rem  ****************************************************************
     rem  *
     rem  *  Score setup.
     rem  *
     rem  ````````````````````````````````````````````````````````````````
     rem  `
     score = 0 :  scorecolor = $20



     rem  ****************************************************************
     rem  *
     rem  *  Misc. setup.
     rem  *
     rem  ````````````````````````````````````````````````````````````````
     rem  `
     NUSIZ0 = $00

     m = 0



     rem  ****************************************************************
     rem  *
     rem  *  Title screen playfield data.
     rem  *
     rem  ````````````````````````````````````````````````````````````````
     rem  `
     playfield:
     XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
     X..............................X
     X...XXXXX.XXX.XXXXX.X....XXXX..X
     X.....X....X....X...X....X.....X
     X.....X....X....X...X....X.....X
     X.....X....X....X...X....XXX...X
     X.....X....X....X...X....X.....X
     X.....X....X....X...X....X.....X
     X.....X...XXX...X...XXXX.XXXX..X
     X..............................X
     XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
end




     rem  ****************************************************************
     rem  *
     rem  *  Player sprite data.
     rem  *
     rem  ````````````````````````````````````````````````````````````````
     rem  `
     player0:
     %01100110
     %00100100
     %00100100
     %01011000
     %01011000
     %00100111
     %00011000
     %00011000
end



     rem  ****************************************************************
     rem  *
     rem  *  Enemy sprite data.
     rem  *
     rem  ````````````````````````````````````````````````````````````````
     rem  `
     player1:
     %00010100
     %01011101
     %00101010
     %00011100
     %01111111
     %00011100
     %00111110
     %01000001
end






__Title_Screen_Loop

     rem  ****************************************************************
     rem  *
     rem  *  Playfield colors.
     rem  *
     rem  ````````````````````````````````````````````````````````````````
     rem  `
     COLUBK = 0 : COLUPF = $30



     rem  ****************************************************************
     rem  *
     rem  *  Draws the screen.
     rem  *
     rem  ````````````````````````````````````````````````````````````````
     rem  `
     drawscreen



     rem  ****************************************************************
     rem  *
     rem  *  If fire button pressed, leave title screen loop.
     rem  *
     rem  ````````````````````````````````````````````````````````````````
     rem  `
     if joy0fire || joy1fire then goto __Setup_for_Main_Loop


     goto __Title_Screen_Loop



__Setup_for_Main_Loop


     rem  ****************************************************************
     rem  *
     rem  *  Turns on debounce bits.
     rem  *
     rem  ````````````````````````````````````````````````````````````````
     rem  `
     _Bit0_Debounce_Fire{0}  = 1
     _Bit1_Debounce_Reset{1}  = 1



     rem  ****************************************************************
     rem  *
     rem  *  Puts sprites on the screen.
     rem  *
     rem  ````````````````````````````````````````````````````````````````
     rem  `
     player0x = 75 : player0y = 85

     player1x = (rand/1) + 20 : player1y = 0




     rem  ****************************************************************
     rem  *
     rem  *  Sets up number of lives.
     rem  *
     rem  ````````````````````````````````````````````````````````````````
     rem  `
     pfscore1 = %10101010



     rem  ****************************************************************
     rem  *
     rem  *  Game playfield data.
     rem  *
     rem  ````````````````````````````````````````````````````````````````
     rem  `
     playfield:
     X..............................X
     X..............................X
     X..............................X
     X..............................X
     X..............................X
     X..............................X
     X..............................X
     X..............................X
     X..............................X
     X..............................X
     X..............................X
end








     rem  ****************************************************************
     rem  ****************************************************************
     rem  *
     rem  *
     rem  *  Main Loop
     rem  *
     rem  *
     rem  ****************************************************************
     rem  ****************************************************************
__Main_Loop


     rem  ****************************************************************
     rem  *
     rem  *  Sets colors.
     rem  *
     rem  ````````````````````````````````````````````````````````````````
     rem  `
     COLUP1 = $52 : COLUP0 = $06
     COLUPF = $40 : COLUBK = $00
     pfscorecolor = $06



     rem  ****************************************************************
     rem  *
     rem  *  Draws the screen.
     rem  *
     rem  ````````````````````````````````````````````````````````````````
     rem  `
     drawscreen


     rem  ****************************************************************
     rem  *
     rem  *  Enemy sprite animation data.
     rem  *
     rem  ````````````````````````````````````````````````````````````````
     rem  `
     _Enemy_Anim_Counter = _Enemy_Anim_Counter + 1

     if _Enemy_Anim_Counter = 10 then player1:
     %00011000
     %00111100
     %00011000
     %01111110
     %11111111
     %00011000
     %10011000
     %01110000
end

     if _Enemy_Anim_Counter = 20 then player1:
     %00011000
     %00111100
     %00011000
     %00111100
     %01111110
     %10011001
     %00011000
     %11110000
end

     if _Kill_Counter= 20 then _Kill_Counter= 0

 _Kill_Counter = _Kill_Counter +1

 if _Kill_Counter = 20 : then goto __Boss_Screen_Loop
end





     rem  ****************************************************************
     rem  *
     rem  *  Player  sprite animation data.
     rem  *
     rem  ````````````````````````````````````````````````````````````````
     rem  `
 _Player_Anim_Counter = _Player_Anim_Counter + 1

 if _Player_Anim_Counter = 10 then player0:
 %00100000
 %01100100
 %00100110
 %00011100
 %10011000
 %01100110
 %00011001
 %00011000
end

 if _Player_Anim_Counter = 20 then player0:
 %00000100
 %00100110
 %01100100
 %00111100
 %00011001
 %01100110
 %10011000
 %00011000
end

     if _Player_Anim_Counter= 20 then _Player_Anim_Counter = 0














     rem  ****************************************************************
     rem  *
     rem  *  Debounce fire button.
     rem  *
     rem  ````````````````````````````````````````````````````````````````
     rem  `
     rem  `  If fire button not pressed, clear debounce bit.
     rem  `
     if !joy0fire then _Bit0_Debounce_Fire{0} = 0


     rem  ****************************************************************
     rem  *
     rem  *  Restarts game when 1-ups are depleted..
     rem  *
     rem  ````````````````````````````````````````````````````````````````
     rem  `
     if pfscore1 = 0 then goto __Game_Over_Screen_Loop



     rem  ****************************************************************
     rem  *
     rem  *  If enemy and player position are the same, restart enemy.
     rem  *
     rem  ````````````````````````````````````````````````````````````````
     rem  `
     if player1y = player0y then player1x = (rand/2) + 20 : player1y = 0 : pfscore1 = pfscore1/4




     rem  ****************************************************************
     rem  *
     rem  *  Check enemy missile.
     rem  *
     rem  ````````````````````````````````````````````````````````````````
     rem  `
     rem  `  If enemy missile isn't on or has gone too far, skip.
     rem  `
     rem  ````````````````````````````````````````````````````````````````
     rem  `
     if missile1y > 200 then goto __Skip_Enemy_Missile_Movement


     rem  ````````````````````````````````````````````````````````````````
     rem  `
     rem  `  Move enemy missile down the screen and skip enemy fire.
     rem  `
     rem  ````````````````````````````````````````````````````````````````
     rem  `
     missile1y = missile1y + 2 : goto __Skip_Enemy_Fire

__Skip_Enemy_Missile_Movement


     rem  ````````````````````````````````````````````````````````````````
     rem  `
     rem  `  If enemy missile isn't moving, randomly put the missile on
     rem  `  the screen (fire missile).
     rem  `
     rem  ````````````````````````````````````````````````````````````````
     rem  `
     if rand < 100 then missile1y = player1y : missile1x = player1x + 4


__Skip_Enemy_Fire



     rem  ****************************************************************
     rem  *
     rem  *  Check player missile.
     rem  *
     rem  ````````````````````````````````````````````````````````````````
     rem  `
     rem  `  If player missile isn't on or has gone too far, skip.
     rem  `
     rem  ````````````````````````````````````````````````````````````````
     rem  `
     if missile0y > 240 then goto __Skip_Missile_Movement


     rem  ````````````````````````````````````````````````````````````````
     rem  `
     rem  `  Move player missile up the screen and skip fire button.
     rem  `
     rem  ````````````````````````````````````````````````````````````````
     rem  `
     missile0y = missile0y - 2 : goto __Skip_Fire


__Skip_Missile_Movement


     rem  ````````````````````````````````````````````````````````````````
     rem  `
     rem  `  If player missile isn't moving and fire button is pressed
     rem  `  and debounce bit is not on, put the missile on the screen
     rem  `  (fire missile).
     rem  `
     rem  ````````````````````````````````````````````````````````````````
     rem  `
     if joy0fire && !_Bit0_Debounce_Fire{0} then missile0y = player0y - 2 : missile0x = player0x + 4

__Skip_Fire



     rem  ****************************************************************
     rem  *
     rem  *  Check Enemy.
     rem  *
     rem  ````````````````````````````````````````````````````````````````
     rem  `
     rem  `  If enemy isn't on or has gone too far, skip.
     rem  `
     rem  ````````````````````````````````````````````````````````````````
     rem  `
     if player1y > 200 then goto __Skip_Player1_Movement


     rem  ````````````````````````````````````````````````````````````````
     rem  `
     rem  `  Move enemy down the screen and skip new ball drop.
     rem  `
     rem  ````````````````````````````````````````````````````````````````
     rem  `
     player1y = player1y + 1 : goto __Skip_Player1_Drop


__Skip_Player1_Movement


     rem  ````````````````````````````````````````````````````````````````
     rem  `
     rem  `  If enemy isn't moving, randomly drop ball.
     rem  `
     rem  ````````````````````````````````````````````````````````````````
     rem  `
     if rand < 50 then player1x = (rand/2) + 22 : player1y = 0 : if player1x > 114 then player1x = 114 - (rand/4)


__Skip_Player1_Drop





     rem  ****************************************************************
     rem  *
     rem  *  Check ball.
     rem  *
     rem  ````````````````````````````````````````````````````````````````
     rem  `
     rem  `  If ball isn't on or has gone too far, skip.
     rem  `
     rem  ````````````````````````````````````````````````````````````````
     rem  `
     if bally > 200 then goto __Skip_Ball_Movement


     rem  ````````````````````````````````````````````````````````````````
     rem  `
     rem  `  Move ball down the screen and skip new ball drop.
     rem  `
     rem  ````````````````````````````````````````````````````````````````
     rem  `
     bally = bally + 1 : goto __Skip_Ball_Drop


__Skip_Ball_Movement


     rem  ````````````````````````````````````````````````````````````````
     rem  `
     rem  `  If ball isn't moving, randomly drop ball.
     rem  `
     rem  ````````````````````````````````````````````````````````````````
     rem  `
     if rand < 50 then ballx = (rand/2) + 22 : bally = 0 : if ballx > 114 then ballx = 114 - (rand/4)


__Skip_Ball_Drop


     rem  ****************************************************************
     rem  *
     rem  *  If player missile hit enemy, add to score and reset enemy.
     rem  *
     rem  ````````````````````````````````````````````````````````````````
     rem  `
     if collision(missile0,player1) then score=score + 10 : player1x = (rand/2) + 20 : player1y = 0 : missile0y=255 : _Kill_Counter + 1


     rem  ****************************************************************
     rem  *
     rem  *  If player touches enemy, subtract from score and reset enemy.
     rem  *
     rem  ````````````````````````````````````````````````````````````````
     rem  `
     if collision(player0,player1) then player1x = (rand/2) + 20 : player1y = 0 : pfscore1 = pfscore1/4

     rem  ****************************************************************
     rem  *
     rem  *  If enemy missile hits player, subtract from score and reset
     rem  *  missile.
     rem  *
     rem  ````````````````````````````````````````````````````````````````
     rem  `
     if collision(missile1,player0) then missile1y=255 : pfscore1 = pfscore1/4


     rem  ****************************************************************
     rem  *
     rem  *  If ball touches player, subtract from score and remove ball.
     rem  *
     rem  ````````````````````````````````````````````````````````````````
     rem  `
     if collision(player0,ball) then bally = 255 : pfscore1 = pfscore1/4


     rem  ****************************************************************
     rem  *
     rem  *  If ball touches missile, remove missile.
     rem  *
     rem  ````````````````````````````````````````````````````````````````
     rem  `
     if collision(missile0,ball) then missile0y = 255


     rem  ****************************************************************
     rem  *
     rem  *  REMed out playfield collision since it's only being used to
     rem  *  keep the player from going too far left or right.
     rem  *
     rem  ````````````````````````````````````````````````````````````````
     rem  `
     rem if !collision(player0,playfield) then goto __Skip_PF_Collision
     rem if m = 1 then player0y = player0y + 1 : goto __Skip_Move
     rem if m = 2 then player0x = player0x + 1 : goto __Skip_Move
     rem if m = 3 then player0y = player0y - 1 : goto __Skip_Move
     rem if m = 4 then player0x = player0x - 1 : goto __Skip_Move

     rem goto __Skip_Move

__Skip_PF_Collision


     rem  ****************************************************************
     rem  *
     rem  *  If joystick moved left, do that and point player that way.
     rem  *
     rem  ````````````````````````````````````````````````````````````````
     rem  `
     if joy0left then player0x = player0x - 2 : goto __Skip_Move



     rem  ****************************************************************
     rem  *
     rem  *  If joystick moved right, do that and point player that way.
     rem  *
     rem  ````````````````````````````````````````````````````````````````
     rem  `
     if joy0right then player0x = player0x + 2 :  m = 4 : goto __Skip_Move


__Skip_Move


     rem  ****************************************************************
     rem  *
     rem  *  Keep the player from going too far left or right.
     rem  *
     rem  ````````````````````````````````````````````````````````````````
     rem  `
     if player0x > 134 then player0x = 134

     if player0x < 20 then player0x = 20



     rem  ****************************************************************
     rem  *
     rem  *  Reset Program:
     rem  *
     rem  *  Any Atari 2600 program should restart when the reset switch  
     rem  *  is pressed. It is part of the usual standards and procedures.
     rem  *
     rem  ````````````````````````````````````````````````````````````````
     rem  `
     if !switchreset then _Bit1_Debounce_Reset{1} = 0 : goto __Skip_Reset
     

     rem  ````````````````````````````````````````````````````````````````
     rem  `  If Reset is pressed, but debounce bit is on, skip.
     rem  `
     if _Bit1_Debounce_Reset{1} then goto __Skip_Reset


     rem  ````````````````````````````````````````````````````````````````
     rem  `  Reset the program.
     rem  `
     goto __Start_Restart


__Skip_Reset


     goto __Main_Loop



__Game_Over_Screen_Loop

     rem  ****************************************************************
     rem  *
     rem  *  Playfield colors.
     rem  *
     rem  ````````````````````````````````````````````````````````````````
     rem  `
     COLUBK = 0 : COLUPF = $30

 ballx = 255 : bally = 255
 player0x = 255 : player0y = 255
 player1x = 255 : player1y = 255
 missile0x = 255 : missile0y = 255
 missile1x = 255 : missile1y = 255

     rem  ****************************************************************
     rem  *
     rem  *  Draws the screen.
     rem  *
     rem  ````````````````````````````````````````````````````````````````
     rem  `
   playfield:
     ......XXXX..X...X.X..XXXX.......
     ......X....X.X.X.X.X.X..........
     ......X.XX.XXX.X.X.X.XXXX.......
     ......X..X.X.X.X.X.X.X..........
     ......XXXX.X.X.X.X.X.XXXX.......
     ................................
     .......XX..X..X.XXXX.XXX........
     ......X..X.X..X.X....X..X.......
     ......X..X.X..X.XXXX.XXX........
     ......X..X..X.X.X....X..X.......
     .......XX....X..XXXX.X..X.......
end
     drawscreen
 COLUP0 = $00


     rem  ****************************************************************
     rem  *
     rem  *  If fire button pressed, leave title screen loop.
     rem  *
     rem  ````````````````````````````````````````````````````````````````
     rem  `
     if joy0fire || joy1fire then goto __Start_Restart


     goto __Game_Over_Screen_Loop






__Boss_Screen_Loop


     rem  ****************************************************************
     rem  *
     rem  *  Playfield colors.
     rem  *
     rem  ````````````````````````````````````````````````````````````````
     rem  `
     COLUBK = 0 : COLUPF = $40

     rem  ****************************************************************
     rem  *
     rem  *  Draws the screen.
     rem  *
     rem  ````````````````````````````````````````````````````````````````
     rem  `
     playfield:
     XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
     X..............................X
     X..............................X
     X..............................X
     X..............................X
     X..............................X
     X..............................X
     X..............................X
     X..............................X
     X..............................X
     X..............................X
end

     drawscreen

Link to comment
Share on other sites

One of the problems you keep introducing is adding random ENDs everywhere. There are specific things that end with END and those are the only times where you use it. Read this little section:

 

http://www.randomter...mmands.html#end

 

 

There are two problems that I see right away here:

 

  if _Kill_Counter = 20 then _Kill_Counter= 0

  _Kill_Counter = _Kill_Counter +1

  if _Kill_Counter = 20 : then goto __Boss_Screen_Loop

 

The last line has a colon before THEN. You never want to put a colon there. Once you fix the last line, the program will never go to __Boss_Screen_Loop. Every time _Kill_Counter equals 20, you have it equal zero. You probably want to move your last line above the first one.

Link to comment
Share on other sites

Yeah, I haven't learned where to put ends really, so I might overuse them. But I will learn in time =)

Hm, I think I understand it better now, generally, when a command ends with : that's when an end command is used?

 

(I also added more to my post above.)

 

You really don't have to learn where to put ENDs. If you are using Visual batari Basic to make your playfields and sprites, it always includes the END for you. You don't have to add a bunch of random ENDs everywhere. It's only used for data-related stuff like this:

 

  player0:
  %00100010
  %01110111
  %01111111
end


  playfield:
  X.X...X..XX..X.XX.X....XX..X.X..
  X.X....XX..X.X..X.X...X..XX..X.X
end


  lives:
  %01000100
  %11111110
  %11111110
  %01111100
  %00111000
  %00010000
  %00010000
  %00010000
end



  data _My_Data
  200, 43, 33, 93, 255, 54, 22
end

 

 

All of that kind of stuff is data. END tells batari Basic when to stop reading the data.

Link to comment
Share on other sites

Another question, how do I save the game as a .bin?

 

If you are using Visual batari Basic, your program is saved as a .bin when you compile it:

 

www.youtube.com/watch?v=BklFnEGaB-w

http://www.youtube.com/watch?v=BklFnEGaB-w

 

There will be a folder in your project folder called bin where all of your .bin files for that project will be saved. You can't see it from VbB; you have to use a normal Windows Explorer folder. You can right click on the name of a project in VbB's Project Explorer and select Open Folder in Windows Explorer. Then you'll be able to see the bin folder.

 

Your .bin files will end in .bas.bin. I always edit out the .bas part before I attach it to a post. It just looks better.

Link to comment
Share on other sites

Hm, it seems I have deleted the .bin. when I have compiled and test the program in Stella I get an error saying "Could not locate dragon_slayer.bas.bin and could not recompile"

How do I fix this one? <_<

 

If you have stripped the crap out of your computer and removed registry entries and all that good stuff, you'll need to make sure the settings are still there. Uncheck the boxes for Add bB Environment Variable and Add bB Compiler to System Path, click on those two check boxes again (so there are little check marks in the boxes), then click on the Save button. Close VbB, then open it again.

 

 

If you're still getting the error, check the troubleshooting section:

 

http://www.randomter...troubleshooting

 

 

If you can't find an answer there, try this:

 

http://www.randomter...tml#install_vbb

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...