I'be been working on a simple space invaders clone however I'm having some problems getting my sprites to behave correctly. When they reach the side of the screen they are ment to drop slightly and start heading back in the other direction.
I've fiddled with the code and I either get them turning round and dropping but the last couple sprites overlap each other. Or I get don't get them turning around but they kinda slant off the screen.
I'd appretiate any help with this, I know its probably going to be something simple I've missed >_<
This is my code for moving the enemy sprites
waittime=waittime+1
if waittime=45
for enemymove=11 to 22
if sprite exist(enemymove)=1
enemycount=enemycount+1
if sprite x(enemymove)>700
enemyypos=enemyypos+10
endif
move=-20
if sprite x(enemymove)<40
enemyypos=enemyypos+10
endif
move=20
sprite enemymove,sprite x(enemymove)+move,enemyypos,3
endif
waittime=1
next enemymove
endif
This is the entire code
set display mode 800,600,16
dir$="H:\Advanced Higher\DarkBASIC\Space Invaders\"
hide mouse
sync rate 60
load image dir$+"ship.jpg",1
load image dir$+"bullet.jpg",2
load image dir$+"enemy1.jpg",3
sprite 1,800,500,1
Sprite 2,0,0,2
Sprite 3,0,0,2
Sprite 10,0,0,3
Hide sprite 2
Hide Sprite 3
SET SPRITE 1,1,1
SET SPRITE 2,1,1
SET SPRITE 3,1,1
SET SPRITE 10,1,1
waittime=0
pxpos=380
pypos=550
bypos=550
bypos2=500
bxpos=0
bxpos2=0
enemy1=0
enemy2=100
enemyypos=30
exist=1
enemycount=20
y=0
for x = 11 to 22
CLONE SPRITE 10,x
next x
for x = 11 to 22
sprite x,y,-100,3
y=y+50
next x
hide sprite 10
enemyxpos=40
enemyypos=30
do
if rightkey()=1 and pxpos<750 then inc pxpos,5
if leftkey()=1 and pxpos>10 then dec pxpos,5
sprite 1,pxpos,pypos,1
if spacekey()=1 and fire1=0
fire1=1
bxpos=pxpos+10
endif
if fire1=1
show sprite 2
dec bypos,10
sprite 2,bxpos,bypos,2
if bypos<200 then fire2=1
if bypos<-10
bypos=550
hide sprite 2
fire1=0
endif
endif
waittime=waittime+1
if waittime=45
for enemymove=11 to 22
if sprite exist(enemymove)=1
enemycount=enemycount+1
if sprite x(enemymove)>700
enemyypos=enemyypos+10
endif
move=-20
if sprite x(enemymove)<40
enemyypos=enemyypos+10
endif
move=20
sprite enemymove,sprite x(enemymove)+move,enemyypos,3
endif
waittime=1
next enemymove
endif
for x = 11 to 22
hit=sprite collision(2,x):if hit=1 then delete sprite x
next x
remstart
if spacekey()=1 and fire1=1 and fire2=1
fire3=1
bxpos2=pxpos+10
endif
if fire3=1
show sprite 3
dec bypos2,10
sprite 3,bxpos2,bypos2,2
if bypos2<-10
bypos=400
hide sprite 3
fire2=0
fire3=0
endif
endif
remend
loop