Moving object from point A to B...

BlitzPlus Forums/BlitzPlus Programming/Moving object from point A to B...

Well, when you fire the bullet, then store the x and y position of the object you are shooting at and store the x and y of the position you are shooting from.

Then each time you update you check to see if the x and y position of the bullet is equal to the x and y position you stored and if not you either deduct or add depending on whether they are larger or smaller and then draw the bullet in the new position and continue to do so until they reach the target.

I hope that made sense.

function newBullet(x,y,xx,yy)
b.bullet = new bullet
b\x1 = x
b\y1 = y
b\x2 =yy
b\y2 = yy
end function

function updateBullet
if b\x1 < b\x2 then b\x1 = b\x1 + 1
if b\x1 > b\x2 then b\x1 = b\x1 - 1
if b\y1 < b\y2 then b\y1 = b\y1 + 1
if b\y1 > b\y2 then b\y1 = b\y1 - 1
drawimage bulletImg,b\x1,b\y1
if b\x1 = b\x2 and b\y1 = b\y2 then
; what ever you want to do when bullet is there
end if
end function

This is just something I threw together quick, but it mey work :-)