The idea of having the asteroids 'run out' was to give the user a little bit of a break in between levels. It is no problem to take it out of the program and just have it progressively get harder. The revised code:
rem plan on the following sprite layout:
` 1 = player1
` 2 = laser missile
` 3-17 = asteroids
` 20-22 = alien ships
` 23-25 = alien missiles
sync on
sync rate 30
color backdrop 0
hide mouse
dim laser(3)
dim asteroid(15,10)
dim enemy(15,10)
dim difficulty(3,9)
player_status = 1
player_image = 1
player_exp_delay = 0
load image "playership.bmp",player_image
load image "asteroid.bmp",2
load image "laser.bmp",3
load image "boom1.bmp",5
load image "boom2.bmp",6
load image "boom3.bmp",7
load image "boom4.bmp",8
load image "boom5.bmp",9
load image "enemyship.bmp",10
load image "enemylaser.bmp",11
LOAD SOUND "laser.wav",1
LOAD SOUND "explode.wav",2
LOAD MUSIC "gra3fs.mid",1
PLAY MUSIC 1
LOOP MUSIC 1
load image "stars.bmp",50
MAKE OBJECT PLAIN 4,600,56
ghost object on 4
POSITION OBJECT 4,0,-4,80
TEXTURE OBJECT 4,50
LOCK OBJECT ON 4
color backdrop rgb(0,0,0)
score=0 : Level=1 : lives=3 : total_levels=3
ysx=50 : ysy=200 : player1=1 : missile=2
hits=0
sprite player1,ysx,ysy,player_image
restore LEVEL_DATA
for i=1 to total_levels
for t=1 to 9
read difficulty(i,t)
next t
next i
asteroid_count=0
`total_asteroids=difficulty(level,1)
asteroids_on_screen=difficulty(level,2)
asteroid_max_speed=difficulty(level,3)
total_ships=difficulty(level,1)
ships_on_screen=difficulty(level,2)
ships_max_speed=difficulty(level,3)
` MAIN LOOP &&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&
do
set cursor 200,400:Print "SCORE:";score; " LEVEL:";level;" LIVES:";lives
gosub PLAYER_CONTROL
if laser(3)=1
for k=1 to 15
if asteroid(k,3)=1
` check to see if laser hit an asteroid
if SPRITE HIT(missile,k+2)=1 and asteroid(k,3)=1
gosub blowitup
asteroid(k,4)=asteroid(k,7)
sprite k+2,asteroid(k,1),asteroid(k,2),asteroid(k,4)
asteroid(k,3)=2 : ` set status to exploding
endif
endif
next k
endif
gosub moveall
gosub movestars
gosub MOVE_ASTEROIDS
REM Go to enemy ship gen method
sync
if player_image>=9 and player_status=2
gosub LOSE_LIFE
if lives>0
player_image=1
player_status=1
sprite player1,ysx,ysy,player_image
endif
endif
if escapekey()=1 or lives=0 then exit
loop
` MAIN LOOP &&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&
ink rgb(255,255,0),0
set text size 48
t=timer()
repeat
center text (screen width()/2),(screen height()/2),"GAME OVER!"
sync
until timer()>(t+3000)
show mouse
end
`ENEMY_SHIP
`Check to see if one exists
`Start one off screen
`Move over to screen
`shoot when reached a certain x-coordinate
`Generate and shoot laser
PLAYER_CONTROL:
if UPKEY()=1 and ysy>100 and player_status=1
dec ysy,10
dec ly,10
sprite player1,ysx,ysy,player_image
endif
if DOWNKEY()=1 and ysy<350 and player_status=1
inc ysy,10
inc ly,10
sprite player1,ysx,ysy,player_image
endif
if player_status=2 and timer()>player_exp_delay
inc player_image,1
sprite player1,ysx,ysy,player_image
player_exp_delay=timer()+100
endif
if inkey$()="z" and laser(3)=0 then gosub shoot
return
MOVE_ASTEROIDS:
active=0
for k=1 to 15
if asteroid(k,3)=2
asteroid(k,4)=asteroid(k,4)+1
sprite k+2,asteroid(k,1),asteroid(k,2),asteroid(k,4)
if asteroid(k,4)>asteroid(k,8)
delete sprite k+2
asteroid(k,3)=0
endif
endif
if asteroid(k,3)=1
asteroid(k,1)=asteroid(k,1)-asteroid(k,5)
sprite k+2,asteroid(k,1),asteroid(k,2),2
if asteroid(k,1)<(0-sprite x(k+2)) : ` check to see if it has moved off screen
delete sprite k+2
asteroid(k,3)=0
else
inc active
` check to see if asteroid collided with player
if SPRITE HIT(k+2,player1)=1 and player_status=1
gosub killplayer
asteroid(k,3)=0
delete sprite k+2
dec active
endif
endif
endif
next k
if active<asteroids_on_screen
` make new asteroid if possible
` first see if a asteroid is available
ast=0
for k=1 to 15
if ast=0 and asteroid(k,3)=0 then ast=k
next k
if ast>0
` start with x coordinate off the screen
asteroid(ast,1)=650 : ` x coord
asteroid(ast,2)=rnd(225)+100 : ` y coord
asteroid(ast,3)=1 : ` status=active
asteroid(ast,4)=2 : ` image for asteroid
a=asteroid_max_speed/2
asteroid(ast,5)=rnd(a)+a*2 : ` h speed
asteroid(ast,7)=6 : ` explode img - first - must be sequential
asteroid(ast,8)=9 : ` explode img - last - must be sequential
sprite ast+2,asteroid(ast,1),asteroid(ast,2),asteroid(ast,4)
inc asteroid_count
endif
endif
return
movestars:
SCROLL OBJECT TEXTURE 4,0.01,0.0
return
shoot:
laser(1)=SPRITE X(player1)+20
laser(2)=SPRITE Y(player1)+10
laser(3)=1 : rem status=active
sprite missile,laser(1),laser(2),3
PLAY SOUND 1
return
moveall:
if laser(3)=1
If laser(1)<640
laser(1)=laser(1)+45
sprite 2,laser(1),laser(2),3
endif
If laser(1)>640
laser(3)=0
delete sprite missile
endif
endif
return
blowitup:
inc hits, 1
if hits = 5
difficulty(level,1) = 125
total_asteroids = difficulty(level,1)
difficulty(level,2) = 2
asteroids_on_screen=difficulty(level,2)
endif
if hits = 10
difficulty(level,1) = 125
total_asteroids = difficulty(level,1)
difficulty(level,2) = 4
asteroids_on_screen=difficulty(level,2)
endif
if hits = 20
difficulty(level,1) = 125
total_asteroids = difficulty(level,1)
difficulty(level,2) = 6
asteroids_on_screen=difficulty(level,2)
endif
if hits = 35
difficulty(level,1) = 125
total_asteroids = difficulty(level,1)
difficulty(level,2) = 8
asteroids_on_screen=difficulty(level,2)
endif
if hits = 60
level = 2
difficulty(level,1) = 125
total_asteroids = difficulty(level,1)
difficulty(level,2) = 10
asteroids_on_screen=difficulty(level,2)
endif
if hits = 90
difficulty(level,1) = 125
total_asteroids = difficulty(level,1)
difficulty(level,2) = 12
asteroids_on_screen=difficulty(level,2)
endif
if hits = 120
level = 3
difficulty(level,1) = 125
total_asteroids = difficulty(level,1)
difficulty(level,2) = 13
asteroids_on_screen=difficulty(level,2)
endif
if hits = 150
difficulty(level,1) = 125
total_asteroids = difficulty(level,1)
difficulty(level,2) = 14
asteroids_on_screen=difficulty(level,2)
endif
if hits = 200
difficulty(level,1) = 125
total_asteroids = difficulty(level,1)
difficulty(level,2) = 15
asteroids_on_screen=difficulty(level,2)
endif
difficulty(level,1) = 125
total_asteroids = difficulty(level,1)
delete sprite 2
laser(3)=0
PLAY SOUND 2
score=score+(level*25)
return
killplayer:
PLAY SOUND 2
player_status=2 : ` status = exploding
player_image=6
sprite player1, SPRITE X(player1), SPRITE Y(player1),player_image
player_exp_delay=timer()+100
return
LOSE_LIFE:
dec lives,1
if lives=0
if sprite exist(player1) then delete sprite player1
for k=1 to total_asteroids
if asteroid(k,3)=1 then delete sprite k+2
asteroid(k,3)=0
next k
if laser(3)=1 then delete sprite missile
endif
return
LEVEL_DATA:
rem 1=total_asteroids, 2=asteroids_on_screen, 3=asteroid_max_speed
rem 4=asteroid_split, 5=asteroid_type, 6=homing_missile, 7=alien_ship
rem 8=alien_ship_missile, 9=shield_hit
rem level 1
data 125,1,8,0,1,0,0,0,5
rem level 2
data 60,2,10,0,2,0,0,0,5
rem level 3
data 70,3,15,2,2,0,1,0,10
It does indeed get a lot harder fairly quickly, in fact I had to take out the gosub to the LOSE_LIFE subroutine in order to test it. You may want to think about a few things:
1. Is the hardness factor progressing too quickly?
2. Do you need more than one shot at a time on the screen? (Maybe you could put in a powerup as the game progresses to allow for additional player shots.)
3. What about a rapid fire option if the fire button is simply held down? (powerup?)
4. Is the level indicated on the screen correct? It did not seem to update correctly.
5. Do you need more lives to start with?
6. What about a one-up powerup?
7. How about an option to pause the game?
You idiots! You've captured their stunt doubles!