load image "ship.bmp",1
load image "shot.bmp",2
load image "bigasteroid.bmp",3
load image "smallasteroid.bmp",4
sprite 1,-1000,0,1
sprite 2,-10000000,-10000000,2
offset sprite 1,42,67
sprite 1,320,240,1
rotate=0
shootok=0
whichxy=1
x1=0
x2=0
y1=0
y2=0
loopno=0
do
load bitmap "background.bmp",0
gosub move
gosub outedges
if loopno>2 then gosub keepmoving
inc loopno
loop
move:
rotate sprite 1,rotate
if upkey()=1 then move sprite 1,5
if downkey()=1 then move sprite 1,-5
if rightkey()=1 then rotate=rotate+10
if leftkey()=1 then rotate=rotate-10
if sprite x(2)>680 then shootok=1
if sprite x(2)<-40 then shootok=1
if sprite y(2)<-40 then shootok=1
if sprite y(2)>520 then shootok=1
move sprite 2,15
if spacekey()=1 and shootok=1
rotate sprite 2,rotate
sprite 2,sprite x(1),sprite y(1),2
shootok=0
endif
return
outedges:
if sprite x(1)>702 then sprite 1,-62,sprite y(1),1
if sprite x(1)<-62 then sprite 1,702,sprite y(1),1
if sprite y(1)>542 then sprite 1,sprite x(1),-62,1
if sprite y(1)<-62 then sprite 1,sprite x(1),541,1
return
keepmoving:
if whichxy=1
x1=sprite x(1)
y1=sprite y(1)
endif
if whichxy=2
x2=sprite x(1)
y2=sprite y(1)
endif
if whichxy=1
movingx=x1-x2
movingy=y1-y2
endif
if whichxy=2
movingx=x2-x1
movingy=y2-y1
endif
sprite 1,sprite x(1)+movingx,sprite y(1)+movingy,1
if whichxy=1 then whichxy=2
if whichxy=2 then whichxy=1
return
In this program (the beginnings of an Asteroids remake), there is a strange error. The "keepmoving" function, instead of making the ship keep moving because of zero gravity, for some reason, adds 320 and 240, respectively, to the ship's x and y coordinates, respectively. I've looked through the entire program and cannot see why this is. Do you people have any idea what is going on? (this is in DBPro)