Example: Tetris

The Tetris program is a Windows version of the popular puzzle game written in Delphi. It uses an initial 480x400 form size and a 240x200 virtual buffer. The virtual buffer contains the Tetris blocks and surrounding border. A timer component is defined that results in the virtual buffer contents being displayed in the middle of the form. The program also uses a header component to show the score, and a button component that allows you to pause the game.

After a row is filled with Tetris blocks, a little munching critter chomps the row from left to right, causing the blocks from above to fall down. This animation is achieved through double buffering using a second virtual buffer, just slightly larger than a row of blocks. This holds a clean copy of the blocks, so as the critters munch they can be moved without leaving remnants.

Because of space considerations, we will not present the Tetris source code here, but instead refer you to the on-line documentation in the Tetris.doc file (SETUP places this file in the Tetris subdirectory of the Fastgraph examples directory).

<< Prev

Next >>

Contents
Fastgraph Home Page

 

copyright 2001 Ted Gruber Software, Inc.