Jump to content
IGNORED

RoadBlaster - A new batari basic game


Recommended Posts

Here's my first attempt at a bB game. It's a complete, playable game, although I'll probably spend more time tweaking it in the coming weeks. I struggled for a long time getting certain components of the game correctly, so I didn't comment the code very well because of all the changes I made when testing it -- I plan on going back and doing that soon.

 

You have a missile equipped car, and can shoot oncoming traffic for points. Your score also increases the longer you stay on the road. Randomly appearing road blocks get in your way and can push you into oncoming traffic. The object is to shoot as many oncoming cars as possible without running into them. Your car has "hit points", and the game will end after multiple collisions with oncoming cars. When your hit points run out, you go to a "game over" screen with your final score. I haven't yet figured out how to reset the game correctly...I can't seem to get the inline asm 'clear playfield' code to work. As a result, you have to exit and reload the game in the emulator when it ends.

 

Anyway, here it is, RoadBlaster v0.1. I've attached the bin and bB code. Any comments or suggestions about improving the bB code or the game itself would be appreciated! This was a lot of fun to make, thanks for making it possible, batari! :D

 

This post will be updated with the latest versions of the game as they are released.

 

So you don't have to scroll through the post to see what the latest revisions contain, here's the verison notes from the source code:

 

v0.65 Updates - Both cars can now be shot individually before they scroll off the screen, and will disappear when shot. Powerups now appear randomly after you shoot a car. Road was widened, a few colors were changed.

 

v0.66 Updates - Attempting to fix problem of cars starting out off the road at the top of the screen after you've shot both of them. My playtesting so far hasn't shown any problems, it seems to be working. Sorry to anyone who downloaded this version -- I accidently left my "debug" mode on -- the car was invincible. I just noticed it as I'm posting the 1.0 version.

 

v 1.0 Update - It seems to be ready for the 1.0 release - I've played it quite a bit and can't find any glaring gameplay bugs. Unless someone finds something wrong, this is the official release.

 

v 1.06 Update

 

:arrow: Color/BW switch toggles between normal mode(color) and invincible/practice mode (BW).

:arrow: Left difficulty controls size of player car, right difficulty controls roadblocks on/off.

:arrow: Title Screen Changed (See screenshot below)

:arrow: Audio sound added to death, animated sequence of car scrolling off the top of the road after death added.

:arrow: Powerups do not appear if you're pushing up on the joystick to go faster, just to make going faster even more challenging.

:arrow: Scroll speed of the roadside slows when you slow down.

:arrow: Sprites changed

:arrow: This version is now compatible with real hardware, v1.00 was not.

 

Steve

rblast1.0.bin

post-2143-1143166810_thumb.jpg

post-2143-1143166824_thumb.jpg

post-2143-1143166838_thumb.jpg

post-2143-1143166849_thumb.jpg

rblast100.txt

rblast106.bin

rblast106.txt

post-2143-1149531516_thumb.jpg

Edited by Atarius Maximus
Link to comment
https://forums.atariage.com/topic/82248-roadblaster-a-new-batari-basic-game/
Share on other sites

Here's the cleaned up, commented source code.

 

 rem Road Blaster
 rem by Steve Engelhardt
 rem v0.1 (1/19/2006)
init
 x=75 : rem X Position of Player 0
 c=0  : rem Hitpoint Counter 
 p=85 : rem Y Position of Player 0
 g=1  : rem Y Position of Player 1
 b=82 : rem X Position of Ball
 u=64 : rem X Position of Player 1
 v=1  : rem Random Number Generator
 COLUPF=144
 COLUBK=0
 CTRLPF=$31
 AUDV0=0:AUDC0=2:AUDF0=1
 scorecolor=224
 rem
 rem Main Game Loop
 rem
main
 if g < 92 then g=g+1 else g=0
 v=rand 
 if v > 180 then u=u-1 : rem randomly 'skids' computer car to the Left
 if v < 50 then u=u+1  : rem randomly 'skids' computer car to the Right
 if v=2 then b=75      : rem randomly places roadblock on the left side
 if v=234 then b = 105 : rem randomly places roadblock on the right side
 if d=1 then u=u+1     : rem move Player 1 Right
 if d=2 then u=u-1     : rem move Player 1 Left
 rem Computer Controlled Car
 player1:               
 %00111100
 %10011001
 %11111111
 %10011001
 %00011000
 %10011001
 %11111111
 %10011001
 %00000000
end
 NUSIZ1=$31 : NUSIZ0=$10 : COLUP1=52 : player1y=g : player1x=u
 rem player 0 is the human car
 player0: 
 %00111100
 %10011001
 %11111111
 %10011001
 %00011000
 %10011001
 %11111111
 %10011001
 %00000000
