Hi, Thanks for the info. It seems I've been looping it correctly, or semi correctly at least, so I'm unsure what the error is in my code.
sync on
sync rate 30
color backdrop 0
hide mouse
Load image "yourship.bmp",1
Load image "alienship.bmp",2
load image "orb.bmp",3
load image "greenlazer.bmp",4
load image "yellowlazer.bmp",5
load image "exp1.bmp",6
load image "exp2.bmp",7
load image "exp3.bmp",8
load image "exp4.bmp",9
load image "exp5.bmp",10
load image "exp6.bmp",11
load image "stars.bmp",50
Load image "title.bmp",9999
Load sound "phaser03.wav",1
Load sound "boom2.wav",2
Make Object Plain 4,600,56
Ghost Object On 4
Position Object 4,0,-4,80
Texture Object 4,50
Lock Object on 4
color backdrop rgb(0,0,0)
main:
pf=0 : score=0 : Level=1 : Lives=3
ysx=50 : ysy=200
sprite 1,ysx,ysy,1
lx=Sprite x(1)+20
ly=Sprite y(1)+10
Sprite 3,500,200,2
Sprite 9999,10,10,9999
rem main loop
do
rem repeat
set cursor 200,400 : Print "Player Score:";score; " Current Level:";level; " Lives Remaining:";lives
Gosub Moveall
Gosub Movestars
Gosub Score
if Upkey()=1 and ysy>50
dec ysy,10
Sprite 1,ysx,ysy,1
lx=sprite x(1)+20
rem lx= sprite x(1)+20
endif
If Downkey()=1 and ysy<400
inc ysy,10
Sprite 1,ysx,ysy,1
lx=sprite y(1)+10
endif
rem Sprite 1,ysx,ysy,1
Sprite 3,500,200,2
sprite 9999,10,10,9999
If scancode()=44 and Sprite Exist(2)=0 Then Gosub shoot : pf=1
If Sprite Exist(2)=1
lx= Sprite x(2) +10
rem ly= Sprite y(1) +10
Sprite 2,lx,ly,4
If Sprite Collision(2,3)=1
Gosub blowup
score=score+500
endif
endif
rem Gosub Moveall
rem Gosub Movestars
sync
loop
rem Until Escapekey()=1
Score:
If Sprite Exist(2)=1
If Sprite collision(2,3)=1
score=score+500
rem else
rem score = score
endif
endif
set cursor 200,400 : Print "Player Score:";score; " Current Level:";level; " Lives Remaining:";lives
return
Movestars:
Scroll Object Texture 4,0.001,0.0
return
Shoot:
If pf=1
lx=lx+10
sprite 2,lx,ly,4
sprite 1,ysx,ysy,1
Play Sound 1
endif
pf=0
gosub moveall
return
MoveAll:
If Sprite Exist(2)=1
If Sprite X(2)<=640
lx=lx+10
rem sprite 2,lx,ly,4
endif
endif
If Sprite Exist(2)=1
If Sprite X(2)=>640 and pf=0
delete sprite 2
rem lx=Sprite x(1)+20
rem ly=Sprite y(1)+10
endif
endif
return
Blowup:
delete sprite 2
lx=sprite x(1) +20
rem ly=Sprite y(1) +10
play sound 2
for t=6 to 11
sprite 3,500,200,t
wait 1
next t
delete sprite 3
sprite 1,ysx,ysy,1
sprite 3,500,200,2
Sprite 9999,10,10,9999
return
return
(some bits are remarked out as I continue to play with the code trying to find an answer.
It runs fine once, you can "shoot" the sprite laser once, it will hit the "enemyship" sprite and collision detection occurs, it then runs my explosion sub routine.
After that, it seems to loop but has errors in it. You can now press fire, but must hold the fire key to get the "laser" to move across the screen. When it passes the "enemyship" sprite, there is no longer any collision detection, I'm not sure exactly what is wrong to be totally honest.
Thank you for your time and help, it's greatly appreciated!
Xatnys
Hello.
Goodbye.
