Hi guys I need your help once again!!!
I'm trying to make my first game,(not Space Invaders again)
I can't seem to get the aliens to move down the page, in the way that they should, now I'm getting a bit confused, and I'm not really familiar with all the sprite commands.
Can anyone maybe give me some pointers ? Also what's the best way to create various levels, within a function maybe using case-endcase?
Hope someone can help, Cheers !!!!
`***************************************************************
`********************* Space Invaders ****************
`********************* Created 20/05/2006 ****************
`********************* Coded by Anthony Kelly ****************
`***************************************************************
`------------------------- KEYS ------------------------------
`-------------- Left and Right arrows to control ship ----------
`-------------- z key to shoot weapon ----------
`---------------------------------------------------------------
set display mode 800,600,16
hide mouse
sync rate 85
dim sp(52,4)
global x
global y#
global counter
global score
global pf
sw=screen width()
constants#=sw
counter=0
lives=3
speed=1
pf=0
x=60
y=80
`load sound "shoot.wav",1
`load image "space.jpg",1
`intro()
cls
set text font "arial"
set text size 16
`your ship shape
for i=501 to 501
box 0,15,25,25
box 5,10,20,20
box 10,3,15,15
get image i,0,0,25,25
next i
`bullet shape
for i=502 to 502
box 0,0,1,15
get image i,0,0,1,15
next i
`aliens shape
for i=1 to 52
box 0,0,25,25,rgb(0,0,0),rgb(100,100,100),rgb(200,200,200),rgb(0,0,0)
center text 12,4,str$(i)
get image i,0,0,25,25
next i
`aliens position
for i=1 to 52
if x=> 700
x=60
y=y+50
endif
sprite i,x,y,i
sp(i,3)=x
sp(i,4)=y
inc x,50
next i
x=400
y=570
y#=y
color backdrop 0
set text size 20
set text to bold
`Main Loop
do
ink -1,0
box 0,0,sw,20
ink rgb(255,0,0),0
text xx+20,yy,"Score : "
text xx+600,yy,"Lives : "
ink rgb(0,0,255),0
text xx+80,yy,str$(score)
text xx+655,yy,str$(lives)
`player
sprite 501,x,y,501
`Can't seem to get aliens to move down page correctly !!!!!!!!!
`---------------------------------------------------------------
`trying to move sprites across page
for p=1 to 52
if sprite exist(p)
sprite p,sp(p,3),sp(p,4),p
sp(p,3)=sp(p,3)+speed
if sp(p,3) > 780
sp(p,4)=sp(p,4)+10
speed=-1
endif
if sp(p,3) < 0
sp(p,4)=sp(p,4)+10
speed=1
endif
endif
next p
`---------------------------------------------------------------
if leftkey()=1 then x=x-1
if rightkey()=1 then x=x+1
if keystate(44)=1 then pf=1
`if y#=550 then play sound 1
`if z key pressed, goto function shot()
if pf=1
shot()
endif
`Bullet conditions
if y#<=40
if sprite exist(502)
if y#<=40 then delete sprite 502
endif
y#=y
pf=0
endif
`if condition is true player has won level
if counter=52
win()
exit
endif
loop
end
function intro()
paste image 1,0,0
ink -1,0
wait key
endfunction
function shot()
`bullet
sprite 502,x+12,y#-15,502
dec y#,10
for i=1 to 52
if sprite exist(i)
if sprite collision(502,i)
delete sprite i
delete sprite 502
counter=counter+1
score=counter
y#=y-15
pf=0
exitfunction
endif
endif
next i
endfunction
function win()
wait 1000
repeat
hide all sprites
color backdrop 0
set text size 20
ink rgb(0,0,255),0
set text size 20
center text 400,250,"Level complete"
set text size 16
ink -1,0
center text 400,280,"Score : "+str$(score)
keypress=scancode()
until keypress > 1
endfunction