end
 pfscroll down
 COLUP0=196 : player0x=x : player0y=p
 rem
 rem Create the 2 sides of the Road
 rem
 pfpixel 7 1 on : pfpixel 25 1 on : pfpixel 7 2 on : pfpixel 25 2 on
 pfpixel 7 3 on : pfpixel 25 3 on : pfpixel 7 4 on : pfpixel 25 4 on
 pfpixel 7 5 on : pfpixel 25 5 on : pfpixel 7 6 on : pfpixel 25 6 on
 pfpixel 7 7 on : pfpixel 25 7 on : pfpixel 7 8 on : pfpixel 25 8 on
 pfpixel 7 9 on : pfpixel 25 9 on : pfpixel 7 10 on: pfpixel 25 10 on
 drawscreen
 AUDV0=0
 rem
 rem Create Roadblock
 rem
 ballx=b : bally=g+15 : ballheight=2
 rem
 rem Move Player Car
 rem
 if joy0left then x=x-1
 if joy0right then x=x+1
 rem
 rem
 if x<31 then x=31
 if x>152 then x=152
 rem
 rem
 if joy0fire && q<1 then goto playerfires
 if q>0 then q=q-1 : missile0y=q
 rem
 rem *Don't allow PLayer controlled car to drive off the road
 rem 
 if collision(playfield,player0) && x > 75 then x=x-1
 if collision(playfield,player0) && x < 75 then x=x+1
 rem
 rem *When Computer Controlled car hits the playfield, bounce the other direction
 rem
 if collision(player1,playfield) && u > 100 then d=2
 if collision(player1,playfield) && u < 80 then d=1
 rem
 rem *If Player Car hits Computer Car, increase hitpoint counter.  When reaches 15, goto end of game  
 rem
 if collision(player1,player0) then c=c+1 : if c=15 then goto thisisit
 if collision(player1,player0) then u=u+5
 rem
 rem *If Player missile hits computer car, increase score by 1000
 rem
 if collision(player1,missile0) then g=0 : score = score + 1000 
 rem
 rem *If Player car hits roadblock bouce away from it
 rem
 if collision(player0,ball) && u > 90 then x=x-6
 if collision(player0,ball) && u < 90 then x=x+6
 rem
 rem *Increase score by 10 (Just for staying alive)
 rem 
 score=score+10
 rem
 rem Loop Back to Main
 rem
 goto main
playerfires
 missile0x=x+4
 q=80 : missile0y=75
 missile0height=6
 goto main
thisisit
 rem
 rem Create 'Game Over' Screen
 rem
 pfpixel 7 1 off : pfpixel 25 1 off : pfpixel 7 2 off : pfpixel 25 2 off
 pfpixel 7 3 off : pfpixel 25 3 off : pfpixel 7 4 off : pfpixel 25 4 off
 pfpixel 7 5 off : pfpixel 25 5 off : pfpixel 7 6 off : pfpixel 25 6 off
 pfpixel 7 7 off : pfpixel 25 7 off : pfpixel 7 8 off : pfpixel 25 8 off
 pfpixel 7 9 off : pfpixel 25 9 off : pfpixel 7 10 off: pfpixel 25 10 off
 pfpixel 1 1 on : pfpixel 2 1 on : pfpixel 3 1 on : pfpixel 4 1 on
 pfpixel 5 1 on : pfpixel 7 1 on : pfpixel 8 1 on : pfpixel 9 1 on
 pfpixel 10 1 on : pfpixel 11 1 on : pfpixel 13 1 on : pfpixel 17 1 on
 pfpixel 19 1 on : pfpixel 20 1 on : pfpixel 21 1 on : pfpixel 22 1 on
 pfpixel 23 1 on : pfpixel 1 2 on : pfpixel 7 2 on : pfpixel 11 2 on
 pfpixel 13 2 on : pfpixel 14 2 on : pfpixel 16 2 on : pfpixel 17 2 on
 pfpixel 19 2 on : pfpixel 1 3 on : pfpixel 3 3 on : pfpixel 4 3 on
 pfpixel 5 3 on : pfpixel 7 3 on : pfpixel 8 3 on : pfpixel 9 3 on
 pfpixel 10 3 on : pfpixel 11 3 on : pfpixel 13 3 on : pfpixel 15 3 on
 pfpixel 17 3 on : pfpixel 19 3 on : pfpixel 20 3 on : pfpixel 21 3 on
 pfpixel 1 4 on : pfpixel 5 4 on : pfpixel 7 4 on : pfpixel 11 4 on
 pfpixel 13 4 on : pfpixel 17 4 on : pfpixel 19 4 on : pfpixel 1 5 on
 pfpixel 2 5 on : pfpixel 3 5 on : pfpixel 4 5 on : pfpixel 5 5 on
 pfpixel 19 5 on : pfpixel 20 5 on : pfpixel 21 5 on : pfpixel 22 5 on
 pfpixel 23 5 on : pfpixel 1 6 on : pfpixel 2 6 on : pfpixel 3 6 on
 pfpixel 4 6 on : pfpixel 5 6 on : pfpixel 7 6 on : pfpixel 11 6 on
 pfpixel 13 6 on : pfpixel 14 6 on : pfpixel 15 6 on : pfpixel 16 6 on
 pfpixel 17 6 on : pfpixel 19 6 on : pfpixel 20 6 on : pfpixel 21 6 on
 pfpixel 22 6 on : pfpixel 23 6 on : pfpixel 1 7 on : pfpixel 5 7 on
 pfpixel 7 7 on : pfpixel 11 7 on : pfpixel 13 7 on : pfpixel 19 7 on
 pfpixel 23 7 on : pfpixel 1 8 on : pfpixel 5 8 on : pfpixel 7 8 on
 pfpixel 11 8 on : pfpixel 13 8 on : pfpixel 14 8 on : pfpixel 15 8 on
 pfpixel 19 8 on : pfpixel 20 8 on : pfpixel 21 8 on : pfpixel 22 8 on
 pfpixel 23 8 on : pfpixel 1 9 on : pfpixel 5 9 on : pfpixel 8 9 on
 pfpixel 10 9 on : pfpixel 13 9 on : pfpixel 19 9 on : pfpixel 22 9 on
 pfpixel 1 10 on : pfpixel 2 10 on : pfpixel 3 10 on : pfpixel 4 10 on
 pfpixel 5 10 on : pfpixel 9 10 on : pfpixel 13 10 on : pfpixel 14 10 on
 pfpixel 15 10 on : pfpixel 16 10 on : pfpixel 17 10 on : pfpixel 19 10 on
 pfpixel 23 10 on
 COLUBK=0
 COLUPF=170
 COLUP0=0
 COLUP1=0
 drawscreen
 scorecolor=208
 rem if switchreset then goto main
 rem
 rem I put this here to go into an infinite loop at the end of the game, until I figure out
 rem how to clear the playfield before I use a 'switchreset'.
 rem
 goto eog
