home *** CD-ROM | disk | FTP | other *** search
/ NeXT Education Software Sampler 1992 Fall / NeXT Education Software Sampler 1992 Fall.iso / Programming / Source / PacMan / GameView.h < prev    next >
Encoding:
Text File  |  1992-07-24  |  4.5 KB  |  120 lines

  1.  
  2. /* Generated by Interface Builder */
  3.  
  4. // A generic class used to handle lots of the logic found in a game like
  5. // pausing, misc. states, backgrounds, sound on/off flagging, etc.  It has
  6. // rudimentary key and mouse handling methods; it's up to a subclass to
  7. // define them further as is appropriate.
  8.  
  9. #import <appkit/View.h>        // super class
  10.  
  11. #define BEZELSIZE 8.0    // width of the bezel border...
  12.  
  13. #define GRANULARITY 0.01    // timer granularity.  Screen should be updated
  14. #define CYCLES 1            // every 0.05 sec., so here, 2*0.025 = 0.05
  15. #define SPEEDUP 20            // how often to speed up game (every x columns)
  16. #define SPEEDUPDELTA 2        // how how long until next speedup
  17. #define SPEEDUPFACTOR 0.95    // how much to speed up at a time
  18. #define INITCY 8            // initial colCycles = INITCY * CYCLES
  19.  
  20. // directions
  21. #define LEFT 3
  22. #define RIGHT 1
  23. #define UP 0
  24. #define DOWN 2
  25. #define NORTHEAST 4
  26. #define NORTHWEST 5
  27. #define SOUTHEAST 6
  28. #define SOUTHWEST 7
  29.  
  30. // states -- tells autoUpdate what to do; a subclass of this view would add
  31. // whatever it needs in the way of new states.
  32. #define NORMALSTATE 0    // player's pill dropping
  33. #define GAMEOVER 1        // things still blink, etc.
  34.             
  35. #define WAITFORDEMO 600        // Wait x cycles before gameover to start demo
  36. // 600 cycles is approx. 30 sec, more or less.
  37.  
  38. @interface GameView:View
  39. {
  40.     id  backGround;
  41.     
  42.     id  preferences;        // PreferencesBrain
  43.     id  controller;            // Game controller reports level, etc.
  44.                             // of class "GameBrain"
  45.     id  animator;            // Animator instance
  46.     id  listenerId;            // Grabs Workspace messages for drag and drop.
  47.         
  48.     int state;                // current state
  49.     int cycles;                // used to blink things, etc. -- counts frames
  50.     int demoWait;            // how many cycles to wait before demo
  51.     char keys[5];            // keys to play game
  52.     BOOL paused;            // game is paused if == YES
  53.     BOOL soundEffects;        // == YES if sound effects on
  54.     BOOL music;                // == YES if music on
  55.     BOOL grayBorder;        // == YES if gray border is on
  56.     BOOL doingBorder;        // == YES if turning border on/off
  57.     BOOL demoMode;            // way to keep brain for setting
  58.                     // high scores from demo mode
  59.     BOOL backIsColor;
  60.     NXColor backColor;
  61.     char *appPath;            // pathname to inside of .app wrapper
  62.     char *iconPathList;        // pathnames of drag/drop files for background
  63. }
  64.  
  65. // initialization and start up functions
  66. - initFrame:(const NXRect *)frm;    // initialize instance
  67. - loadPix;                // gameBrain calls this from appDidInit
  68. - animate:sender;        // start animation-call from appDidInit
  69.  
  70. // return info about game state and so on...
  71. - (int)gameState;        // returns current state
  72. - (BOOL)demoMode;        // if last game was demo or in demo now
  73. - (float)speedTime;        // returns current speed
  74. - (BOOL)isPaused;        // tell caller if we're paused
  75. - autoUpdate:sender;    // sent by timer
  76. - pause:sender;            // pause game
  77. - unpause:sender;        // unpause game
  78. - soundOn;                // turn on sound effects
  79. - soundOff;                // turn off sound effects
  80. - musicOn;                // turn on music
  81. - musicOff;                // turn off music
  82. - getPreferences;        // set up preference inst. variables
  83.  
  84. // various view methods; many are overridden from the default NeXTstep
  85. // methods... basically, deal with various event types.
  86. - (BOOL)acceptsFirstResponder;    // to grab keyboard events
  87. - updateSelf:(NXRect *)rects :(int)rectCount;  //used by internals for speed
  88. - (BOOL)acceptsFirstMouse;        // let us grab activating mousedowns
  89. - mouseDown:(NXEvent *)event;    // handle mouseDown events.
  90. - keyDown:(NXEvent *)myevent;    // handle keyDown events.
  91. - setKey:(int)keyIndex val:(char)keyVal;  // change key we respond to
  92. - setUpScreen;                    // set up the game screen
  93. - changeBorder:(BOOL)borderOn;    // move view about in the window & do sizing
  94. - restartGame;                    // reset internal variables to restart level
  95.  
  96. // background handling methods.  Set various files, render the background,
  97. // resize it, and deal with drag and drop colors.  The specific background
  98. // stuff comes from BreakApp; the color stuff and any modifications are mine.
  99. - setBackgroundFile:(const char *)fileName andRemember:(BOOL)remember;
  100. - changeBackground:sender;
  101. - revertBackground:sender;
  102. - sizeTo:(NXCoord)width :(NXCoord)height;
  103. - back1:sender;
  104. - back2:sender;
  105. - back3:sender;
  106. - drawBackground:(NXRect *)rect;
  107. - acceptColor:(NXColor)color atPoint:(NXPoint *)aPoint;
  108. - writeColor;
  109.  
  110. // Icon dragging methods
  111. - registerWindow;
  112. - unregisterWindow;
  113. - (int)iconEntered:(int)windowNum at:(double)x :(double)y
  114.     iconWindow:(int)iconWindowNum iconX:(double)iconX iconY:(double)iconY
  115.     iconWidth:(double)iconWidth iconHeight:(double)iconHeight
  116.     pathList:(char *)pathList;
  117. - (int)iconReleasedAt:(double)x :(double)y ok:(int *)flag;
  118.  
  119. @end
  120.