Jump to content
  • Advertisement
Sign in to follow this  
phil67rpg

mouse values

This topic is 1805 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

well I am using a mouse in a tic tac toe game, I am unsure of how the x and y values in this piece of code operate. 

LRESULT
 
 
CALLBACK WindowProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam)
{
 
 
int x=LOWORD(lParam);
 
 
int y=HIWORD(lParam);
 
 
 
switch(wParam)
{
 
 
case VK_ESCAPE:
{
PostQuitMessage(0);
 
 
return 0;
} 
 
break;
}
 
 
switch(message)
{
 
 
case WM_LBUTTONDOWN:
{
display_text_x(x,y);
 
 
return 0;
} 
 
break;
 
 
case WM_RBUTTONDOWN:
{
display_text_o(x,y);
 
 
return 0;
} 
 
break;
 
 
 
case WM_DESTROY:
{
PostQuitMessage(0);
 
 
return 0;
} 
 
break;
}
 
 
return DefWindowProc (hWnd, message, wParam, lParam);
}

 

do the values for x and y correspond to the tip of the mouse pointer?

 

Share this post


Link to post
Share on other sites
Advertisement

Yes, it is known as the "hotspot" for the mouse pointer (different cursors can have different hotspots, you can define a hotspot in x, y pixel offsets from the top left of a cursor if you make a new one).

 

The value is usually relative to the client window (the area not including the title bar, menu, etc.) top left as well if I recall correctly.

Share this post


Link to post
Share on other sites

well then there is something wrong with my code, for some reason when you click the mouse in one box it effects the adjacent box.let me know  if you need more code.

 
 
if(x>=300 && x <=350 && y>=225 && y <=275)
{
font_rect.left=310;
font_rect.top=235;
font_rect.right=330;
font_rect.bottom=255;
board_x[0][0]=
 
true;
}
 
 
if(x>=350 && x <=400 && y>=225 && y <=275)
{
font_rect.left=360;
font_rect.top=235;
font_rect.right=380;
font_rect.bottom=255;
board_x[0][1]=
 
true;
}

 

when I click on one spot near the edge of the line it draws an x or o in the adjacent spot.

Share this post


Link to post
Share on other sites

Trying that code shows you have more serious issues than your mouse. A proper render loop being one of which.

 

The pink/green flash also shows you don't know about the Direct3D Debug Runtime. I could go into more detail but I think most of the problems I see have been adressed already in older posts. Repeatedly.

 

And you have switched the graphics API. Again. *sigh*

 

I go with BearNutts: Use an easier framework. And maybe an easier language, too. (XNA, Löve, Pygame, take your pick).

Share this post


Link to post
Share on other sites

Well, then do get familiar with the debug runtimes (you have myriads of memory leaks and failing draw calls!) and learn to use PIX, the D3D debugger.

Edited by unbird

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • 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!