I made a similar game you should be able to figure it out from this code.
You will need
sprite x
sprite y
sprite collision
look at the control_gun: and control_bullet: in this code
rem sprites 5-9-bird 10-14-egg 15-19-hatched
gosub _load_game
gosub _start_screen
do
gosub _control_player
gosub _control_gun
gosub _control_bullet
gosub _make_bird
gosub _control_bird
gosub _control_egg
gosub _control_hatched
cls
set cursor 0,0 : print "Score:"
set cursor 50,0 : print score
`set cursor (screen width() -65),0 : print "FPS:"
`set cursor (screen width() -30),0 : print screen fps()
print temp
sync
if dead = 1
dead = 0
score = 0
gosub _start_screen
`remove all birds,eggs,hatched and put man in middle of screen
endif
loop
wait 1000
_control_player:
if leftkey()=1
if sprite x(1) > 5 then sprite 1,(sprite x(1) -1),sprite y(1),6
endif
if rightkey()=1
if sprite x(1) < (screen width() -45) then sprite 1,(sprite x(1) +1),sprite y(1),6
endif
` check for collisions with eggs and hatched birds
for temp = 10 to 19
if sprite collision(1,temp) = 1
if temp < 15
dead = 1
else
dead = 1
endif
endif
next temp
return
_control_gun:
if controlkey()=1
if sprite exist (3) = 0
sprite 3,(sprite x(1) +22),325,2
endif
endif
return
_control_bullet:
if sprite exist (3)
sprite 3,sprite x(3),(sprite y(3) -2),2
if sprite y(3) < -1
delete sprite 3
endif
endif
if sprite exist (3)
spr = 4
repeat
spr = spr + 1
if sprite exist(spr) = 1
if sprite exist (3)
if sprite collision(3,spr) = 1
delete sprite 3
if spr < 10 : `it's a bird
delete sprite spr : makebird = makebird + 1 : score = score + 5
else
if spr < 15 : `it's an egg
delete sprite spr : egg = egg - 1 : score = score + 15
else `it's a hatched bird
if spr < 20 then delete sprite spr : hatched = hatched -1 : score = score +10
endif
endif
endif
endif
endif
until spr = 19
endif
return
_make_bird:
if makebird > 0
spr = getsprite(1)
if rnd(1) = 1 : `right to left
sprite spr,(rnd(1500)+640),(rnd(130)+10),3
else : `left to right
sprite spr,(rnd(1500)-1545),(rnd(130)+10),3
mirror sprite (spr)
endif
makebird = makebird -1
endif
return
_control_bird:
FOR temp = 5 TO 9
if sprite exist(temp)
if sprite mirrored (temp)
sprite temp,(sprite x (temp) + 1),sprite y (temp),3
if sprite x (temp) > 640 then delete sprite (temp) : makebird = makebird + 1
else
sprite temp,(sprite x (temp) - 1),sprite y (temp),3
if sprite x (temp) < - 45 then delete sprite (temp) : makebird = makebird + 1
endif
endif
NEXT temp
return
_control_egg:
` Make eggs
if rnd(750) = 65
temp = (rnd (4)+5)
if sprite exist(temp)
if sprite x (temp) > 20 : ` make sure bird is in screen area
if sprite x (temp) < 620
if egg < 5
randomize timer()
spr = getsprite(2)
sprite spr,sprite x (temp),sprite y (temp),4
egg = egg +1
endif
endif
endif
endif
endif
` Control eggs
for temp = 10 to 14
if sprite exist(temp)
if sprite y (temp) < 420 : `move sprite if it's not on ground
sprite temp,sprite x (temp),(sprite y (temp)+1),4
else
if eggs((temp-10)) < 750
eggs((temp-10)) = eggs((temp-10)) + 1
else
eggs((temp-10)) = 0
if hatched < 5
spr = getsprite(3)
sprite spr,sprite x (temp),(sprite y (temp)+15),5 : hatched = hatched + 1
if rnd(1) = 0 : ``move bird left or right after hatching?
hatch((spr -15),0) = 0 : `bird will go left
else
hatch((spr -15),0) = 1 : `bird will go right
endif : `bird needs to go up as egg is at ground level
hatch((spr -15),1) = 0
endif
delete sprite temp : egg = egg - 1
endif
endif
endif
next temp
return
_control_hatched:
for temp = 15 to 19
if sprite exist(temp)
if hatch((temp -15), 0) = 0 then tempx = (sprite x (temp) - 1)
if hatch((temp -15), 0) = 1 then tempx = (sprite x (temp) + 1)
if hatch((temp -15), 1) = 0 then tempy = (sprite y (temp) - 2)
if hatch((temp -15), 1) = 1 then tempy = (sprite y (temp) + 2)
sprite temp,tempx,tempy,5
if tempx < 5 then hatch((temp -15), 0) = 1
if tempx > (screen width() -45) then hatch((temp -15), 0) = 0
if tempy < 5 then hatch((temp -15), 1) = 1 : flip sprite temp
if tempy > (screen height() - 45) then hatch((temp -15), 1) = 0 : flip sprite temp
endif
next temp
return
_start_screen:
load image "splash.png",10
sprite 10,0,0,10
sync
repeat
`repeat until a key is pressed
until scancode() > 0
delete sprite 10
delete image 10 : `get rid of splash screen
return
_load_game:
sync on
set image colorkey 0,255,0
load image "back.png",1,1
load image "man.png",6,1
load image "bullet.png",2,1
load image "bird.png",3,1
load image "egg.png",4,1
load image "hatched.png",5,1
sprite 2,0,15,1
sprite 1,310,330,6
sync on
randomize timer()
rem initial variables
egg = 0 : hatched = 0 : makebird = 5 : dead = 0 : score = 0
dim eggs(4) : `counter for hatching eggs
dim hatch(5,1) : `0/1 left/right 0/1 up/down
return
function getsprite(z)
`z = 1 bird, 2 egg, 3 hatched bird
x = 0
if z = 1
y = 4
repeat
y = y + 1
x = sprite exist(y)
until x = 0
endif
if z = 2
y = 9
repeat
y = y + 1
x = sprite exist(y)
until x = 0
endif
if z = 3
y = 14
repeat
y = y + 1
x = sprite exist(y)
until x = 0
endif
endfunction y