end
eog
 goto eog

roadblast.bin

Edited by Atarius Maximus

Suggestions/Comments:

 

First: :thumbsup: Very nice!

 

A few things...

1. Remove the missile from the screen when it hits something.

2. Allow the player to speed up/slow down the scrolling.

3. Make only the car you hit with a missile disappear when you hit it, rather than both.

4. Are the roadblocks supposed to move L/R? Looks a little odd. Actually, there seem to be a couple of glitches with the roadblocks jumping around the screen.

5. Some variations on enemy car movement?

6. Some variations on enemy car sprites?

7. IMO the missile should move faster. And it should be smaller.

8. Sound? :D

 

Very nice all in all! Fun to play. ;)

Suggestions/Comments:

 

First: :thumbsup: Very nice!

 

A few things...

1. Remove the missile from the screen when it hits something.

2. Allow the player to speed up/slow down the scrolling.

3. Make only the car you hit with a missile disappear when you hit it, rather than both.

4. Are the roadblocks supposed to move L/R?  Looks a little odd.  Actually, there seem to be a couple of glitches with the roadblocks jumping around the screen.

5. Some variations on enemy car movement? 

6. Some variations on enemy car sprites?

7. IMO the missile should move faster.  And it should be smaller.

8. Sound?  :D

 

Very nice all in all!  Fun to play. ;)

1003747[/snapback]

 

Thanks for the Suggestions! I actually had already thought of some of those things, I just don't know how to implement them. Using only the bB help file, I couldn't figure out how to do most of the things on that list, it's going to take a whole lot of trial and error on my part. Any code examples you (or anyone else) could provide would be much appreciated! :)

 

Steve

Edited by Atarius Maximus

Yeah, once you figure it out, it would be good to pull back on the stick to slow down and push forward to speed up. Making the reset switch and fire button restart the game when it's all over would be nice too.

 

Speaking of figuring things out, if you have any ideas on how to make this bB related page easier to understand and use, please let me know:

 

http://www.randomterrain.com/a2m/bbcommands.html

 

Thanks.

Edited by Random Terrain
Yeah, once you figure it out, it would be good to pull back on the stick to slow down and push forward to speed up. Making the reset switch and fire button restart the game when it's all over would be nice too.

I would like to implement those features, as well as most of the things that vdub_bobby mentioned. I'm going to have to look at the code of some other games that have already been developed to help figure some of this stuff out.

 

Speaking of figuring things out, if you have any ideas on how to make this bB related page easier to understand and use, please let me know:

 

http://www.randomterrain.com/a2m/bbcommands.html

 

Thanks.

1003898[/snapback]

 

I'll take a look at your site, thanks for the link. I can't seem to figure out anything related to speeding up or slowing down the scrolling effect, it seems like all you can do is turn pfscroll on or off. Same goes for the speed of the player objects. Did you do anything with the speed of objects in your 'Ruins' game?

 

Steve

Edited by Atarius Maximus

:D

 

I'm looking at Jess' Solar Plexus thread, and it's helping. I figured out how to speed up and slow down your speed by pressing up and down on the joystick by looking at his code. There's more to do, but here's a new bin with the speed up/slow down working.

 

Steve

roadblast.txt.bin

Nice job figuring out how to change scrolling speeds!  :thumbsup:

 

Needs some tweaking, but good start.

1004013[/snapback]

 

Thanks! I know it's going to need some tweaking, but I was happy to make it work. :) I've now got the road blocks appearing in 9 different random locations, and they don't jump around anymore while they're scrolling down. They do seem to scroll up when you shoot a car though. Still working on it - and done for tonight. Time to go to bed. :)

 

Steve

roadblast.txt.bin

Edited by Atarius Maximus
Thanks!  I know it's going to need some tweaking, but I was happy to make it work. :)  I've now got the road blocks appearing in 9 different random locations, and they don't jump around anymore while they're scrolling down.  They do seem to scroll up when you shoot a car though.  Still working on it - and done for tonight.  Time to go to bed.  :)

1004030[/snapback]

 

One thing you should try to do to distinguish your game from a Firefly/Sorceror clone is to determine which enemy car a player shoots. If the player shoots the right car, set NUSIZ1 to 0 and increase by 16 the range of motion for the enemy cars. If the player shoots the left car, decrease the enemy car position by 16 and then, as above, set NUSIZ1 to 0 and increase the range of motion for the enemies.

 

Doing this will greatly increase the level of professionalism in your game.

