Jump to content
  • Advertisement

Archived

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

InsaneX

Simple Mouse Movement

This topic is 5304 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

I am an idiot. This must be expressly understood to answer my question with yelling at me. I am using glut to make pong. I want to get the mouse working, so I am trying to get the mouse to move a paddle. (for no real reason I made a block class, as in paddle)
void MouseMove(int x, int y)
{
 	CurrMousePos.x = x;
	CurrMousePos.y = y;
	
	ChangeMouse.x = CurrMousePos.x - PrevMousePos.x;
	ChangeMouse.y = CurrMousePos.y - PrevMousePos.y;
	
	PrevMousePos.x = CurrMousePos.x;
	PrevMousePos.y = CurrMousePos.y;
}
//ChangeMouse, CurrMousePos, and PrevMousePos are simple
//structs with two GLfloats x and y

//I call this each frame
block.UpdatePos(ChangeMouse.y);
//and after drawing the board I do this
glTranslatef(-10.5, CurrMousePos.y, 0.0f);

void CBlock::UpdatePos(GLfloat Mousey)
{
	position += Mousey;
	if(position > maxY)
		position = maxY;
	if(position < minY)
		position = minY;
} 
I know there will probably be a problem with the screen cords not working well with the GL coords (too much movement) but it doesnt move at all unless I resize the window, which makes me think that the problem is not with my movement detection code.

Share this post


Link to post
Share on other sites
Advertisement
have you tried dividing Mousey by, say, 1000? because your problem could be to do with


if(position > maxY)
position = maxY;
if(position < minY)
position = minY;

Share this post


Link to post
Share on other sites
I did try to do that, but I have the same problem. Moving my mouse around on the screen has no effect. Only sometimes when I move it on the title bar, or when I hit the maximize/minimize button will it move.

Share this post


Link to post
Share on other sites
[EDIT:Deleted answer, I did not read you used Glut and not Win32]

[edited by - Red Ghost on May 10, 2004 5:35:48 AM]

Share this post


Link to post
Share on other sites
Sounds like you are only getting mouse coordinates when you get a redraw call. Look at where your mouse gets updated.
-Greg

Share this post


Link to post
Share on other sites

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!