Basically, when you click the mouse the sprite needs to 'walk' to where the mouse has been clicked. I can only get the sprite to move along the horizontal/virtical/diagonal axis which is close to what I want, but not quite. I would prefer it if the sprite would go directly to the mouse, whatever angle it is.
Here is my code.
LOAD IMAGE "player.bmp",1 `<----YOULL NEED A IMAGE FOR HERE
playerx = 600
playery = 350
sprite 1, playerx,playery,1
Do
if mouseclick() = 1
if playerx+16 < mousex()
playerx = playerx + 2
sprite 1, playerx,playery,1
endif
if playerx+16 > mousex()
playerx = playerx - 2
sprite 1, playerx,playery,1
endif
if playery+16 < mousey()
playery = playery + 2
sprite 1, playerx,playery,1
endif
if playery+16 > mousey()
playery = playery - 2
sprite 1, playerx,playery,1
endif
endif
loop
Sorry that it's a little messy, I'm just testing out possibilities.
Any suggestions would be ideal. I'm making a really basic top-down RPG. Oh, and I'm using DarkBASIC PRO.
(I had a quick scan of a few pages on the forum and couldnt see anything that helped, so I'd appreciate any ideas or thoughts)
Thanks
-Will