Jump to content
IGNORED

Problem Code


Primordial Ooze

Recommended Posts

This code is being executed even when the first part becomes true.

	rem if the fire button is pressed
rem and a missile hasn't been fired
if !joy0fire && missileFired = 0 then skipjoy0fireandmissilenotfired

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 and a missilehasn't
	rem been fired the instructions are skipped to here
skipjoy0fireandmissilenotfired

Edited by Open Source Pong
Link to comment
Share on other sites

The answer is here:

 

http://www.randomterrain.com/atari-2600-me...ommands.html#if

 

You are allowed only one OR (||) for each if-then statement. You can use more than one AND (&&) in a line, but you cannot mix AND (&&) and OR (||). The NOT ( ! ) operator may only be used with statements that do not include a comparison token (such as =, <, >, or <>).
Link to comment
Share on other sites

So how should i rewrite this bit of code?

If you're talking about this:

 

  if !joy0fire || missileFired then skipjoy0fireandmissilenotfired

 

 

Then if two things won't work on the same line, seems like the easiest thing to do would be to put them on different lines:

 

  if !joy0fire then skipjoy0fireandmissilenotfired
 if missileFired then skipjoy0fireandmissilenotfired

Link to comment
Share on other sites

So how should i rewrite this bit of code?

I think this may do what you were trying to accomplish?

 

	dim missileFired = a

if joy0fire then joy0fired
if missileFired = 0 then skipjoy0fireandmissilenotfired

joy0fired

missile1x = player0x + 5
missile1y = player0y - 3
missileFired = 1

skipjoy0fireandmissilenotfired

Michael

Link to comment
Share on other sites

So how should i rewrite this bit of code?

If you're talking about this:

 

  if !joy0fire || missileFired then skipjoy0fireandmissilenotfired

 

 

Then if two things won't work on the same line, seems like the easiest thing to do would be to put them on different lines:

 

  if !joy0fire then skipjoy0fireandmissilenotfired
 if missileFired then skipjoy0fireandmissilenotfired

 

I tried that and it still doesn't work. Here is my code:

   rem Planetary Wars
  rem a Rail Shootem up
  rem Updated: October 11, 2008
  rem Website: http://planetarywars.freepgs.com

  rem includes
  
  rem include the 6 lives multikernal
  include 6lives.asm
  
  rem setup all the game variables
  
  rem varaible to hold if a missle has been fired
  dim missileFired = a
  
  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 color of the playfield to light green
  COLUPF = 206

  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 set the lives color to blue
lifecolor = 128

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 lives to 3
lives = 96

rem define the lives counter
lives:
%00011000
%00111100
%01111110
%01111110
%01111110
%01111110
%01111110
%01111110
end

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 > 158 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 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 take 1 life from the player
lives = lives - 32

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 player is out of lives go to the game over screen
if lives < 32 then gameOver

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 ideas?

 

Thanks,

 

Open Source Pong

Edited by Open Source Pong
Link to comment
Share on other sites

It looks like your whole problem is here:

 

	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 > 158 then skipmissileoffscreen

 

Try this:

 

   rem Planetary Wars
  rem a Rail Shootem up
  rem Updated: October 11, 2008
  rem Website: http://planetarywars.freepgs.com

  rem includes
 
  rem include the 6 lives multikernal
  include 6lives.asm
 
  rem setup all the game variables
 
  rem varaible to hold if a missle has been fired
  dim missileFired = a
 
  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 color of the playfield to light green
  COLUPF = 206

  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 set the lives color to blue
lifecolor = 128

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 lives to 3
lives = 96

rem define the lives counter
lives:
%00011000
%00111100
%01111110
%01111110
%01111110
%01111110
%01111110
%01111110
end

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 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 missle was fired "annimate" the missle
if missileFired = 1 then missile1x = missile1x + 1

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 take 1 life from the player
lives = lives - 32

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 player is out of lives go to the game over screen
if lives < 32 then gameOver

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

 

planetary_wars_2008y_10m_22d_2315t.bas

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...