sync rate 30
create bitmap 1,20,20
box 0,0,20,20
get image 1,0,0,20,20,1
ink RGB(255,0,0),RGB(0,0,0)
box 0,0,20,20
get image 10,0,0,10,10,1
delete bitmap 1
ink RGB(255,255,255),RGB(0,0,0)
`above code just creates a player image num 1 and an red enemy image num 10
`player sprite number = 1
`enemy sprite numbers = 10,11,12,13,14
randomize timer()
`position the player sprite
sprite 1,20,screen height()/2,1
`Main loop
do
`Create the enemy sprites if needed
for i = 10 to 14 : `loop through each of the enemy sprite nums
if sprite exist(i) = 0 `if the sprite doesn't exist
`create a new sprite and postion it randomly on the screen
sprite i,rnd(screen width()),rnd(screen height()),10
endif
next i
`check if the sprite is off screen and if it is remove it
for i = 10 to 14
if sprite exist(i)
if sprite x(i) < -10 then delete sprite i
endif
next i
`check if any sprites have hit the player sprite
for i = 10 to 14
if sprite exist(i)
if sprite collision(1,i)
`the sprites are colliding so delete the enemy sprite
delete sprite i
endif
endif
next i
`Move any existing enemy sprites
for i = 10 to 14
if sprite exist(i)
sprite i,(sprite x(i)-5),sprite y(i),sprite image(i)
endif
next i
`move the player sprite up when the up arrow is press and down when down arrow pressed
if upkey() then sprite 1,sprite x(1),sprite y(1)-5,1
if downkey() then sprite 1,sprite x(1),sprite y(1)+5,1
loop
dbpro : p166mmx @ 233 : 256mb : sb 128pci : sis onboard