rem if the missile is past the asteroid hide rem the missile off screen and set missileFired rem to flase, otherwise skip to skipmissilepasttarget if missile1x < player1x then skipmissilepasttarget rem hide the missle off screen missile1x = 0 missile1y = 0 rem and set missileFired to false missileFired = 0 rem if the missile isn't past the the asteroid rem the instructions are skipped to here skipmissilepasttarget
Here is the full source:
rem Planetary Defense rem a Rail Shootem up rem Updated: October 11, 2008 rem Website: http://planetarydefense.freepgs.com rem includes rem none rem setup all the game variables rem varaible to hold if a missle has been fired dim missileFired = a rem variable to hold the number of hits the planet has taken dim hitpoints = b rem set the rom size set romsize 4k rem set the tv format to NTSC set tv ntsc rem turn on smartbranching set smartbranching on rem kernel options rem enable no blank lines set kernel_options no_blank_lines rem set the color of the background to black COLUBK = 0 rem set the score field color scorecolor = 128 rem define the playfield playfield: ................................ X............................... XX.............................. XXX............................. XXX............................. XXX............................. XXX............................. XXX............................. XXX............................. XX.............................. X.............................. ................................ end rem enable the "High Definition" playfield hack pfscroll upup : pfscroll upup rem define player 1's sprite player0: %11100000 %11110000 %00001000 %11111111 %11111111 %00001000 %11110000 %11100000 end rem define the enemy sprite player1: %00000000 %00000000 %00011000 %00111100 %01111110 %00111100 %00011000 %00000000 end rem define player 1's missle height missile1height=1 rem start a new game startNewGame rem reset player's score to 0 score = 0 rem reset the number of hitpoints to 3 hitpoints = 3 rem set player'1 inital x position player0x = 20 rem set player'1 inital y position player0y = 44 rem set the enemie's initial x position off screen player1x = 150 rem set the enemie's initial y position off screen player1y = 40 rem set the missle off screen missile1x=0 missile1y=0 rem set missle fired to false missileFired = 0 gameLoop rem if the reset switch is pressed, start a new game if switchreset then startNewGame rem set player 1's color to white COLUP0 = 14 rem set the enimie's color to grey COLUP1 = 10 rem if the left joystick is pushed up, move player 1 up if joy0up then player0y = player0y - 1 rem make sure the player doesn't go off the top of the screen if player0y < 9 then player0y = 9 rem if the left joystick is pushed down, move player 1 down if joy0down then player0y = player0y + 1 rem make sure the player doesn't go off the bottom of the screen if player0y > 87 then player0y = 87 rem if the fire button is pressed jump to rem skipjoy0fireormissilenotfired if !joy0fire then skipjoy0fireormissilenotfired rem if a missile has been fired jump to rem skipjoy0fireormissilenotfired if missileFired = 1 then skipjoy0fireormissilenotfired rem set the missle in the same x position as the player missile1x = player0x + 5 rem set the missile in front of the player missile1y = player0y - 3 rem set missileFired to true missileFired = 1 rem if the fire button isn't pressed the instructions rem are skipped to here skipjoy0fireormissilenotfired rem if the missle was fired "annimate" the missle if missileFired = 1 then missile1x = missile1x + 1 rem if the missle goes off screen if missile1x < 159 then skipmissileoffscreen rem hide the missle off screen missile1x = 0 missile1y = 0 rem and set missileFired to false missileFired = 0 rem if the missile isn't off screen rem the instructions are skipped to here skipmissileoffscreen rem if the missile is past the asteroid hide rem the missile off screen and set missileFired rem to flase, otherwise skip to skipmissilepasttarget if missile1x < player1x then skipmissilepasttarget rem hide the missle off screen missile1x = 0 missile1y = 0 rem and set missileFired to false missileFired = 0 rem if the missile isn't past the the asteroid rem the instructions are skipped to here skipmissilepasttarget rem animate the enimie player1x = player1x - 1 rem if the asteroid hits the planet the player loses a life and the asteroid rem is destroyed as well otherwise skip the instructions if !collision(player1,playfield) then skipplayer1playfieldcollision rem dercease the planets hitoints by 1 hitpoints = hitpoints - 1 rem place the enimie at the starting location right of the screen player1x = 154 rem set the enimes new y position randomly tryagain01 rem generate a random number r=rand rem if the number is too small or too big regenerate the number if r < 8 || r > 84 then tryagain01 rem set the players y position based on the new random number player1y = r rem if the player doesn't collide with the playfield the instructions rem are skipped to here skipplayer1playfieldcollision rem if the player's missle hit the enemie asteroid destroy rem move the missile off screen and give the player 5 points rem otherwise skip these instructions if !collision(missile1,player1) then skipmissile1player1collision rem move the missile offscreen missile1x = 0 missile1y = 0 rem reset the missile filed variable missileFired = 0 rem place the enimie at the starting location right of the screen player1x = 154 rem set the enimes new y position randomly tryagain02 rem generate a random number r=rand rem if the number is too small or too big regenerate the number if r < 8 || r > 84 then tryagain02 rem set the players y position based on the new random number player1y = r rem and increment the score by 5 points score = score + 5 skipmissile1player1collision rem if the planet has taken too many hits hide the planet rem and go to the game over screen if hitpoints = 0 then COLUPF = 0 : goto gameOver rem set the color of the playfield to light grey rem if the planet hasn't been hit yet if hitpoints = 3 then COLUPF = 6 rem set the color of the playfield to medium grey rem if the planet has been hit once if hitpoints = 2 then COLUPF = 4 rem set the color of the playfield to light grey rem if the planet has been hit twice if hitpoints = 1 then COLUPF = 2 rem draw the screen drawscreen goto gameLoop rem Game Over Screen gameOver rem hide the missiles missile1x = 0 missile1y = 0 gameOverLoop rem if the reset switch is pressed, start a new game if switchreset then startNewGame rem if the joystick is moved start a new game if joy0up then startNewGame if joy0down then startNewGame if joy0left then startNewGame if joy0rightt then startNewGame rem set player 1's color to white COLUP0 = 14 rem set the enimie's color to grey COLUP1 = 10 rem draw the screen drawscreen goto gameOverLoop
Any idea on how i can fix it? i tried
f missile1x < player1x + 5 then skipmissilepasttargetbut that produced assembly errors.
Thanks,
Open Source Pong













