This sample simulates a desktop football game, using the TImage class to perform drawing on the window client area.
You can find the Football sample project at:
- Start > Programs > Embarcadero RAD Studio > Samples and then navigate to Delphi\VCL\Football
- Subversion Repository for Delphi: http://sourceforge.net/p/radstudiodemos/code/HEAD/tree/branches/RadStudio_XE4/Delphi/VCL/Football/
This application consists of a football game. The user controls the running back. There are two difficulty levels: PRO1 and PRO2. PRO2 is for more advanced levels and the tacklers move quicker than in PRO1 level.
For more information on the gameplay, select Help > About from the main menu of the application.
How to Use the Sample
- Navigate to Start > Programs > Embarcadero RAD Studio > Samples and open Football.dproj.
- Press F9 or choose Run > Run.
The form displayed when the user chooses Help > About.
The form for the game itself.
- TAboutForm represents the class for the about form. It contains a TMemo object to display the gameplay instructions.
- TMainForm is the class for the game form. It contains multiple TImage objects to display the field and the controls. To display the score, the statistics, and the players (the running back controlled by the users and the tacklers controlled by the computer), simple TLabels are used.
- Two TTimer components are used: one for displaying the time on the form (Clock) and the other for simulating the play of the computer (Timer).
- sndPlaySound from the MMSystem unit is used to play a sound.
- The spot record is used to handle an item in the field. Each spot is empty if no player exists in that place, or contains a red underscore otherwise. It also stores a Boolean value that indicates whether that player is a running back or not. The field is a two-dimensional array of spots.
- The Timer.OnTimer event handler is used to randomly move a tackler in the field. The Clock.OnTimer event handler is used to change the time displayed on the form.