Class TGameControl (unit GameCtl)

Inherits from

TMultiChannelStateAware

Constructors


constructor Create;

Class constructor and destructor.


Functions

destructor Destroy;

Initialize other general state flags.

procedure DisplaySplashScreen;

Methods to tell the game to start it's idle cycle, or break it by beginning a new game.

procedure DrawFrame;

Method to draw a single "Frame".

procedure EraseFrame;

Perform collision detection just after a frame draw is completed.

procedure Move;

Object control methods.

procedure StartNewGame;

Start showing the game's splash screen.

procedure EnterState(iChannel: Integer; pstCurrent: PState);

Virtual methods for customizing state behavior.

procedure ExitState(iChannel: Integer; pstCurrent: PState);

Establish default mappings for the game control object.

procedure ProcessMessage(iCategory, iType: Integer; bValue0: Boolean; fValue1, fValue2: Real);

Method to handle keyboard messages.

procedure CheckLevelProgression;

If there are Barts left then use one.

procedure CleanUpDeadObjects(var bAlienObjectKilled: Boolean);

This method releases memory used by all objects in the universe that are currently dead, and removes them from the master list.

procedure CreateCollisionLists;

Position the credits off the screen and let them scroll into view.

procedure CreateScoreBoard;

Other methods.

procedure DefineGameShapes;

Method to define common shapes used in the game.

procedure DisplayFloatingText(szTextString: String; iPosX, iPosY: Integer);

This method will create a floating, flashing piece of text.

procedure EnterPauseState;

Toggle the current game pause state.

procedure ExitPauseState;

Set the game pause state and erase the current contents of the screen.

procedure FreeObjects(iGroupID: Integer);

Method to release all objects in a given category.

procedure IncrementCursorPos(iAmount: Integer);

Perform cursor movement.

procedure InitializeBart;

Method to create a new Bart.

procedure MakeStars(iClientWidth, iClientHeight: Integer);

Methods for creating and painting on the starry backdrop.

function NewTextObject(szText: String; clrText: TColor; bFlashing: Boolean; iPosX, iPosY: Integer; fScale: Real; iGroupID: Integer): TTextObject;

Procedure to create text object and add it to the universe.

procedure PaintBackdrop;

Determine the position of the starry background.

procedure PerformCollisionDetection(listObjects: TList);

Collision detection methods.

procedure PerformCursorMovement(iAmount: Integer);

Construct the new string, padding it on the right with underscores.

procedure PerformLetterMovement(iAmount: Integer);

Position the first line of text.

procedure PopulateAsteroidField(iGroupID: Integer);

Method for forming the asteroid field.

procedure PrepareCredits;

This method prepares the text objects used in the credits screen.

procedure PrepareNameEntryText;

Finally, wait for asecond while asteroids are generated.

procedure ResetTagColors;

Methods for high score text entry.

procedure ReviveBart;

End the current state.

procedure SetGamePause(bPaused: Boolean);

Methods for controlling game pauses.

Properties

property bGameDead : Boolean


property bGamePaused : Boolean

Exposed properties.

Events

Variables

m_alstCollisionLists : Array [0 .. 1] of TList;

Collision lists for processing collision with godd and bad guys.

m_astarBackground : Array[0 .. STAR_COUNT] of TPoint;

Array of points where stars exist on the backdrop.

m_bAlienOnScreen : Boolean;

TRUE while the game is paused.

m_bEnteringName : Boolean;

Current input device, copied for convenience.

m_bGameDead : Boolean;

Currently active Bart object.

m_bGamePaused : Boolean;

Probablity that an alien will appear.

m_bPendingAsteroidCreation : Boolean;

TRUE while the user is entering a hi-score tag.

m_bScoreBoardShownLast : Boolean;

TRUE while we're generating an asteroid field.

m_fAlienProbability : Real;

Value of last level bonus given.

m_fLevelStartTime : Real;

TRUE while an alien is on the screen.

m_hslHighScores : THighScoreList;

Current score and number of lives.

m_iAliensOnLevel : Integer;

Current level number during game play.

m_iCharPos : Integer;

TRUE if hi-scores were shown last (not credits).

m_iCurrentLevel : Integer;

TRUE if the game object has one full-cycle.

m_iLevelBonus : Integer;

Number of aliens that have appeared on level.

m_inpPlayer : TWindowsKeyboard;

List of all objects in the universe.

m_iStateChannel1 : Integer;

Current hi-score value display.

m_iStateChannel2 : Integer;

Primary state channel ID.

m_lstUniverse : TList;

Time (in seconds) user started on level.

m_scrScoreBoard : TScoreBoard;

Internal game-control values.

m_szCurrentChar : Char;

Current "cursor" position while entering tag.

m_voBart : TBart;

Secondary state channel ID.

m_voHiScoreText : TTextObject;

Current high score list.

m_voTagChar : Array[0 .. 2] of TTextObject;

Character at current tag position.


Constructors


constructor Create;

Class constructor and destructor.

