Hi all.
I'm trying to create a clone of Space Invaders. I want the aliens to move at a slower pace than the gun. I've tried using a sleep command in the loop, but obviously this effects the speed of the gun movement as well as the aliens.
Here's my code so far:
print "Space Invaders"
print ""
print "Controls so far:"
print "Left Key......Move gun left"
print "Right Key.....Move gun right"
print ""
print "Press any key to begin or Esc key to exit"
wait key
cls
sync on
sync rate 30
hide mouse
REM Loading the bitmaps then deleting once assigned image number
load bitmap "A1.bmp", 1
get image 1,0,0,32,32
get image 2,32,0,64,32
delete bitmap 1
load bitmap "A2.bmp", 1
get image 3,0,0,32,32
get image 4,32,0,64,32
delete bitmap 1
load bitmap "A3.bmp", 1
get image 5,0,0,32,32
get image 6,32,0,64,32
delete bitmap 1
load bitmap "A4.bmp", 1
get image 7,0,0,32,32
get image 8,32,0,64,32
delete bitmap 1
load bitmap "A5.bmp", 1
get image 9,0,0,32,32
get image 10,32,0,64,32
delete bitmap 1
load bitmap "gun.bmp",1
get image 11,0,0,26,16
delete bitmap 1
load bitmap "invaders.jpg",1
get image 12,0,0,640,472
delete bitmap 1
REMSTART
Assign the initial location of the alien's x & y coords,
the direction they're travelling, the first frame of the
alien's animation, and the initial location of the gun.
REMEND
alienx = 100
alieny = 50
aliendir = 1
frame = 1
gunx = screen width()/2
do
REM Set the backdrop
paste image 12,0,0,0
REM Create a batch of alien sprites
for row=0 to 4
for col=0 to 10
sprite 1+(row*11)+col, alienx+(col*32),alieny+(row*32),frame+(row*2)
next col
next row
REM The aliens moving right
if aliendir = 1 then alienx = alienx + 20
if alienx => screen width()/2.3 then aliendir = 2
if alienx => screen width()/2.3 then alieny = alieny + 20
REM The aliens moving left
if aliendir = 2 then alienx = alienx - 20
if alienx = 20 then aliendir = 1
if alienx = 20 then alieny = alieny +20
REM Creating the alien animation
if frame = 1 then frame = 2 else frame = 1
REM Create the gun and assign the controls
sprite 300,gunx,400,11
if gunx => screen width()/5 and leftkey() then gunx = gunx - 10
if gunx =< (screen width() - screen width()/5) and rightkey() then gunx = gunx + 10
sync
loop
Any advice would be greatly appreciated!
Cheers,
Lee