This is GameBrain.h in view mode; [Download] [Up]
/* Generated by Interface Builder */
// This handles a lot of the logic of the game; it has application delegate
// methods to deal with start up and shut down of the application. It also
// has some window delegate methods that work in conjunction with the game
// window (window with the playing field). It starts and stops the game,
// odes pausing, makes sure initialization is done properly, moves from
// level to level, and tracks the score along with various bonuses.
#import <objc/Object.h> // superclass
#import <objc/typedstream.h> // highscore tables
#import <appkit/Matrix.h> // matrix controls' methods
#import <appkit/Control.h> // various controls' methods
#import <appkit/Panel.h> // Alert Panels
#import <appkit/defaults.h> // preferences (defaults)
#import <appkit/Application.h> // application stuff
#import <appkit/TextField.h> // high score text fields
#import "GameView.h" // the brain's partner in crime
#import "HighScoreTable.h" // to handle high scores
@interface GameBrain:Object
{
id alert; // tells user to wait during load
id levelText; // textField on status window
id gameScreen; // gameView instance
id topScoreText; // high score textField on status window
id scoreText; // score textField on status window
id pauseMenuCell; // menuCell that pauses/unpauses game
id gameWindow; // window holding gameView
id highScoreTable; // object to handle High Scores
id preferencesBrain; // object to handle Preferences Panel
id infoController; // object to put out info/help panels
id soundPlayer; // the object handling the sounds
id loadingPanel; // to tell the user we're awake
id fruitBasket; // displays fruit for each level
id pacsLeft; // displays PacMen left
BOOL paused; // game is paused flag
BOOL ranOnce; // did the player at least play one game?
// instance variables to hold preferences and game status:
int score, level, viruses, speed, ghostCount, pointsToNextBonus, lastBonus;
}
- init; // designated initializer
- (int)level; // returns current play level
- (int)speed; // returns speed
- zeroScore;
- addToScore:(int)increment; // add an int to the score
- gameOver; // end the game & wrap it up, disp. "game over"
- (int)pause; // pause the game - internal method
- (int)paused; // are we paused?
- unpause; // unpause the game - internal method
- showHigh; // update the "high score field
// Interface Builder (IB) methods:
- pauseGame:sender; // to be sent by menu item
- startNewGame:sender; // called by New Game menu item and on startup
- unpauseGame:sender; // same as pauseGame:
- gameOver:sender; // sent by gameScreen when game is over.
- nextLevel:sender; // advance game to next level - internal
- (int)ateGhost; // eating ghosts is tracked by these methods since
- resetGhostScore; // the score depends on how many ghosts are eaten
- appWillInit:sender; // puts up loading alert.
- appDidInit:sender; // starts up the game on launch
- appDidBecomeActive:sender; // reactivates the game
- appDidHide:sender; // deactivates the game
- appDidResignActive:sender; // reactivates the game
- appDidUnhide:sender; // deactivates the game
- appWillTerminate:sender; // saves high scores and preferences
- quit:sender; // to catch the "quit" menu item
- windowDidResginMain:sender; // do pause if window loses main status
- windowDidResignKey:sender; // do pause if window loses key status
- windowDidBecomeKey:sender; // do unpause if window gains key status
- windowDidMove:sender; // move fruit basket and status with game window
@end
These are the contents of the former NiCE NeXT User Group NeXTSTEP/OpenStep software archive, currently hosted by Netfuture.ch.