Yes, I'm making a 2-d space shooter game thing, and I was wondering about help with some issues I'm having. I asked some in the 2D thread, but looking for a little more help here, if possible.
-How do I make these enemy (still about to get an enemy sprite ship) and asteroids (which I have now) move? I've tried altering their x/y axes, but it's not been doing anything. Is there an easy way to create a certain number of them
-For detecting the sprite collisions, would I just have to do a for/next statement to loop through all the sprites, and then do the same in the blowitup method (to find out where to loop explosion images)?
-As far as making enemy strengths and stuff, is there an example I can look at as far as using arrays for something like this?
-Also, just need to know a good way to set up how/when levels change, basically want to start out with small # of asteroids, then increase those, then go to enemy ships and the like.
Sorry if it's a lot to ask. Also, I wasn't sure which version of DB I was using (but found out recently!) that I'm using DBC.
Here's the code I have so far
sync on
sync rate 30
color backdrop 0
REM **Hide mouse pointer**
hide mouse
REM **Array for laser state**
dim laser(3)
REM **Load images**
load image "playership.bmp",1
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 "stars.bmp",50
REM **Load sounds**
LOAD SOUND "laser.wav",1
LOAD SOUND "explode.wav",2
REM **Stretch background over 3D object**
MAKE OBJECT PLAIN 4,600,56
ghost object on 4
POSITION OBJECT 4,0,-4,80
TEXTURE OBJECT 4,50
LOCK OBJECT ON 4
REM **Make background black**
color backdrop rgb(0,0,0)
REM **Set up score/level/life variables**
pf=0:score=0:Level=1:lives=3
REM **Set up where player ship position begins**
ysx=50:ysy=200
sprite 1,ysx,ysy,1
REM **Set up where player laser fires from**
lx=SPRITE X(1)+20
ly=SPRITE Y(1)+0
sprite 3,500,200,2
REM **MAIN GAME LOOP**
do
REM **Set Score/level/lives on screen**
set cursor 200,400:Print "SCORE:";score; " LEVEL:";level;" LIVES:";lives
REM **Movement up for player**
if UPKEY()=1 and ysy>100
dec ysy,10
dec ly,10
endif
REM **Movement down for player**
if DOWNKEY()=1 and ysy<350
inc ysy,10
inc ly,10
endif
REM **If player hits 'z' key, go to sub method to fire laser**
if inkey$()="z" and laser(3)=0 then gosub shoot
REM **If laser is shooting, check to see if it hits object**
if laser(3)=1
if SPRITE HIT(2,3)=1 then gosub blowitup
endif
REM **Refresh ship position**
sprite 1,ysx,ysy,1
REM **Go to sub method moveall to move things like laser**
gosub moveall
REM **Go to sub method movestars to scroll background**
gosub movestars
REM **If player hits escape key, exit the loop**
if escapekey()=1 then exit
sync
REM **End of main loop**
loop
REM **Shows mouse and exits the game**
show mouse
end
movestars:
REM **Scroll the background texture**
SCROLL OBJECT TEXTURE 4,0.01,0.0
return
shoot:
REM **If laser is fired, alter it's state and then play laser firing sound**
laser(1)=SPRITE X(1)+20
laser(2)=SPRITE Y(1)+10
laser(3)=1 : rem status=active
sprite 2,laser(1),laser(2),3
PLAY SOUND 1
return
moveall:
REM **Increment laser x if still on screen, then delete sprite**
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 2
endif
endif
return
blowitup:
REM **Delete the laser sprite**
delete sprite 2
REM **Set statues to inactive**
laser(3)=0
REM **Play exploding sound**
PLAY SOUND 2
REM **Loop through explosion images**
for t=6 to 9
sprite 3,SPRITE X(3),SPRITE Y(3),t
sync
next t
delete sprite 3
return
Thanks for any help!