This is PacManView.h in view mode; [Download] [Up]
/* Generated by Interface Builder */ // This object is the guts of the whole game. It is like a central clearing // house... it renders all the peices within itself. Rather than having lots // of independent views that do theire rendering all throughout the game, this // view ties together a lot of player/ghost objects and has them render // themselves inside of itself. This makes the drawing a bit more efficient // and allows allows easy programmatic control of which order things get drawn // in. Since the images all use transparency, etc., this order is very // important. The two main methods in here are the autoUpdate: method, which // is a giant state machine that handles the logic of the game, and the // updateSelf:: method that updates the screen from one animation frame to the // next. drawSelf:: is a less complex version of updateSelf:: because it // always renders the whole view, not just the things which have changed since // the last update. By having two different methods, drawing is sped up at // the sacrifice of code clarity. (Having two different rendering methods // gives better speed, but code complexity is nasty and the difficulty of // keeping both methods in sync so that they give identical results make for // a lot of work.) I haven't yet found a good way to simplify the rendering // engine without slowing it down...if you have any suggestions, I would like // to hear them of course, but I've already tried quite a few things. #import <gamekit/gamekit.h> // states -- tells autoUpdate what to do #define BLINK_LEVEL 10 // when out of dots we do this #define READY 11 // READY on screen (starting a new level) #define DIEREADY 12 // READY on screen (after a die) #define DYING_PAC 13 // the Pac melts during this phase #define GAME_OVER GAMEOVER // I forget which one to use, so define both // Sizes of arrays used to determine which maze to use for a level // and the point value for a fruit on a particular level #define NUMSCREENS 24 #define NUMFRUITVALS 16 #define WAITFORDEMO 600 // Wait x cycles before gameover to start demo // values for "fruitOn" (besides YES and NO; these two are transitory states) #define DRAW 2 // do we put fruit on the screen? #define ERASE 3 // do we erase fruit from the screen? // offset for drawing ghost/fruit point values. #define TEXTOFFSET (-10) #define WIPETEXT (-1) // flag to undraw text scores // when fruit gets erased #define ERASEFRUIT (200 + (([controller level] <= 10) ? 10 * (10 - \ [controller level]) : 0) + timeToFruit) // macro for zapping rectangle at specific coords #define ZAPRECT(r, x, y) NX_X(&(r)) = (x); NX_Y(&(r)) = (y); \ [dirtPile addRegion:&(r)] #define CLRRECT(r) [dirtPile addRegion:&(r)]; \ [staticBuffer composite:NX_COPY fromRect:&(r) toPoint:&((r).origin)] @interface PacManView:GameView { // various actors that get rendered in our view. id backGround2; id maze; id fruit[3]; id player; id ghost[4]; id gameOver[3]; int begin; // used as a counter for state transitions BOOL erasePwr, eraseReady; // erase power dot, ready text? int fruitCount; // counter to decide when to do fruit stuff int timeToFruit; // when to put next fruit up int fruitOn; // if fruit is out there...YES, NO, DRAW, or ERASE. int numFruits; // how many fruits put up in current level int fruitPointCount, ftx, fty, fruitPoints, ftx2, fty2; int ghostPointCount[4], gtx[4], gty[4], ghostPoints[4], gtx2[4], gty2[4]; NXPoint mazePos, myorigin; NXRect eraseRect, textEraseRect, readyRect; NXSize gameOverSize[3]; int scale; BOOL cheatMode; // in cheat mode? GKTrackerId ghostId, fruitId; // bonus trackers } - initFrame:(const NXRect *)frm; // initialize instance - loadPix; // gameBrain calls this from appDidInit - ghost:(int)i; // return ghost #i - autoUpdate:sender; // sent by timer - updateSelf:(NXRect *)rects :(int)rectCount; //used by internals for speed - drawSelf:(NXRect *)rects :(int)rectCount; // standard rendering method - keyDown:(NXEvent *)myevent; // handle keyDown events. - setUpScreen; // sets up screen from level start, calls -startScreen below. - startScreen; // sets up screen without refilling all eaten dots. - restartGame; // start game over. - restartGameForDemo:(BOOL)doingDemo; // use to keep start game sound quiet // in demo mode if that's what the user wants. - blinkPowerDot; // update static buffer where power dots are. - setBackgroundFile:(const char *)fileName andRemember:(BOOL)remember; - buildColorBackground; - rebuildStaticBuffer; - rebuildStaticAt:(NXRect *)rect; - (int)scale; - setScale:(int)newScale; - setGhostTracker:(GKTrackerId)tracker; - setFruitTracker:(GKTrackerId)tracker; @end
These are the contents of the former NiCE NeXT User Group NeXTSTEP/OpenStep software archive, currently hosted by Netfuture.ch.