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, etc. It has // rudimentary key and mouse handling methods; it's up to a subclass to // define them further as is appropriate. #import <appkit/appkit.h> #define GKKEYCODE (myevent->data.key.charCode) #define BEZELSIZE 8.0 // width of the bezel border... #define GRANULARITY 0.05 // 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 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 scoreKeeper; // tracks player's score id strings; // localized strings id customSound; // call to handle the sounds id preferences; // PreferencesBrain id dirtPile; // Object to handle flushing id buffer; // screen buffer id staticBuffer; // screen buffer holds maze, etc. id controller; // Game controller (GameBrain) reports level, etc. 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 grayBorder; // == YES if gray border is on BOOL doingBorder; // == YES if turning border on/off BOOL demoMode; // keep brain from putting demo score as high BOOL backIsColor; NXColor backColor; NXDragOperation dragOperation; } // initialization and start up functions - initFrame:(const NXRect *)frm; // initialize instance - appDidInit:sender; // forwarded by gamebrain - 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 - 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; - buildBackground; // allows hook to add static stuff on top of image - changeBackground:sender; - revertBackground:sender; - sizeTo:(NXCoord)width :(NXCoord)height; - loadAnImage:(const char *)imageName; - back1:sender; - back2:sender; - back3:sender; - drawBackground:(NXRect *)rect; // Note: although this is an "obsolete" API in 3.0, it's OK because // I use the new 3.0 drag and drop methods (as I should) and then // have them call this when appropriate. Note that NEXTSTEP no // longer does that, however; I do it explicitly! So in the GameKit, // it is NOT obsolete...it is supported. :) - acceptColor:(NXColor)color atPoint:(const NXPoint *)aPoint; - writeColor; // rebuild staticBuffer - rebuildStaticBuffer; - rebuildStaticAt:(NXRect *)rect; // drag & drop images & color - (NXDragOperation)draggingEntered:sender; - (NXDragOperation)draggingUpdated:sender; - draggingExited:sender; - (BOOL)prepareForDragOperation:sender; - (BOOL)performDragOperation:sender; - concludeDragOperation:sender; - gameOver; // sent by GameBrain @end
These are the contents of the former NiCE NeXT User Group NeXTSTEP/OpenStep software archive, currently hosted by Netfuture.ch.