forums

TNT Basic Forums > Programming Q&A
Moving with mouse
< Last Thread     Next Thread >
Author
Thread        Post A Reply

11-13-2003 05:22

Posted by:
fjerkon

Location:
Sweden

Find more posts by fjerkon

is there a simple way to move a sprite with the mouse??

11-13-2003 08:09

Posted by:
Miles

Location:
Australia

Click Here to Email Miles   Find more posts by Miles

Yeah, just set the Sprite coordinates to Mouse X, Mouse Y.

Sprite n,Mouse X,Mouse Y,img

Of course, you might want to "Hide Mouse" first.

Or, alternatively, you could make the sprite head towards the mouse's coordinates. That would probably be better for most games.

11-13-2003 12:38

Posted by:
-wyvern

Location:
Bedroom

Find more posts by -wyvern

Another idea is to have a set of oldx and oldy variables for the mouse. You could then calculate how far the mouse moved and apply it's acceleration to an object. This would mean (if it worked) that the object would move in the same direction as the mouse, but at limited speed. If you ever played the ancient "oxyd" game, the marble moved in a similar fashion to what I have described. Perhaps if I am feeling bored I will write an example.

11-13-2003 13:04

Posted by:
Miles

Location:
Australia

Click Here to Email Miles   Find more posts by Miles

Wouldn't that work until the mouse reached the bounds of the screen, whereapon it's x and y values could no longer be moved in that direction?

11-13-2003 13:05

Posted by:
Miles

Location:
Australia

Click Here to Email Miles   Find more posts by Miles

Hmmm... a command which could set the mouse position would be useful for that.

11-13-2003 17:12

Posted by:
mark_667

Location:
England

Click Here to Email mark_667   Find more posts by mark_667

This has been suggested before, see:
http://www.tntbasic.com/community/forums/showthread.php?threadid=495

11-14-2003 17:46

Posted by:
fjerkon

Location:
Sweden

Find more posts by fjerkon

thanks!! is there a simle way to make the sprite follow the mous at a predefined speed?

11-14-2003 23:33

Posted by:
eekaydee

Location:
CA, USA

Click Here to Email eekaydee   Find more posts by eekaydee

Sure. Once you have the current coordinates and the destination coordinates, you can find the angle of travel and measure it to your defined distance. Then just move to that place.

All times are GMT        Post A Reply

Forum Jump:
< Last Thread     Next Thread >

< Contact Us - TNT Basic >

Powered by: vBulletin Lite Version 1.0.1 Lite
Copyright © Jelsoft Enterprises Limited 2000.