I have never used sprite collision before.
I am trying to shoot an alien, but my rocket seems to stick to the alien.
I've tried moving the rocket away upon impact. I've tried moving the alien away but the point of impact seems to stay where it is and when I shoot the rocket at the same place a collision is detected even though the alien isn't at that position anymore.
I'm using two sprites.
repeat
if rocket=0 then sprite 500,x#,386,149
if rocket=2 then sprite 501,x#,386,150
if rightkey()=1 and x#<200 then inc x#,0.1
if leftkey()=1 and x#>27 then dec x#,0.1
if spacekey()=1 and rocket=0 then rocket=1
if rocket=1 or rocket=2 then gosub rock:
if aexist=1 then gosub movealiens
if SPRITE COLLISION(502,503)=1 then gosub splat
sync
until lives=0
return
movealiens:
inc count
if count=400 then count=0
if aexist=1 and count<201 then sprite 503,ax#,ay#,153
if aexist=1 and count>200 then sprite 503,ax#,ay#,152
if dire=1 then inc ax#,0.1
if dire=1 and int(ax#)=200 then dire=2 : oldy#=ay#
if dire=2 and ay#<oldy#+20 then inc ay#,0.1
if dire=2 and int(ay#)>oldy#+19 then dire=3
if dire=3 then dec ax#,0.1
if dire=3 and int(ax#)<27 then dire=4 : oldy#=ay#
if dire=4 and ay#<oldy#+20 then inc ay#,0.1
if dire=4 and int(ay#)>oldy#+19 then dire=1
return
rock:
if rocket=1 then rx#=x#+12 : ry#=373 : inc rocket : show sprite 502 : hide sprite 500 : show sprite 501
if rocket=2 then sprite 502,rx#,ry#,151
if rocket=2 and ry#>220 then dec ry#,0.2
if rocket=2 and ry#<221 then hide sprite 502 : rocket=0 : hide sprite 501 : show sprite 500
return
splat:
No good deed goes unpunished!