Microsoft DirectX 8.1 (Visual Basic)

Memory

Memory is a simple game in which you match tiles and try to score the most points.

Path

Source: (SDK root)\Samples\Multimedia\VBSamples\DirectPlay\Memory

Executable: (SDK root)\Samples\Multimedia\VBSamples\DirectPlay\Bin

User's Guide

Double-click the Memory icon to start the game. The application opens a small window and you can choose Multiplayer or Solitaire. When the Memory board opens, begin selecting tiles and try to match the images. Score one point for every match. In multiplayer mode, try to get more matches than your opponent(s). In solitaire mode, try to clear the board in as few attempts as possible.

Programming Notes

The Memory sample is very similar in form to the SimplePeer sample. For more information, see the Programming Notes section of the SimplePeer sample.

When a tile is clicked, the application will take the following steps.

  1. If it's the local player's turn, show the picture.
  2. Fill out a byte array telling everyone else to show the picture.
  3. Call DirectPlay8Peer.SendTo with the buffer() parameter set to the byte array. It also passes the DPNID_ALL_PLAYERS_GROUP flag in the idSend parameter so that this message goes to everyone.

When the Memory sample receives the DPNMSG_RECEIVE message, the DirectPlay8Event_Recieve function:

The application will the process the following message types.

MSG_SETUPBOARD Retrieve board information and update the local state.
MSG_SHOWPIECE Show the image behind the indicated tile.
MSG_HIDEPIECES Hide all tiles that aren't currently matched.
MSG_TURNEND Advance to the next players turn.
MSG_CHAT Receive a text string and update the user interface (UI).
MSG_MATCHED Set the state so these two pictures are marked as matched.
See the DirectPlay8Event interfaces in the source code for more messages that the Memory sample handles.