Help - Search - Members - Calendar
Full Version: Mouse Speedometer!
Game Maker Community > Games > Game Maker Creations > Tools & Applications
Recreate
This little program shows how fast your mouse is traveling on your screen, If anyone wants the source then ask.
It "Smooths" the speed for the speedometer, And sometimes may not be too accurate.
It records in Pixels Per Step, I have no clue how to convert it to MPH or feet per second or anything else, If you do, Please let me know.
So far it only records x speed and y speed, Velocity, I may later chunk it together into just speed, If i can figure out how. tongue.gif
GM version:7
Works in vista: I'll be darned if it does not.
Pro: Yes
Screenshot:
Download: mouse_speedmeter.exe
Enjoy!
I am open to suggestions, Ideas, Whatever.
Thanks
~ReCreate
JesseG88
Speed in the x direction and speed in the y direction are technically called velocity.

To get the actual speed, take sqrt((velX^2)+(velY^2)), or square root of the quantity (velX squared plus velY squared).
Recreate
Well, Yes thanks, I'll implement that now.
Edit: Just testing:
D1g1talAli3n
QUOTE (JesseG88 @ Nov 2 2009, 07:58 PM) *
Speed in the x direction and speed in the y direction are technically called velocity.

To get the actual speed, take sqrt((velX^2)+(velY^2)), or square root of the quantity (velX squared plus velY squared).


Correct me if I'm wrong but, that's very much like the point_distance() function. You could just make an object follow the mouse in the step event, and calculate the speed by using point_distance(xprevious,yprevious,x,y)
Obj_Control
Create:
CODE
mxl=display_mouse_get_x();
myl=display_mouse_get_y();


Draw:
CODE
SpeedOfMouse = point_distance( mxl , myl , display_mouse_get_x() , display_mouse_get_y() );

mxl=display_mouse_get_x();
myl=display_mouse_get_y();
Schyler
Being able to get the relative resolution of the screen would be interesting (1028p, 2048p etc). It would mean that it could actually be possible to convert to mps/cps. I think it would be possible via a DLL.
IceMetalPunk
Getting something like "1028p" would only tell you how many lines of pixels are used. To convert to actual length units (meters, centimeters, inches, feet, whatever) you'd need to know the physical size of the user's screen. This is, AFAIK, impossible to get, as it's a hardware property that cannot be accessed via software. Someone correct me if I'm wrong, though.

-IMP wink1.gif smile.gif
Shadow Link
QUOTE (IceMetalPunk @ Nov 9 2009, 08:53 PM) *
Someone correct me if I'm wrong, though.


Surely smile.gif

I've been meaning to post this, but kept losing interest. Actually, it's pretty simple, but I won't dive too far into it. (Ok, so I kind of did...)

Depending on your monitor's real-world size, and your resolution, a pixel will be a different size, so you'll have to keep that in mind. There should be a simple way to figure out pixels-per-inch. MS Paint has it right on the Edit > Attributes (Ctrl E) dialog. My laptop's PPI is 102 on a 1280 x 800 monitor (13 inch?). As you can imagine, my monitor being displayed in a movie theater projector would make a pixel the size of a thumb, or something. An easier way to think about this would be imagining a 1 x 1 pixel monitor. On a 13 inch monitor a pixel would be... well, 13 inches. A 17-inch monitor would be 17 inches, etc.

Once you have the PPI, you can convert to miles. We'll use my stats for now:

PPI = 102
1 foot = 12 inches (1224 pixels)
1 mile = 5280 feet, 63,360 inches (6,462,720 pixels)

If I moved my mouse across the whole screen perfectly in one step, it would be 1280 / 102 = 12.55 inches (the 13-inch monitor size includes the side panels). We're going to floor that to make it easier and clean (but we wouldn't do it in a program like this since doing that would make it inaccurate), so we moved the mouse about 1 foot per step. Since a step is 1/room_speed, a room with room_speed at 30 and at 30 fps would make a step 1/30th of a second. So we just say we moved the mouse 30 feet per second. 30 * 60 = 1800 feet per minute, and 1800 * 60 = 108,000 feet per hour. 108,000 feet per hour / 5280 feet = 20.45 MPH.

The only changing factor are the PPI displayed on your monitor. Hope this cleared things up a bit.
This is a "lo-fi" version of our main content. To view the full version with more information, formatting and images, please click here.
Invision Power Board © 2001-2009 Invision Power Services, Inc.