Sorry your browser is not supported!

You are using an outdated browser that does not support modern web technologies, in order to use this site please update to a new browser.

Browsers supported include Chrome, FireFox, Safari, Opera, Internet Explorer 10+ or Microsoft Edge.

2D All the way! / mouse stuff.

Author
Message
JonyBasic
18
Years of Service
User Offline
Joined: 23rd Feb 2007
Location:
Posted: 23rd Feb 2007 07:15
greetings all, I'm new to this forum, but I've been a 2D game developer for over 5 years now.
I generally work in BASIC (of all kinds)
but I decided to try a game in GameMaker, so I hope some one has experience in the gamemaker language. (It's similar to C++)
At the moment, the game maker forums are down. crappy timing eh?
And let me tell you, the things that are easy, are easy.
But the things that are more difficult, are impossible.
So here's what I need help with.
I'm making a simple "follow the mouse" routine for a space ship.
The ship follows the position of the mouse until it
reaches mouse X,Y.
Once it reaches the position of the mouse, it starts freaking out
because it constantly switches directions as it's trying to get exactly on the mouse's X,Y.
I told it to only change direction if

object.x <> mouse_x
object.y <> mouse_y

but it's still stupid, I ran in debug to check the problem, and it seems my object's x and y are double precision. :/
so they are ALWAYS <> mouse

so...

floor(object.x) <> mouse_x
floor(object.y) <> mouse_y

should work right?
doesn't. same crap.

that's my problem. anyone think they got a better way?

Watch out, I'm the best there is. That means you too
Dark Dread.
MonoCoder
19
Years of Service
User Offline
Joined: 4th Dec 2005
Location: england
Posted: 24th Feb 2007 00:04 Edited at: 24th Feb 2007 00:04
Why not check to see if the object's position is within so many units of the mouse, then snap it to place?


Uber Tails fan. monocoder.spaces.live.com http://MonoCoder.bebo.com
Van B
Moderator
22
Years of Service
User Offline
Joined: 8th Oct 2002
Location: Sunnyvale
Posted: 24th Feb 2007 00:33
Convert the object positions to an integer then check that?


Good guy, Good guy, Wan...

Login to post a reply

Server time is: 2025-05-14 12:43:10
Your offset time is: 2025-05-14 12:43:10