Archived

This topic is now archived and is closed to further replies.

Goodlife

Getting better mouse granularity

Recommended Posts

Hi all, I was wondering if there were any DirectInput jocks out there. Here''s my situation: I am writing a game where you move the main character around with the mouse. Essentially, the main character looks at the amount of motion the mouse has made since the last call, and moves in that direction, capping it if the motion is too large. Now, here''s why I need help: When you move the mouse only a SMALL amount, the mouse jumps one pixel. That means, if you move the mouse straight up, and then move diagonally, you originally have a mouse motion of (0,-1) that suddenly switches to (1,-1). This makes my character, who was rotated at 0 degrees (pointing straight up) suddenly rotate to 45 degrees (pointing upper right). Because of this coarseness of mouse motion, if you move the mouse slowly, to try to aim your character nicely, you end up jumping 45 degrees (or some other large number). So: Is there any way to track smaller mouse movement than 1 pixel? Is there a way in DirectX to grab mickeys or something like that? I''m looking to record mouse motions like (1,.25) or (.3,10) so that my character always points in the right direction. Thanks in advance! Goodlife

Share this post


Link to post
Share on other sites
i''m not useing direct input, i''m actualy useing windows calls to implement the mouse in my game

  
POINT point; // Pont struct for mouseing (Cheap way)


// Get the mouses position (Cheap way)

GetCursorPos(&point);

// Mouse turning (Cheap way)

yrot += float(point.x-320) / 5.0f; // -320 because mouse is in

// the middle of the 640x480 screen.


// keep rotation within 360 degrees

if (yrot > 360)
yrot -= 360;
if (yrot < 0)
yrot += 360;

// Mouse look (Cheap way)

xrot += float(point.y-240) / 5.0f; //cast the point to a float so i can

//get partial results (less that one pixel)


// keep look within 90 degrees

if (xrot > 90)
xrot = 90;

// keep look within 90 degrees

if (xrot < -90)
xrot = -90;

// Restet mouse to center of screem (Cheap way)

SetCursorPos (320,240);


well, i hope that helps a little

-------------------------------------------------
Don''t take life too seriously, you''''ll never get out of it alive. -Bugs Bunny

Share this post


Link to post
Share on other sites