Objects allocated during a level of the game. } { Bonus amount for shooting the alien ship.


Functions


destructor Destroy;

Initialize other general state flags.


procedure DisplaySplashScreen;

Methods to tell the game to start it's idle cycle, or break it by beginning a new game.

Define the shape of an attacking alien spaceship.


procedure DrawFrame;

Method to draw a single "Frame".

Check if it's time to move to another level.


procedure EraseFrame;

Perform collision detection just after a frame draw is completed.


procedure Move;

Object control methods.

Release the object, and remove it from the universal list.


procedure StartNewGame;

Start showing the game's splash screen.


procedure EnterState(iChannel: Integer; pstCurrent: PState);

Virtual methods for customizing state behavior.

If there are no more enemy objects then progress } { to the next level.


procedure ExitState(iChannel: Integer; pstCurrent: PState);

Establish default mappings for the game control object.


procedure ProcessMessage(iCategory, iType: Integer; bValue0: Boolean; fValue1, fValue2: Real);

Method to handle keyboard messages.

Clear out the current event queue, and add a BeginGame command.


procedure CheckLevelProgression;

If there are Barts left then use one. Otherwise, the game is over!


procedure CleanUpDeadObjects(var bAlienObjectKilled: Boolean);

This method releases memory used by all objects in the universe that are currently dead, and removes them from the master list.

Create the scoreboard object.


procedure CreateCollisionLists;

Position the credits off the screen and let them scroll into view.


procedure CreateScoreBoard;

Other methods.

Put Bart right in the middle of screen.


procedure DefineGameShapes;

Method to define common shapes used in the game.

Free pause-state items, and then resume normal object processing.


procedure DisplayFloatingText(szTextString: String; iPosX, iPosY: Integer);

This method will create a floating, flashing piece of text. This is used for displaying bonus values when the player shoots an alien.

Kill objects that (1) aren't dead, and (2) match the given control } { group ID.


procedure EnterPauseState;

Toggle the current game pause state.


procedure ExitPauseState;

Set the game pause state and erase the current contents of the screen.


procedure FreeObjects(iGroupID: Integer);

Method to release all objects in a given category. This is most useful when transitioning to a new screen, such as credits.

Add the new text object to the object list.


procedure IncrementCursorPos(iAmount: Integer);

Perform cursor movement.


procedure InitializeBart;

Method to create a new Bart.

Draw a pixel for each star.


procedure MakeStars(iClientWidth, iClientHeight: Integer);

Methods for creating and painting on the starry backdrop.

We're no longer waiting for the asteroid belt to be created.


function NewTextObject(szText: String; clrText: TColor; bFlashing: Boolean; iPosX, iPosY: Integer; fScale: Real; iGroupID: Integer): TTextObject;

Procedure to create text object and add it to the universe. Calling this method is more convenient that creating text explicitly.

Put the object into the appropriate list.


procedure PaintBackdrop;

Determine the position of the starry background.


procedure PerformCollisionDetection(listObjects: TList);

Collision detection methods.

Erase each object currently in the universe.


procedure PerformCursorMovement(iAmount: Integer);

Construct the new string, padding it on the right with underscores.


procedure PerformLetterMovement(iAmount: Integer);

Position the first line of text.


procedure PopulateAsteroidField(iGroupID: Integer);

Method for forming the asteroid field.

Perform default cleanup.


procedure PrepareCredits;

This method prepares the text objects used in the credits screen.


procedure PrepareNameEntryText;

Finally, wait for asecond while asteroids are generated.


procedure ResetTagColors;

Methods for high score text entry.

Stash the current letter in the position we're moving off of..


procedure ReviveBart;

End the current state.


procedure SetGamePause(bPaused: Boolean);

Methods for controlling game pauses.

Take down text amount after a while.


Properties


property bGameDead : Boolean


property bGamePaused : Boolean

Exposed properties.


Events


Variables


m_alstCollisionLists : Array [0 .. 1] of TList;

Collision lists for processing collision with godd and bad guys. Alien objects (including asteroids) go in one list, while Bart-friendly ones go in the other.


m_astarBackground : Array[0 .. STAR_COUNT] of TPoint;

Array of points where stars exist on the backdrop.


m_bAlienOnScreen : Boolean;

TRUE while the game is paused.


m_bEnteringName : Boolean;

Current input device, copied for convenience. } { Game state variables.


m_bGameDead : Boolean;

Currently active Bart object.


m_bGamePaused : Boolean;

Probablity that an alien will appear.


m_bPendingAsteroidCreation : Boolean;

TRUE while the user is entering a hi-score tag.


m_bScoreBoardShownLast : Boolean;

TRUE while we're generating an asteroid field.


m_fAlienProbability : Real;

Value of last level bonus given.


m_fLevelStartTime : Real;

TRUE while an alien is on the screen.


m_hslHighScores : THighScoreList;

Current score and number of lives.


m_iAliensOnLevel : Integer;

Current level number during game play.


m_iCharPos : Integer;

TRUE if hi-scores were shown last (not credits).


m_iCurrentLevel : Integer;

TRUE if the game object has one full-cycle.


m_iLevelBonus : Integer;

Number of aliens that have appeared on level.


m_inpPlayer : TWindowsKeyboard;

List of all objects in the universe.


m_iStateChannel1 : Integer;

Current hi-score value display.


m_iStateChannel2 : Integer;

Primary state channel ID.


m_lstUniverse : TList;

Time (in seconds) user started on level.


m_scrScoreBoard : TScoreBoard;

Internal game-control values.


m_szCurrentChar : Char;

Current "cursor" position while entering tag.


m_voBart : TBart;

Secondary state channel ID.


m_voHiScoreText : TTextObject;

Current high score list.


m_voTagChar : Array[0 .. 2] of TTextObject;

Character at current tag position. } { High score name entry values.