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


What is wrong with my logic

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
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
Well, it''s relative by default... To set the mode, though, you''d use IDirectInputDevice8::SetProperty(DIPROP_AXISMODE, &propHdr) where propHdr is an instance of DIPROPHEADER.

DirectInput Device Properties

You can call IDirectInputDevice8::GetProperty(DIPROP_AXISMODE, &propHdr) to verify the mode.

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