One thing you should try to do to distinguish your game from a Firefly/Sorceror clone is to determine which enemy car a player shoots.  If the player shoots the right car, set NUSIZ1 to 0 and increase by 16 the range of motion for the enemy cars.  If the player shoots the left car, decrease the enemy car position by 16 and then, as above, set NUSIZ1 to 0 and increase the range of motion for the enemies.

1004286[/snapback]

Thanks for the suggestion, that's a good idea. I'll make that change on my next revision. :)

 

Steve

Edited by Atarius Maximus
One thing you should try to do to distinguish your game from a Firefly/Sorceror clone is to determine which enemy car a player shoots.  If the player shoots the right car, set NUSIZ1 to 0 and increase by 16 the range of motion for the enemy cars.  If the player shoots the left car, decrease the enemy car position by 16 and then, as above, set NUSIZ1 to 0 and increase the range of motion for the enemies.

 

Doing this will greatly increase the level of professionalism in your game.

1004286[/snapback]

That's a good tip, but how can you tell which car is hit? Aren't both registering as the same sprite? Is it simply a matter of comparing the position of the sprite to the position of the missile? Is it something like this:

 

If enemy car sprite is hit and missile position is greater than _____ then destroy right car, else destroy left car?

One thing you should try to do to distinguish your game from a Firefly/Sorceror clone is to determine which enemy car a player shoots.  If the player shoots the right car, set NUSIZ1 to 0 and increase by 16 the range of motion for the enemy cars.  If the player shoots the left car, decrease the enemy car position by 16 and then, as above, set NUSIZ1 to 0 and increase the range of motion for the enemies.

 

Doing this will greatly increase the level of professionalism in your game.

1004286[/snapback]

That's a good tip, but how can you tell which car is hit? Aren't both registering as the same sprite? Is it simply a matter of comparing the position of the sprite to the position of the missile? Is it something like this:

 

If enemy car sprite is hit and missile position is greater than _____ then destroy right car, else destroy left car?

1004655[/snapback]

 

That's a good point -- I didn't see any obvious way to do it either. I was looking through the Space Invaders thread in this forum and it looks like batari used a creative way to allow individual invaders to be hit...something like using playfield blocks behind the sprites, and then changing the color of the playfield block to mask the sprite when it was hit (I may be remembering this wrong, I read it a few days ago). It looked rather complicated, and would involve a rewrite of my game I think. I was going to try the method you mentioned first, trying to detect the car and missile position to determine which car was being hit. It doesn't look like that's going to work, but I'm going to give it a shot.

 

Steve

This version has a few more revisions:

 

1. The missile now disappears after you hit an enemy car, and is narrower.

3. When you hit one of the two cars - the right car will disappear from view. It will reappear after the single car passes by a few more times. Making each car disappear individually is still a work in progress.

3. When one of the two cars is hit, the single car will continue toward you, it will not disasppear & reset to the top of the screen. Currently, shooting the single car that's left will still give you points, but it's indestructable.

 

I'm still working the other suggestions. Thanks to everyone for the feedback.

 

Steve

Rblast.bin

If enemy car sprite is hit and missile position is greater than _____ then destroy right car, else destroy left car?

1004655[/snapback]

 

The code needs a variable to keep track of whether 1 or 2 cars exist (since NUSIZx are write-only). If two cars exist and the player's shot position is more than 8 pixels greater than the car position, the player shot the right car (and so you should add 16 to the car position).

 

