home *** CD-ROM | disk | FTP | other *** search
Text File | 1996-06-03 | 5.7 KB | 165 lines | [TEXT/PJMM] |
- {****************************************************}
- {}
- { GameIntf.p }
- {}
- { Interface file for the classes which optimize event processing for games. }
- { These classes are based on the concept of a "Game Director", which when }
- { playing the game, becomes the gopher and handles all user control events. }
- { In the Dawdle method of this director, animation calls are made etc. }
- {}
- { For a real game, you may want to override the Game Switchboard further, }
- { so that mouse clicks, instead of being dispatched to pull down menus etc., }
- { are sent to the gopher as triggers for the ships laser guns (say). }
- {}
- { Game Classes }
- { Copyright © 1996 by Patrick C Hew. All rights reserved. }
- {}
- { THINK Class Library }
- { Copyright © 1989 by Symantec Corporation. All rights reserved. }
- {}
- { Revision History: }
- {}
- { Version: 1.00 for TCL 1.1.2 }
- { Date: 02 June 1996 }
- { Author: Patrick C Hew <phew@ucc.gu.uwa.edu.au> }
- { Notes: Initial release - CFastApp and CFastSwitchboard . }
- {}
- {****************************************************}
-
-
- unit GameIntf;
-
- interface
-
- uses
- TCL;
-
- {****************************************************}
- {}
- { CGameApp }
- {}
- { Application class, optimized to the needs of gameplay. }
- {}
- {****************************************************}
-
- type
- CGameApp = object(CApplication)
-
- { Flag for whether we are in game mode or not. }
- isInGameMode: Boolean;
-
- { Flag for whether to give time to background events during game mode. }
- isBkgdFriendlyInGameMode: Boolean;
-
- { Private pointer to the switchboard. }
- itsGameSwitchboard: CGameSwitchboard;
-
- { Initializes a Game Application object. }
- procedure IGameApp (extraMasters: Integer;
- aRainyDayFund: Longint;
- aCriticalBalance: Longint;
- aToolboxBalance: Longint);
-
- { Creates the single Game Switchboard object used by the application. }
- { We store a pointer for our own use. }
- procedure MakeSwitchboard;
- override;
-
- { It is expected that there is a Game Director, handling game animation etc. }
- { in its Dawdle method. This method streamlines the call during gameplay. }
- { It is assumed that during gameplay, the following hold :- }
- { 1 There are no memory emergencies to correct, so the Rainy Day memory }
- { fund does not need to be reset. It will, in any case, be reset when we }
- { leave game mode. }
- { 2 The Game Director is the gopher. }
- { 3 Only the Game Director needs to receive a Dawdle method. Reasonable, }
- { unless you have a special director reporting to the Game Director; for }
- { instance, a window set up for controls. In such a case, you may want }
- { to make the gopher send a Dawdle message to its supervisor. }
- { 4 There are no other Dawdle chores to perform. }
- procedure Idle (macEvent: EventRecord);
- override;
-
- { Streamlined processing of events during gameplay. }
- { It is assumed that during gameplay, the following hold :- }
- { 1 The desktop does not need to be cleaned up. This holds if there are no }
- { floating windows. }
- { 2 There are no urgent chores to be performed. }
- { 3 There is no switching to or from desk accessories. }
- procedure Process1Event;
- override;
-
- { Turn off game mode before quitting. }
- procedure DoCommand (theCommand: LongInt);
- override;
-
- { Return whether or not we are in game mode. }
- function GetInGameMode: Boolean;
-
- { Configure for fast event processing. }
- procedure BeginGameMode;
-
- { Return to normal event processing. }
- procedure EndGameMode;
-
- { Get the state of background friendliness in game mode. }
- function GetBkgdFriendlyInGameMode: Boolean;
-
- { Set the background friendliness in game mode. }
- procedure SetBkgdFriendlyInGameMode (aBkgdFriendlyInGameMode: Boolean);
-
- end; { CGameApp }
-
-
- {****************************************************}
- {}
- { CGameSwitchboard }
- {}
- { Switchboard class, optimized to the needs of gameplay. }
- {}
- { For a real game, you may want to override the Game Switchboard further, }
- { so that mouse clicks, instead of being dispatched to pull down menus etc., }
- { are sent to the gopher as triggers for the ships laser guns (say). }
- {}
- {****************************************************}
-
- type
- CGameSwitchboard = object(CSwitchboard)
-
- { Flag for whether we are in game mode or not. }
- { This flag should always synchronize with that in the CGameApp. }
- { It is stored locally for speed. }
- isInGameMode: Boolean;
-
- { Flag for whether to give time to background events. }
- isBackgroundFriendly: Boolean;
-
- { Initialize a Game Switchboard object. }
- procedure IGameSwitchboard;
-
- { Set the game mode. }
- procedure SetInGameMode (aInGameMode: Boolean);
-
- { Get the current background friendliness. }
- function GetBackgroundFriendly: Boolean;
-
- { Set the background friendliness. }
- procedure SetBackgroundFriendly (aBackgroundFriendly: Boolean);
-
- { Gets an event, subject to background friendliness. }
- function GetAnEvent (var macEvent: EventRecord): Boolean;
- override;
-
- { Process event, subject to the requirement that a Dawdle message be }
- { sent to the Game Director on each iteration of the event loop. }
- { It is assumed that during game play, the Game Director has sole }
- { control the appearance of the mouse; that is, the automatic configuring }
- { of the mouse by TCL can be omitted. }
- procedure ProcessEvent;
- override;
-
- end; { CGameSwitchboard }
-
- implementation
-
- end. { GameIntf }