Jump to content
IGNORED

Life Counter Graphic Is Corrupt


Primordial Ooze

Recommended Posts

Heres the code:

   rem Open Source Pong
  rem an Open Source Pong Remake
  rem Updated: Feburary 10, 2008
  rem Website: http://opensourcepong.freepgs.com

  goto setup
  
  rem setup all the game variables
setup
  rem include for multiplication
  include div_mul.asm
  
  rem include for lives counter
  include 6lives.asm
  
  rem set the rom size
  set romsize 4k

  rem set kernel options
  rem readpaddle - set it so the paddle controlers are read
  set kernel_options no_blank_lines readpaddle

  rem set an alias for the ball's x velocity
  dim ballxvelocity = a

  rem set an alias for the ball's y velocity
  dim ballyvelocity = b
  
  rem color the background green
  COLUBK = 198

  rem set the color of the playfield to white
  COLUPF = 14

  rem define the playfield
  playfield:
  XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
  ................................
  ................................
  ................................
  ................................
  ................................
  ................................
  ................................
  ................................
  ................................
  XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
end

  rem define player 1's sprite
  player0:
  %00011000
  %00011000
  %00011000
  %00011000
  %00011000
  %00011000
  %00011000
  %00011000
end

  rem define player 2's sprite
  player1:
  %00011000
  %00011000
  %00011000
  %00011000
  %00011000
  %00011000
  %00011000
  %00011000
end

  rem read paddle 0, use it to position player0x across the screen
  currentpaddle = 0

  rem set the lives counter layout to compact
  rem dim lives_compact = 1

  rem set the player live counter to blue
  lifecolor = 140
  
  rem finished seting up the game variables
  
  rem start the game loop
  goto startNewGame
  
  rem start a new game and reset everything that was changed during
  rem the course of the game
startNewGame
  rem set player1's inital x positon
  player0x = 140

  rem set player1's inital y positon
  player0y = 45

  rem set player2's inital x positon
  player1x = 15

  rem set player2's inital y positon
  player1y = 45

  rem set ball's inital x positon
  ballx = 80

  rem set ball's inital y positon
  bally = 45

  rem set the ball's initial x velocity
  ballxvelocity = 1
  
  rem set the ball's initial x velocity
  ballyvelocity = 1

  rem setup the lives counter
  rem needs to be setup everytime the lives are SET
  lives:
  %00011000
  %00011000
  %00011000
  %00011000
  %00011000
  %00011000
  %00011000
  %00011000
end
  
  rem set the lives counter to 3
  lives = 96
  
  rem finished reseting all the game variables changed during
  rem the course of the game
  
  rem go to the game loop
  goto gameLoop
  
  rem start of the game loop
gameLoop

  rem color player 1's paddle
  COLUP0 = 140

  rem color player 2's paddle
  COLUP1 = 28

  rem draw the game screen
  drawscreen

  rem set player1's y position to the paddle control's axis
  rem plus 8
  player0y = paddle + 8

  rem make sure the player doesn't go off the top screen
  if player0y < 16 then player0y = 16
  
  rem make sure the player doesn't go off the bottom screen
  if player0y > 79 then player0y = 79

  rem set the computer's y position to the balls y position
  player1y = bally
  
  rem make sure the computer doesn't go off the top screen
  if player1y < 16 then player1y = 16
  
  rem make sure the computer doesn't go off the bottom screen
  if player1y > 79 then player1y = 79
  
  rem move the ball
  ballx = ballx + ballxvelocity
  bally = bally + ballyvelocity
  
  rem make sure the ball doesn't go off the top screen
  if bally < 9 then ballyvelocity = 0 - ballyvelocity
  
  rem make sure the ball doesn't go off the bottom screen
  if bally > 77 then ballyvelocity = 0 - ballyvelocity
  
  rem if the ball collides with the player paddle
  if collision(player0, ball) then gosub playercollision

  rem if the ball collides with the computer paddle
  if collision(player1, ball) then gosub playerscores
  
  rem if the ball goes past the player paddle
  if ballx > 160 then gosub playerlostlife
  
  rem if player has lost all of his lives start a new game
  if lives < 32 then goto gameover
  
  goto gameLoop
  
  rem end of the game loop code, restart the game loop
  
  rem code for handling collision between player and ball
playercollision
  rem move the ball a bit so it doesn't stick
  ballx = ballx - 10
  
  rem and reverse its x velocity
  ballxvelocity = 0 - ballxvelocity
  return
  
  rem end of player collision code
  
  rem code for handling when the ball hits the computers paddle
  rem and the player scores
playerscores
  rem move the ball a bit so it doesn't stick
  ballx = ballx + 10

  rem reverse the balls x velocity
  ballxvelocity = 0 - ballxvelocity
  
  rem increase the score by 10 points
  score = score + 10
  return
  
  rem end of player scores code
  
  rem code for handling when the player misses the ball and the
  rem player loses a life
playerlostlife
  rem dencrease the score by 50 points
  lives = lives - 32
  
  rem and reset the ball
  ballx = 80
  bally = 45
  return
  
  rem end of player lost life code
  
  rem code for handling when the player has lost all his/her
  rem lives and its gameover
gameover
  rem for now just start a new game
  goto gameLoop

 

I have have no idea why, maybe Stella is freaking out on my code. I also am attaching a screenshot of what it looks like when you play a typical game as the lives counter should look exactly like player 1's sprite(A Blue Paddle). Any Ideas?

 

Thanks,

 

Open Source Pong

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

You need to set the number of lives first, and then define the graphics, rather than the other way around:

 

   rem setup the lives counter
  rem set the lives counter to 3
  lives = 96

  rem needs to be setup everytime the lives are SET
  lives:
  %00011000
  %00011000
  %00011000
  %00011000
  %00011000
  %00011000
  %00011000
  %00011000
end

Michael

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