Board game samples

Started by
2 comments, last by -Moxie- 21 years, 6 months ago
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.
Advertisement
Anyone? How about a simple sample iso/rts engine that supports using the mouse to select units. Does anyone have such a code sample?

[edited by - -Moxie- on September 25, 2002 9:07:38 PM]
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


------------------http://www.nentari.com
If I recall correctly, there is also a "pick" sample in the DirectX SDK samples. It will contain code for doing 3D ''collision detection'' between your mouse and 3D objects in a scene, is my guess.

This topic is closed to new replies.

Advertisement