Game Sample

This sample application implements a simple Windows Forms game, complete with GDI+ graphics, timer features, user configuration, and high-score storage.

To get samples and instructions for installing them

  • Do one or more of the following:

    • On the Help menu, click Samples.

      The Readme displays information about samples.

    • Visit the Visual Studio 2008 Samples Web site. The most recent versions of samples are available there.

    • Locate samples on the computer on which Visual Studio is installed. By default, samples and a Readme file are installed in drive:\Program Files\Microsoft Visual Studio 9.0\Samples\lcid. For Express editions of Visual Studio, all samples are located online.

For more information, see Visual Studio Samples.

Security noteSecurity Note:

This sample code is intended to illustrate a concept, and it shows only the code that is relevant to that concept. It may not meet the security requirements for a specific environment, and it should not be used exactly as shown. We recommend that you add security and error-handling code to make your projects more secure and robust. Microsoft provides this sample code "AS IS" with no warranties.

To view the sample documentation

  1. In Solution Explorer, double-click the Documentation folder.

  2. If you are using Visual Basic Express, right-click ReadMe.htm in the Documentation folder. Select View in Browser.

  3. If you are using another version of Visual Basic, double-click ReadMe.htm in the Documentation folder.

Demonstrates

This sample demonstrates features that are implemented in most applications:

  • User options   The Options form enables users to reset the high scores and turn sound on and off.

  • **Help   **The application includes a compiled Help project. The compiled Help is accessed through the Help menu item.

  • Mouse   The mouse is used not only to play the game, but to drag the form around when the title bar is hidden.

  • Keyboard   The "M" key toggles the menu and title bar on and off. The "P" key pauses and restarts the game action.

Several Visual Basic and .NET Framework features are highlighted:

  • GDI+ graphics   The game action is implemented by using drawing functions from the System.Drawing namespace.

  • Registry   High scores are stored in the registry.

  • Object-oriented programming   The game action and drawing is controlled by several classes that act together. The main game classes are the Grid and Block classes. The PointTranslator class adds utility functions for drawing the blocks. The HighScores class handles retrieving and setting scores.

See Also

Reference

System.Drawing

My.Computer.Audio Object

My.Computer.Registry Object

HelpProvider

MouseDown

KeyDown