Sign in to follow this  

direct3d and win32 mouse collision?

This topic is 3340 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 have some sprites displaying on screen, kept the default centre of top left corner of the sprite for positioning. directx uses getsrcrect() to ensure its keeping the same proportion as the window its displaying on. the positioning of the sprites is working fine and theyre not being stretched or skewed in any way, but collision detection with the mouseis decidedly dodgy some sprites detect fine, and all collisions on the x are fine, but the y can sometimes be a good half-height of the sprite above or below is this algorithm basically ok for it? if mouse.x >= xpos and mouse.x <= posx + width and mouse.y >= posy and mouse.y <= posy + height therell be no weird projections or anything skewing mouse input would there? this is being truly annoying i needs be ill have to start outputting debug text to the screen of mouse coords

Share this post


Link to post
Share on other sites
Looks fine, but I bet you're not using AdjustWindowRectEx to get the correct window size for your app.
The width and height you pass to CreateWindowEx are the width and height of the window - that includes the title bar, menu and borders. If you pass 800, 600 for those two parameters, you'll get a window that is 800x600, but a client area (Drawable area where DirectDraw / Direct3D render to) of maybe 792x564. That means that any rendering will be stretched from the backbuffer to the window, and will put all of your mouse coordinates out; since they're in window coordinates, not backbuffer coordinates.

Share this post


Link to post
Share on other sites
excellent, thanks very much! i was thinking the titlebar might be a factor. annoying im sure if you want a specific working-area but this is fine for me. ill rate you up if i can work the weird peripheral they relace mice and keyboards with here, if not ill do it when i get home

Share this post


Link to post
Share on other sites

This topic is 3340 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.

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this