Jump to content
  • Advertisement


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


What is wrong with my logic

This topic is 5369 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 feel like a moron but I an getting some messed up results I read the mouse and then go thru my linked list of sprites and this linked list contains buttons sprites. What I want to have happen is if the mouse is within the sprite I want to change my source RECT. This seems like it should work but the buttons are changing instead at what seems radom places. here is the code MouseState = mDInput.ReadMouse(); MouseXPos += MouseState.lX; MouseYPos += MouseState.lY; sSprite* Ptr = mSprite->First; while(Ptr!=NULL){ if(MouseXPos >= Ptr-> location.x && MouseXPos <=(Ptr-> location.x + Ptr->width) && MouseYPos >= Ptr-> location.y && MouseYPos <=(Ptr->location.y + Ptr->height)) { Ptr->srcRect.left=200; Ptr->srcRect.right=400; } else{ Ptr->srcRect.left=0; Ptr->srcRect.right=200; } Ptr=Ptr->Next; } thanks I can''t check this until after work but anything you leave is greatly thanked -Dapeos

Share this post

Link to post
Share on other sites
Simple question: is your mouse data relative or absolute? If it''s absolute, it''s no wonder your actual location seems to be "random"; your code expects relative data.

Share this post

Link to post
Share on other sites
I am not sure if my mouse data is relative or absolute, how can I specify which type I want. Here is the code that fills my DIMOUSESTATE struct

DIMOUSESTATE cDInput::ReadMouse()
if(pMouse != NULL)
pMouse->GetDeviceState(sizeof(DIMOUSESTATE),(LPVOID) &MouseState);

return MouseState;

How can I fix my code to accept relative data?

Share this post

Link to post
Share on other sites
I want to use relative but I think I found the problem.
long MouseXPos=0, MouseYPos=0;
Shouldn''t this be set to where the mouse currently is when the program executes.
in Lamothe''s book he shows:
but the compiler yells at me even when I throw GetSystemMetrics() around it.
I am going crazy

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.

GameDev.net is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

Sign me up!