ftp.nice.ch/pub/next/developer/resources/libraries/gamekit_proj.NI.sa.tar.gz#/gamekit_proj/Documentation/Classes/GameBrain.rtf

This is GameBrain.rtf in view mode; [Download] [Up]

Release 1.0  Copyright 1992 by Don Yacktman.  All Rights Reserved.





Warning:  This is a very old document and is unreliable.  It's probably best to read the Chapter 2 GameKit docs and the header files¼and you'll be much better off!





GameBrain 

INHERITS FROM	Object

DECLARED IN	GameBrain.h



CLASS DESCRIPTION

A GameBrain serves as the "distributor cap" that ties together a game application.  It acts as delegate to the Application class and is also the delegate to the game's main window.  It handles housekeeping chores like updating the menus (pause/unpause), handling auto pause/unpause, updating the "statistics" window, and tracking the player's score.

To use a GameBrain, you must hook it up to the various parts of the game interface.  First, it should be the delegate of the main game window and the delegate of the Application.  Next, it needs to be connected to a HighScoreTable object, a PreferencesBrain object, and a subclass of GameView.  Finally, you should hook up any applicable interface elements, notably the pause/unpause menu button, the text fields to hold the level, score and current high score, and a PlayerUpView object.  If your particular game doesn't require one of these interface elements, just leave it out.  (Or delete the element from the generic game priovided with this distribution.)

You probably won't need to make a subclass of the GameBrain; typically a game is defined by subclassing the GameView and GameActor classes.  However, often it does make sense to add certain functions to the GameBrain rather than one of the other classes, such as tracking bonuses, user registration hooks, and so on.  For examples of these, see the source code for PacMan and Columns, respectively.



INSTANCE VARIABLES

Inherited from Object	Class	isa;

Declared in GameBrain	int	score, level, speed;
	int	pointsToNextBonus, lastBonus;
	BOOL	paused, ranOnce;
	id	alert;
	id	levelText, topScoreText, scoreText;
	id	pauseMenuCell;
	id	soundPlayer;
	id	infoController;
	id	preferencesBrain;
	id	highScoreTable;
	id	gameScreen;
	id	gameWindow;

score 	Player's score.

level 	Current level of play.

speed 	Current speed of game.

pointsToNextBonus 	How many point the player needs to score until the next free "man".

lastBonus 	Points the player had when the most recent free "man" was awarded.

paused 	Whether or not the game is paused.

ranOnce 	Whether or not the player actually played a game.  This allows us to "complain" if the app was launched but never used.

alert 	An alert panel ("loading images") put up while the app initializes.

levelText 	Textfield that contains the player's current level of play.

topScoreText 	Textfield that contains the current highest score.

scoreText 	Textfield that contains the player's current score.

pauseMenuCell 	The "Pause" cell in the Main Menu.

soundPlayer 	A SoundPlayer object (coordinates playback of several sounds).

infoController 	An InfoController object (coordinates the Info menu stuff).

preferencesBrain 	A PreferencesBrain object (preferences tracker).

highScoreTable 	A HighScoreTable object (high score tracker).

gameScreen 	A GameView subclass.

gameWindow 	The main game window.


METHOD TYPES

Initialization	- init 

Scoring	- zeroScore 
- addToScore:
- showHigh

Pause Control	- pause 
- unpause
- paused
- pauseGame:
- unpauseGame:

Game Control	- startNewGame: 
- gameOver
- gameOver:
- nextLevel:
- level
- speed
- quit:

Window Delegate	- windowDidResginMain:
- windowDidResignKey:
- windowDidBecomeKey:
- windowDidMove:

Application Delegate	- appWillInit:
- appDidInit:
- appDidBecomeActive:
- appDidHide:
- appDidUnHide:
- appDidResignActive:
- appDidWillTerminate:




INSTANCE METHODS


- addToScore:
- appDidBecomeActive:
- appDidHide:
- appDidInit:
- appDidResignActive:
- appDidUnHide:
- appDidWillTerminate:
	- appWillInit:
- gameOver
- gameOver:
init
- init

Designated initializer for the GameBrain.  Sets up various instance variables.  Returns self.



level
- (int)level

Returns the level.

See also:  ± nextLevel:



nextLevel:
- nextLevel:sender

Moves the game to the next level.  A subclass may be required to add extra functionality to this method.  Don't forget to call the super method if you do this.  Returns self.

See also:  ±level





	- pause 
- paused
- pauseGame:
- quit:
- showHigh
	- speed
	- startNewGame: 
	- unpause
	- unpauseGame:
	- windowDidResginMain:
	- windowDidResignKey:
	- windowDidBecomeKey:
	- windowDidMove:
	- zeroScore 

	

These are the contents of the former NiCE NeXT User Group NeXTSTEP/OpenStep software archive, currently hosted by Netfuture.ch.