Simple version would be something like (sorry I've not actually coded in bB yet):

 if (CXM1P & 64) then
   if shotXPos > carXPos+8 then
     carXPos=carXPos+16
   endif
   if twoCars then
     NUSIZ1 = 0
     twocars = 0
     ' Register shooting of one car
   else
     ' Blow up remaining car
   endif
 endif

Note that the car motion code should allow the cars to move further to the right if only one car exists than if two do.

 

If you want to be a little fancier, you could do something like this:

' Set both car1stat and car2stat to 128 when they appear at top of screen

 if (CXM1P & 64) then
   if shotXpos > carXpos+16 then
     if car2stat & 128 then
       car2stat = 127
       ' Score hit
     endif
   else
     if car1stat & 128 then
       car1stat = 127
       ' Score hit
     endif
   endif
 endif

' Just before draw kernel
 if car1stat & 127 then
   car1stat = car1stat-1
 endif
 if car2stat & 127 then
   car2stat = car2stat-1
 endif
 if car1stat & 129 then ' Either not hit, or every other frame if hit
   if car2stat & 129 then
     NUSIZ1 = 1
     P1xpos = carXpos
   else
     NUSIZ1 = 0
     P1xpos = carXpos
   endif
 else
   if car2stat & 129 then
     NUSIZ1 = 0
     P1xpos = carXpos+16
   else
     ' Don't show either car
   endif
 endif

This would cause cars to flash for about 2 seconds when hit. In controlling carXpos you should allow it to go an extra 16 pixels to the right when car2stat is zero, and an extra 16 pixels to the left when car1stat is zero. Do this and your game will gain considerable polish.

If enemy car sprite is hit and missile position is greater than _____ then destroy right car, else destroy left car?

1004655[/snapback]

 

The code needs a variable to keep track of whether 1 or 2 cars exist (since NUSIZx are write-only). If two cars exist and the player's shot position is more than 8 pixels greater than the car position, the player shot the right car (and so you should add 16 to the car position).

 

Simple version would be something like (sorry I've not actually coded in bB yet):

 if (CXM1P & 64) then
   if shotXPos > carXPos+8 then
     carXPos=carXPos+16
   endif
   if twoCars then
     NUSIZ1 = 0
     twocars = 0
     ' Register shooting of one car
   else
     ' Blow up remaining car
   endif
 endif

Note that the car motion code should allow the cars to move further to the right if only one car exists than if two do.

 

If you want to be a little fancier, you could do something like this:

' Set both car1stat and car2stat to 128 when they appear at top of screen

 if (CXM1P & 64) then
   if shotXpos > carXpos+16 then
     if car2stat & 128 then
       car2stat = 127
       ' Score hit
     endif
   else
     if car1stat & 128 then
       car1stat = 127
       ' Score hit
     endif
   endif
 endif

' Just before draw kernel
 if car1stat & 127 then
   car1stat = car1stat-1
 endif
 if car2stat & 127 then
   car2stat = car2stat-1
 endif
 if car1stat & 129 then ' Either not hit, or every other frame if hit
   if car2stat & 129 then
     NUSIZ1 = 1
     P1xpos = carXpos
   else
     NUSIZ1 = 0
     P1xpos = carXpos
   endif
 else
   if car2stat & 129 then
     NUSIZ1 = 0
     P1xpos = carXpos+16
   else
     ' Don't show either car
   endif
 endif

This would cause cars to flash for about 2 seconds when hit. In controlling carXpos you should allow it to go an extra 16 pixels to the right when car2stat is zero, and an extra 16 pixels to the left when car1stat is zero. Do this and your game will gain considerable polish.

1004837[/snapback]

 

Thank you supercat!!!! :) I'll work on adding your sample code into the game. Now that you've explained it, it makes perfect sense -- I don't think I would have come up with that on my own.

 

Steve

Simple version would be something like (sorry I've not actually coded in bB yet):

 if (CXM1P & 64) then
   if shotXPos > carXPos+8 then
     carXPos=carXPos+16
   endif
   if twoCars then
     NUSIZ1 = 0
     twocars = 0
     ' Register shooting of one car
   else
     ' Blow up remaining car
   endif
 endif

Converted to bB syntax, this would be (I think):

 if !collision(player1,missile1) then goto nocollision
 temp1=carXPos+8:if shotXPos > temp1 then carXPos=carXPos+16
 if twoCars=0 then NUSIZ1 = 0:  twocars = 0
   rem if true, Register shooting of one car
   rem else Blow up remaining car
nocollision

I'm too lazy at the moment to convert the larger code snippet.

Thanks to the comments by supercat and batari, I was able to come up with a way to make the left & right cars disappear individually when they're shot. I've also increased the missile speed a bit.

 

It still doesn't work perfectly, in that once you destroy one of the two cars, shooting the remaining car will not make it disappear. To get around this problem, I could just increase the speed of the game enough so there's only time to destroy one of the two cars before they scroll off the screen. ;)

 

I'll post the code changes later after I've had time to clean it up and comment it.

 

Steve

rblast0.2.bin

Here's the current cleaned up & commented source code:

 

 rem --------------------
 rem Road Blaster
 rem    for batariBasic
 rem by Steve Engelhardt
 rem v0.2 (1/22/2006)
 rem --------------------
 rem
 rem ** There may be redundant or unnecessary code still in here --
 rem ** I've made lots of changes during my trial and error testing!
 rem 
init
 rem -------------
 rem Set Variables
 rem -------------
 x=75 : rem X Position of Player 0 (Human Car)
 c=0  : rem Hitpoint Counter 
 p=85 : rem Y Position of Player 0 (Human Car)
 g=1  : rem Y Position of Player 1 (Enemy Car)
 t=0  : rem used to calculate x pos of missile0
 b=82 : rem X Position of Ball
 u=64 : rem X Position of Player 1 (Enemy Car)
 W=0
 a=0  : rem counter
 o=0  : rem counter
 rem -------------
 rem Set Colors
 rem -------------
 COLUPF=144
 COLUBK=0
 CTRLPF=$35
 scorecolor=224
 rem -------------
 rem Set Audio
 rem  (not done with this yet)
 rem -------------
 AUDV0=0:AUDC0=2:AUDF0=1
 rem
 rem --------------
 rem Main Game Loop
 rem --------------
main
 rem g=g+1 : rem ** uncomment this line to make the enemy cars move twice as fast! **
 o=o+1 : rem O is used as a counter
 rem
 rem ** G is the Y Position of Enemy Car -- If the Y Position is less than 94, Scroll car down.
 rem
 if g < 94 then g=g+1 else g=0
 rem
 rem -------------------------------------
 rem Random Enemy Car & Roadblock Behavior
 rem -------------------------------------
 v=rand 
 if v > 180 then u=u-1              : rem randomly 'skids' computer car to the Left
 if v < 50 then u=u+1               : rem randomly 'skids' computer car to the Right
 rem
 rem ** The following will randomly generate the roadblock at 9 different X Positions.
 rem ** B is the X Position of the Ball
 rem
 if v=2   && g > 76 then b = 75     : rem Create Roadblock at X Position 75
 if v=234 && g > 76 then b = 105    : rem Create Roadblock at X Position 105
 if v=112 && g > 76 then b = 89     : rem Create Roadblock at X Position 89
 if v=50  && g > 76 then b = 81     : rem Create Roadblock at X Position 81
 if v=188 && g > 76 then b = 115    : rem Create Roadblock at X Position 115
 if v=166 && g > 76 then b = 79     : rem Create Roadblock at X Position 79
 if v=132 && g > 76 then b = 95     : rem Create Roadblock at X Position 95
 if v=176 && g > 76 then b = 111    : rem Create Roadblock at X Position 111
 if v=209 && g > 76 then b = 120    : rem Create Roadblock at X Position 120
 rem
 rem D is the left/right movement flag, set when the enemy car collides with playfield (side of road)
 rem
 if d=1 then u=u+1
 if d=2 then u=u-1 
 rem
 rem ** Player 1 is the Computer Controlled Car
 rem
 player1:               
 %00111100 
 %10011001 
 %11111111 
 %10011001 
 %00011000 
 %10011001 
 %11111111 
 %10011001 
 %00000000
end
 rem
 rem ** Z is a flag - when it equals 1, an enemy car has been hit by a missile.
 rem ** If the cars have scrolled off the screen (g>92), this flag is reset to 0.
 rem ** W is a color flag set in the carhit subroutine 
 rem
 if g > 92 then z=0 : w=0
 rem
 rem ** Z Flag is set to 1 when collision occurs and Reset to Zero when cars scroll off the bottom of the screen.
 rem
 if z=0 then NUSIZ1=$11
 NUSIZ0=$00
 rem
 rem ** W Flag is set during the carhit subroutine
 rem ** if w is 1 Change Player1 Car Color to Black
 rem 
 if w=1 then COLUP1=0 else COLUP1=52
 rem
 rem ** Player1's X and Y Position.
 rem
 player1y=g : player1x=u
 rem
 rem  ** player0 is the Human car
 rem
 player0: 
 %00111100 
 %10011001 
 %11111111 
 %10011001 
 %00011000 
 %10011001 
 %11111111 
 %10011001 
 %00000000
end
 rem
 rem ** Set Playfield to scroll down
 rem 
 pfscroll down
 rem
 rem ** Set Human Car's Color and X/Y Position
 rem
 COLUP0=196 : player0x=x : player0y=p
 rem 
 rem ** Create the 2 sides of the Road
 rem
 pfpixel 7 1 on : pfpixel 25 1 on : pfpixel 7 2 on : pfpixel 25 2 on
 pfpixel 7 3 on : pfpixel 25 3 on : pfpixel 7 4 on : pfpixel 25 4 on
 pfpixel 7 5 on : pfpixel 25 5 on : pfpixel 7 6 on : pfpixel 25 6 on
 pfpixel 7 7 on : pfpixel 25 7 on : pfpixel 7 8 on : pfpixel 25 8 on
 pfpixel 7 9 on : pfpixel 25 9 on : pfpixel 7 10 on: pfpixel 25 10 on
 drawscreen
 AUDV0=0
 rem
 rem ** Create Roadblock
 rem
 ballx=b : bally=g+15 : ballheight=2
 rem
 rem ** Move Human Car (Player0)
 rem
 if joy0left then x=x-1                  
 if joy0right then x=x+1                  
 if joy0up then g=g+1                     
 rem
 rem ** Limit X Position Movement of Player0
 rem **   (Redundant with Player0/Playfield Collision Detection?)
 rem
 if x<31 then x=31
 if x>152 then x=152
 rem
 rem ** Detect Joystick Button press - fire missile
 rem
 if joy0fire && q<1 then goto playerfires
 if q>0 then q=q-2 : missile0y=q : o=0    
 rem
 rem ---------------------------
 rem Collision Routines
 rem ---------------------------
 rem
 rem
 rem ** Don't allow Human car to drive off the road
 rem 
 if collision(playfield,player0) && x > 75 then x=x-1
 if collision(playfield,player0) && x < 75 then x=x+1
 rem
 rem ** When Computer Controlled car hits the playfield, bounce the other direction
 rem
 if collision(player1,playfield) && u > 100 then d=2 
 if collision(player1,playfield) && u < 80 then d=1
 rem
 rem ** If Player Car hits Computer Car, increase hitpoint counter.  At 15, end Game
 rem ** C is increased by more than 1 during a collision - Don't know why.
 rem ** Current 'hitpoint' setting of 15 allows for about 4 direct hits.
 rem
 if collision(player1,player0) then c=c+1 : if c=15 then goto thisisit
 if collision(player1,player0) then u=u+5
 rem
 rem ** If Player missile hits computer car, increase score by 1000
 rem
 if collision(player1,missile0) then goto carhit 
 rem
 rem ** If Player car hits roadblock bouce away from it
 rem
 if collision(player0,ball) && u > 90 then x=x-6 
 if collision(player0,ball) && u < 90 then x=x+6 
 rem
 rem ** Increase score by 10 (Just for staying alive)
 rem 
 score=score+10
 rem
 rem  ** Loop Back to Main
 rem
 goto main
 rem
 rem -----------------------
 rem Fire Missile Subroutine
 rem -----------------------
 rem
playerfires
 t=x+4
 missile0x=t
 q=80 : missile0y=75
 missile0height=6
 rem
 goto main
 rem
thisisit
 rem
 rem -----------------------------
 rem 'Game Over' Screen Subroutine
 rem -----------------------------
 pfpixel 7 1 off : pfpixel 25 1 off : pfpixel 7 2 off : pfpixel 25 2 off
 pfpixel 7 3 off : pfpixel 25 3 off : pfpixel 7 4 off : pfpixel 25 4 off
 pfpixel 7 5 off : pfpixel 25 5 off : pfpixel 7 6 off : pfpixel 25 6 off
 pfpixel 7 7 off : pfpixel 25 7 off : pfpixel 7 8 off : pfpixel 25 8 off
 pfpixel 7 9 off : pfpixel 25 9 off : pfpixel 7 10 off: pfpixel 25 10 off
 pfpixel 1 1 on : pfpixel 2 1 on : pfpixel 3 1 on : pfpixel 4 1 on
 pfpixel 5 1 on : pfpixel 7 1 on : pfpixel 8 1 on : pfpixel 9 1 on
 pfpixel 10 1 on : pfpixel 11 1 on : pfpixel 13 1 on : pfpixel 17 1 on
 pfpixel 19 1 on : pfpixel 20 1 on : pfpixel 21 1 on : pfpixel 22 1 on
 pfpixel 23 1 on : pfpixel 1 2 on : pfpixel 7 2 on : pfpixel 11 2 on
 pfpixel 13 2 on : pfpixel 14 2 on : pfpixel 16 2 on : pfpixel 17 2 on
 pfpixel 19 2 on : pfpixel 1 3 on : pfpixel 3 3 on : pfpixel 4 3 on
 pfpixel 5 3 on : pfpixel 7 3 on : pfpixel 8 3 on : pfpixel 9 3 on
 pfpixel 10 3 on : pfpixel 11 3 on : pfpixel 13 3 on : pfpixel 15 3 on
 pfpixel 17 3 on : pfpixel 19 3 on : pfpixel 20 3 on : pfpixel 21 3 on
 pfpixel 1 4 on : pfpixel 5 4 on : pfpixel 7 4 on : pfpixel 11 4 on
 pfpixel 13 4 on : pfpixel 17 4 on : pfpixel 19 4 on : pfpixel 1 5 on
 pfpixel 2 5 on : pfpixel 3 5 on : pfpixel 4 5 on : pfpixel 5 5 on
 pfpixel 19 5 on : pfpixel 20 5 on : pfpixel 21 5 on : pfpixel 22 5 on
 pfpixel 23 5 on : pfpixel 1 6 on : pfpixel 2 6 on : pfpixel 3 6 on
 pfpixel 4 6 on : pfpixel 5 6 on : pfpixel 7 6 on : pfpixel 11 6 on
 pfpixel 13 6 on : pfpixel 14 6 on : pfpixel 15 6 on : pfpixel 16 6 on
 pfpixel 17 6 on : pfpixel 19 6 on : pfpixel 20 6 on : pfpixel 21 6 on
 pfpixel 22 6 on : pfpixel 23 6 on : pfpixel 1 7 on : pfpixel 5 7 on
 pfpixel 7 7 on : pfpixel 11 7 on : pfpixel 13 7 on : pfpixel 19 7 on
 pfpixel 23 7 on : pfpixel 1 8 on : pfpixel 5 8 on : pfpixel 7 8 on
 pfpixel 11 8 on : pfpixel 13 8 on : pfpixel 14 8 on : pfpixel 15 8 on
 pfpixel 19 8 on : pfpixel 20 8 on : pfpixel 21 8 on : pfpixel 22 8 on
 pfpixel 23 8 on : pfpixel 1 9 on : pfpixel 5 9 on : pfpixel 8 9 on
 pfpixel 10 9 on : pfpixel 13 9 on : pfpixel 19 9 on : pfpixel 22 9 on
 pfpixel 1 10 on : pfpixel 2 10 on : pfpixel 3 10 on : pfpixel 4 10 on
 pfpixel 5 10 on : pfpixel 9 10 on : pfpixel 13 10 on : pfpixel 14 10 on
 pfpixel 15 10 on : pfpixel 16 10 on : pfpixel 17 10 on : pfpixel 19 10 on
 pfpixel 23 10 on
 COLUBK=0
 COLUPF=170
 COLUP0=0
 COLUP1=0
 drawscreen
 scorecolor=208
 rem
 rem ** I'd like to put a 'switchreset' detection routine in right here,
 rem **   so you can reset the game from the game over screen.
 rem ** Currently, if you uncomment the line below, the playfield graphics will
 rem **   be messed up when the reset button is used - a 'clear playfield'
 rem **   needs to be implemented here.
 rem if switchreset then goto main
 rem 
 rem ** I put this here to go into an infinite loop at the end of the game
 rem ** until I figure out how to clear the playfield before I use a 'switchreset'.
 rem
 goto eog
end
 rem -----------------------------------
 rem Enemy Car hit by Missile Subroutine
 rem -----------------------------------
carhit
 rem
 rem ** H is used as a flag to know when NUSIZ1 has been changed to 0
 rem ** It's reset at the beginning of the routine.
 rem
 h=0
 rem
 rem ** Z is a Color Flag
 rem ** Score is increased by 1000 when the missile hits the enemy car
 rem
 z=1 : score = score + 1000 : missile0x=60 
 rem
 rem ** A = The Enemy Car's X Position + 8
 rem 
 a=u+8
 rem 
 rem ** T = X Position of Missile0
 rem ** A = X Posiiton of Player1 (+8)
 rem ** If X Position of Missile0 Hit is less than (X+8) from Player1, set Nusiz1 to 0 to erase car
 rem ** H Flag is set, Car is shifted by 16
 rem
 if t < a then NUSIZ1=0 : h=1 : u=u+16 : goto main 
 rem
 rem ** If H=1, then one car has already been hit
 rem ** If X Position of Missile0 Hit is less than (X+8) from Player1, set COLUP1=0 to change car color to black
 rem ** u=u-16: Shift Car Position
 rem ** c=c+10: Invisible Car may hit player - this gives the "hit points" back in case it does.
 rem
 if h=1 && t > a then COLUP1=0 : W=1 : u=u-16 : c=c+10 : goto main
 rem
 goto main
 rem 
 rem --------------------------------------------
 rem EOG - 'End of Game' Infinite Loop Subroutine
 rem --------------------------------------------
 rem
 rem ** This is temporary until I get the game reset function working.
eog
 goto eog

  • Like 1

Changes look good. A few more suggestions, if I may...:D

 

1. You should be able to shoot another missile immediately after the 1st disappears from the screen.

2. Why not use both missiles so you can have 2 missiles on the screen at once?

3. Slow the scrolling when the player's car hits the side of the road.

Thank you for all the suggestions, vdub_bobby. I thought I'd reply to each one individually.

 

1. Remove the missile from the screen when it hits something.

 

I was able to do this -- the missile disappears when you hit a car.

 

2. Allow the player to speed up/slow down the scrolling.

 

Pressing up on the joystick will speed up the game. As far as pressing down on the joystick to slow down, I found that I can't slow the game down any further. If I decrease the Y value of the enemy cars by even one more increment, they sit still on the screen and don't move -- not much of an enhancement to gameplay. ;)

 

