Archived

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

What is wrong with my logic

This topic is 5012 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
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()
{
DIMOUSESTATE MouseState;
if(pMouse != NULL)
pMouse->GetDeviceState(sizeof(DIMOUSESTATE),(LPVOID) &MouseState);

return MouseState;
}

How can I fix my code to accept relative data?
thanks

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.

IDirectInputDevice9::SetProperty
DirectInput Device Properties
DIPROPHEADER structure

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:
long MouseXPos=SCREEN_CENTER_X , MouseYPos=0= SCREEN_CENTER_Y;
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