ftp.nice.ch/pub/next/developer/objc/appkit/AnimTester.s.tar.gz#/AnimTester/GameView.h

This is GameView.h in view mode; [Download] [Up]

/* Generated by Interface Builder */

// A generic class used to handle lots of the logic found in a game like
// pausing, misc. states, backgrounds, sound on/off flagging, etc.  It has
// rudimentary key and mouse handling methods; it's up to a subclass to
// define them further as is appropriate.

#import <appkit/View.h>		// super class

#define BEZELSIZE 8.0	// width of the bezel border...

#define GRANULARITY 0.01	// timer granularity.  Screen should be updated
#define CYCLES 1			// every 0.05 sec., so here, 2*0.025 = 0.05
#define SPEEDUP 20			// how often to speed up game (every x columns)
#define SPEEDUPDELTA 2		// how how long until next speedup
#define SPEEDUPFACTOR 0.95	// how much to speed up at a time
#define INITCY 8			// initial colCycles = INITCY * CYCLES

// directions
#define LEFT 3
#define RIGHT 1
#define UP 0
#define DOWN 2
#define NORTHEAST 4
#define NORTHWEST 5
#define SOUTHEAST 6
#define SOUTHWEST 7

// states -- tells autoUpdate what to do; a subclass of this view would add
// whatever it needs in the way of new states.
#define NORMALSTATE 0	// player's pill dropping
#define GAMEOVER 1		// things still blink, etc.
			
#define WAITFORDEMO 600		// Wait x cycles before gameover to start demo
// 600 cycles is approx. 30 sec, more or less.

@interface GameView:View
{
    id  backGround;
    
    id  preferences;		// PreferencesBrain
    id  controller;			// Game controller reports level, etc.
    						// of class "GameBrain"
    id  animator;			// Animator instance
	id  listenerId;			// Grabs Workspace messages for drag and drop.
	    
    int state;				// current state
	int cycles;				// used to blink things, etc. -- counts frames
    int demoWait;			// how many cycles to wait before demo
    char keys[5];			// keys to play game
    BOOL paused;			// game is paused if == YES
    BOOL soundEffects;		// == YES if sound effects on
    BOOL music;				// == YES if music on
    BOOL grayBorder;		// == YES if gray border is on
    BOOL doingBorder;		// == YES if turning border on/off
    BOOL demoMode;			// way to keep brain for setting
					// high scores from demo mode
	BOOL backIsColor;
	NXColor backColor;
	char *appPath;			// pathname to inside of .app wrapper
	char *iconPathList;		// pathnames of drag/drop files for background
}

// initialization and start up functions
- initFrame:(const NXRect *)frm;	// initialize instance
- loadPix;				// gameBrain calls this from appDidInit
- animate:sender;		// start animation-call from appDidInit

// return info about game state and so on...
- (int)gameState;		// returns current state
- (BOOL)demoMode;		// if last game was demo or in demo now
- (float)speedTime;		// returns current speed
- (BOOL)isPaused;		// tell caller if we're paused
- autoUpdate:sender;	// sent by timer
- pause:sender;			// pause game
- unpause:sender;		// unpause game
- soundOn;				// turn on sound effects
- soundOff;				// turn off sound effects
- musicOn;				// turn on music
- musicOff;				// turn off music
- getPreferences;		// set up preference inst. variables

// various view methods; many are overridden from the default NeXTstep
// methods... basically, deal with various event types.
- (BOOL)acceptsFirstResponder;	// to grab keyboard events
- updateSelf:(NXRect *)rects :(int)rectCount;  //used by internals for speed
- (BOOL)acceptsFirstMouse;		// let us grab activating mousedowns
- mouseDown:(NXEvent *)event;	// handle mouseDown events.
- keyDown:(NXEvent *)myevent;	// handle keyDown events.
- setKey:(int)keyIndex val:(char)keyVal;  // change key we respond to
- setUpScreen;					// set up the game screen
- changeBorder:(BOOL)borderOn;	// move view about in the window & do sizing
- restartGame;					// reset internal variables to restart level

// background handling methods.  Set various files, render the background,
// resize it, and deal with drag and drop colors.  The specific background
// stuff comes from BreakApp; the color stuff and any modifications are mine.
- setBackgroundFile:(const char *)fileName andRemember:(BOOL)remember;
- changeBackground:sender;
- revertBackground:sender;
- sizeTo:(NXCoord)width :(NXCoord)height;
- back1:sender;
- back2:sender;
- back3:sender;
- drawBackground:(NXRect *)rect;
- acceptColor:(NXColor)color atPoint:(NXPoint *)aPoint;
- writeColor;

// Icon dragging methods
- registerWindow;
- unregisterWindow;
- (int)iconEntered:(int)windowNum at:(double)x :(double)y
    iconWindow:(int)iconWindowNum iconX:(double)iconX iconY:(double)iconY
    iconWidth:(double)iconWidth iconHeight:(double)iconHeight
    pathList:(char *)pathList;
- (int)iconReleasedAt:(double)x :(double)y ok:(int *)flag;

@end

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