3. Make only the car you hit with a missile disappear when you hit it, rather than both.

 

This does work, each car can be shot individually and will disappear individually. The only current problem is shooting the remaining car after one has disappeared. You'll still score the 1000 points for hitting it, but it will not disappear. I should be able to figure out a way to fix this.

 

4. Are the roadblocks supposed to move L/R? Looks a little odd. Actually, there seem to be a couple of glitches with the roadblocks jumping around the screen.

 

This problem has been resolved, the roadblocks don't jump back and forth any more.

 

5. Some variations on enemy car movement?

 

I haven't really tried to do this yet -- I'll see what I can do.

 

6. Some variations on enemy car sprites?

 

I like this idea, but haven't tried it yet. Is it possible to define multiple sprite definitions to player0 and call a different one randomly? I'll try and see what I can do.

 

7. IMO the missile should move faster. And it should be smaller.

 

Missile speed has been increased.

 

8. Sound?

 

I've done most of the work on this game during my lunchbreak at work, and I can't work on sound in my cubicle. :) This is probably the last thing I'll add to the game when I get some time at home.

 

--

 

1. You should be able to shoot another missile immediately after the 1st disappears from the screen.

 

If you shoot and miss you will be able to immediately fire again after the missile scrolls off the top of the screen. If you shoot a car - the missile hasn't actually disappeared, it shifts and is hidden behind the left side of the road, so there will be a slight delay in your second shot if you've just successfully destroyed an enemy car.

 

