Archived

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

Board game samples

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

This isn''t exactly iso but I''m looking for code samples of simple board games written using Direct3D. Top down games like chess or checkers. Especially those that use the mouse to click, highlight and move a game piece. Thanks.

Share this post


Link to post
Share on other sites
Awhile ago I wrote a Connect 4esque program. I had to handle mouse selections.

I don''t know much about Direct3D, but I''ll assume that you still get all of the regular windows messages.

I''m not sure if this will help you but:

Every time something happens you''ll get a message from windows. In the case of a mouse click you''ll get WM_LBUTTONDOWN. The event data will include the mouse coordinates.

Check to see if these coordinates are on top of on of your ''items''. In a board game, this is usually really easy because the ''board'' is broken up in to logical regions.

This mouse down will ''SELECT'' the selection, but not activate it. To demonstrate this, move the mouse over a button in your web browser, then hold the mouse button down. The button becomes depressed, but no action is taken.

So you remember what item was selected, and then wait for a WM_LBUTTONUP event. Check the coordinates from the message, and if they''re in the same object as the WM_LBUTTONDOWN event, you assume the user wants to activate the control. This could mean anything, depending on your program.

You can probably find tons of code out there that uses this model.

Hope this helped.

Will


Share this post


Link to post
Share on other sites