The Daily Click ::. Forums ::. Klik Coding Help ::. Speed and Angle for the Movement of the Mouse
 

Post Reply  Post Oekaki 
 

Posted By Message

MBK



Registered
  07/06/2007
Points
  1578

VIP Member
24th April, 2010 at 06:28:39 -

As the title says, mouse speed and mouse angle, how might one go about acquiring that data, recording it, and pacing it into counter or variable form?


 
Click Me! http://www.create-games.com/project.asp?view=main&id=1444

http://www.mediafire.com/download.php?aoo1dnnlq5i

Blood of the Ancient One, Seen only as Shadow, Faster than Lightning, Fierce as the Greatest Dragon, Nearly Invisible, Floating in a Dream, Entered through the Demon Door, Destroyer of Evil in a Realm with a Red Sky Scarred, Who could I be ?

aphant



Registered
  18/05/2008
Points
  1242
24th April, 2010 at 08:21:05 -

Well, at any given time the mouse is at exactly one point on the screen. To record speed or angle, you have to record the movement between two frames. You'll need 4 alterable variables for this: oldX, oldY, currentX, currentY

To calculate the speed, just calculate the distance between old and current. Distance/time should give you the speed; Remember, the time would be one frame, so 1/50 (if your framerate is 50).

To calculate the angle, I believe you'll need to construct the three lines A, B, and C: A is oldX,oldY to oldX,currentY; B is oldX,currentY to currentX,currentY; C is oldX,oldY to currentX, currentY. You should be able to find the angle of movement (which would be along line C) by calculating the cosine of (line A)/(line C).

Edit: That angle method isn't correct.

Edited by aphant

 

Solgryn

Solgryn dot org

Registered
  20/12/2008
Points
  12572

GOTW Winner!VIP MemberWii OwnerIt's-a me, Mario!The Cake is a LieGOTM 2ND PLACE! - APRIL 2009GOTM 2ND PLACE - JUNE 2009PS3 OwnerKlikCast #15 Compo Winner!LOL Sign
You've Been Circy'd!GOTM WINNER - JANUARY 2010I am an April FoolGOTW MARCH 2010 WINNER!Santa Hat
24th April, 2010 at 10:17:33 -

Made an example here:

http://www.solgryn.org/Stuff/Random/MouseAnglSpd.zip

=D Hope it's useful !

 
www.Solgryn.org

Image

MBK



Registered
  07/06/2007
Points
  1578

VIP Member
27th April, 2010 at 00:25:13 -

Is this really an example for angle or does it use directions?
It seems to be just as twitchy as my TGF1 directional version is, cept I did mine with extra actives instead of extra math.
Maybe it's twitchy because it's too accurate ... Is there a way to make its angle gradually change to that of the mouse's angle instead of instantaneously?


 
Click Me! http://www.create-games.com/project.asp?view=main&id=1444

http://www.mediafire.com/download.php?aoo1dnnlq5i

Blood of the Ancient One, Seen only as Shadow, Faster than Lightning, Fierce as the Greatest Dragon, Nearly Invisible, Floating in a Dream, Entered through the Demon Door, Destroyer of Evil in a Realm with a Red Sky Scarred, Who could I be ?

Solgryn

Solgryn dot org

Registered
  20/12/2008
Points
  12572

GOTW Winner!VIP MemberWii OwnerIt's-a me, Mario!The Cake is a LieGOTM 2ND PLACE! - APRIL 2009GOTM 2ND PLACE - JUNE 2009PS3 OwnerKlikCast #15 Compo Winner!LOL Sign
You've Been Circy'd!GOTM WINNER - JANUARY 2010I am an April FoolGOTW MARCH 2010 WINNER!Santa Hat
27th April, 2010 at 17:17:59 -


Originally Posted by MBK
Is this really an example for angle or does it use directions?
It seems to be just as twitchy as my TGF1 directional version is, cept I did mine with extra actives instead of extra math.
Maybe it's twitchy because it's too accurate ... Is there a way to make its angle gradually change to that of the mouse's angle instead of instantaneously?



that one is angle, you could also make the object move towards (instead of instant) the mouse to make it less twitchy

Edited by Solgryn

 
www.Solgryn.org

Image

MBK



Registered
  07/06/2007
Points
  1578

VIP Member
28th April, 2010 at 04:53:58 -

Ok, thanks Solgryn.
I have much less time now than I previously did, so I'll have to give up on TGF1 for the time being and just learn to cope with the slight interface differences of MMF2 right now. Don't think this is me giving up though, I'll return to TGF1 after making something usable in MMF2. I'm going to work backwards from now on so maybe things will click quicker soon.
This is a good example and many others have shown me lots that can be easily done in MMF2 and not in TGF1.

So, as of this moment, I'm going to switch gears and use MMF2 first, and if I succeed with it, then I'll see if I can make the same thing in TGF1 to satisfy my stubborn obsession at a later time.

I bet you guys thought I'd never begin using MMF2 as my main program.
It seems like I'm one of the last ones if not the last who was using it as his main game creation device.


 
Click Me! http://www.create-games.com/project.asp?view=main&id=1444

http://www.mediafire.com/download.php?aoo1dnnlq5i

Blood of the Ancient One, Seen only as Shadow, Faster than Lightning, Fierce as the Greatest Dragon, Nearly Invisible, Floating in a Dream, Entered through the Demon Door, Destroyer of Evil in a Realm with a Red Sky Scarred, Who could I be ?

Solgryn

Solgryn dot org

Registered
  20/12/2008
Points
  12572

GOTW Winner!VIP MemberWii OwnerIt's-a me, Mario!The Cake is a LieGOTM 2ND PLACE! - APRIL 2009GOTM 2ND PLACE - JUNE 2009PS3 OwnerKlikCast #15 Compo Winner!LOL Sign
You've Been Circy'd!GOTM WINNER - JANUARY 2010I am an April FoolGOTW MARCH 2010 WINNER!Santa Hat
28th April, 2010 at 07:50:34 -


Originally Posted by MBK
Ok, thanks Solgryn.
I have much less time now than I previously did, so I'll have to give up on TGF1 for the time being and just learn to cope with the slight interface differences of MMF2 right now. Don't think this is me giving up though, I'll return to TGF1 after making something usable in MMF2. I'm going to work backwards from now on so maybe things will click quicker soon.
This is a good example and many others have shown me lots that can be easily done in MMF2 and not in TGF1.

So, as of this moment, I'm going to switch gears and use MMF2 first, and if I succeed with it, then I'll see if I can make the same thing in TGF1 to satisfy my stubborn obsession at a later time.

I bet you guys thought I'd never begin using MMF2 as my main program.
It seems like I'm one of the last ones if not the last who was using it as his main game creation device.



OMG Finally =D! Well, it took me some time to switch but I'm glad I did.

 
www.Solgryn.org

Image
   

Post Reply



 



Advertisement

Worth A Click