2. Why not use both missiles so you can have 2 missiles on the screen at once?

 

Excellent idea! I was trying to decide if I wanted to use the second missile to have the enemy cars shoot back at you, or allow you to shoot two missiles on the screen at once. Thoughts?

 

3. Slow the scrolling when the player's car hits the side of the road.

 

I've got the same problem here that I had when trying to allow the player to slow his car down -- I don't think I can make the game run any slower to achieve this effect.

 

 

A few more features were added:

1. There is now a titlescreen. Press the reset button or push down on the joystick to start the game.

2. When the game ends, it takes you back to the title screen and displays your final score. Pressing reset again will restart the game again.

3. The left difficulty switch now has a function. If you change it to 'A', the player car doubles in size, and the enemy cars move twice as fast. There is a slight glitch with this, as the missile that fires from the human car is no longer shot from the center of the car, it's offset a little bit to the left. I probably can fix this, I just haven't tried to yet.

 

Any thoughts or suggestions on the scoring? Currently, 10 points are added every time the program runs through the main loop, and 1000 points are added for every car that's shot.

 

EDIT: I made a minor change from .3 to .31 -- the score wasn't resetting to 0 when you reset the game, and I added the ability to push down on the joystick to reset the game as well. From now on, I'll start posting the latest versions in the first post of this thread.

 

Here's the latest bB code and bin file:

rblast031.bin

rblast031.txt

Edited by Atarius Maximus

Looking very good!

 

I don't have a strong opinion either way about how to use the 2nd missile; I just say use it somehow! Having the enemy cars fire back would be cool; so would being able to shoot two bullets.

 

If you have extra RAM, look into using fractional math to control scrolling speed. This will give you more possible speeds. Something like...

   ScrollCounter = ScrollCounter - ScrollSpeed
  ScrollCounter = ScrollCounter - ScrollSpeed
  if ScrollCounter < 50 then ScrollCounter = 255 : gosub ScrollStuffSubroutine
  rem else don't scroll this frame

And run that code every frame.

 

If ScrollSpeed is 1 (for example), then the screen would scroll every ~100 frames, if ScrollSpeed was 110 it would scroll every frame. Or something similar.

 

I think you could, fairly easily, choose randomly between different enemy sprites. Something like (I don't remember the bB syntax very well so forgive any weird looking commands):

MakeNewCarSubroutine
  if rand<50 then CarType = 1 : return
  CarType = 0
  return

And then define your sprite based on the variable CarType. There's probably a better way to do this.

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