home *** CD-ROM | disk | FTP | other *** search
-
- #import <gamekit/gamekit.h>
-
- // This object controls the main animation loop and handles
- // things like which buffer gets drawn into an when. You do
- // not _have_ to use the intermediate buffers; if one is missing,
- // then the drawing at that level is done in the next higher
- // buffer level. You _must_ have the top level (the gameView)
- // buffer set up, though, or nothing will ever get drawn! If
- // you do not have a background buffer set up, then the DirtPile
- // for the next level up will use a solid color...see DirtPile
- // class for details. (If you want a solid color, make _sure_
- // that you set it in the right DirtPile!)
-
- // How many levels of beffering are used
- #define GK_BUFFER_TYPES 4
- #define GK_BACKGROUND_BUFFER 0
- #define GK_STATIC_BUFFER 1
- #define GK_DYNAMIC_BUFFER 2
- #define GK_SCREEN_BUFFER 3 // MUST be isKindOf:[GameView class]!!!
-
- // There are several types of actors which you might use
- #define GK_ACTOR_TYPES GK_BUFFER_TYPES
- #define GK_NO_ACTOR 0 // NULL actor
-
- // STATIC: actors that draw in the static buffer, if it
- // exists; these move or change appearance rarely (the power dots
- // and onscreen text messages in PacMan, for example...)
- #define GK_STATIC_ACTOR GK_STATIC_BUFFER
-
- // DYNAMIC: actors that draw in the dynamicBuffer (most actors are this)
- #define GK_DYNAMIC_ACTOR GK_DYNAMIC_BUFFER
-
- // RETAINED: actors that draw directly on gameView w/o buffer
- // things like stars, explosion particles, and so on.
- #define GK_RETAINED_ACTOR GK_SCREEN_BUFFER
-
- @interface GKStage:Object
- {
- id actors[GK_ACTOR_TYPES];
- id addActors[GK_ACTOR_TYPES]; // actors to add for next cycle
- id removeActors[GK_ACTOR_TYPES]; // actors to remove before next cycle
- id collisionGroups, addCollisionGroups, removeCollisionGroups;
- // Lists of GKCollisionGroup objects
- id stageManager; // where to send "dead" actors
- id drawingBuffers[GK_BUFFER_TYPES];
- id dirtPiles[GK_BUFFER_TYPES]; // dirtPile #1 goes between buff. 0&1, etc
- // DirtPiles are created automatically when a buffer/gameView are set up
- }
-
- - init;
-
- - actorListForType:(int)type; // return the List object with the actors in it
- - dirtPileType:(int)anInt; // returns DirtPile for buffer of type anInt
- - bufferType:(int)anInt; // returns buffer of type anInt
- - setBufferType:(int)anInt to:aBuffer; // change buffer that we use to aBuffer
- - makeDirtPileForBuffer:(int)anInt; // returns a new dirtPile for buffer
- // override if you want to fine tune the DirtPiles in any way...
-
- - stageManager;
- - setStageManager:aManager; // where to send old actors to (free them if nil)
-
- // add and delete actors; action is delayed until -doAddsAndRemoves is called
- // so we don't change the Lists while we are traversing them. The same goes
- // for collision groups.
- - addActor:anActor ofType:(int)type;
- - removeActor:anActor ofType:(int)type;
- - addCollisionGroup:aGroup;
- - removeCollisionGroup:aGroup;
- - collisionGroups;
- - findCollisionGroupWithTag:(int)anInt;
- - doAddsAndRemoves; // called at the end of a frame to update the actor Lists
-
- - doOneFrame; // does one frame of animation/calculation (game cycle)
-
- // the steps taken for each frame of calculation and animation (game cycle)
- // these are separate to make subclassing easier to do...
- - calculateMoves;
- - calculateCollisions;
- - render;
-
- - (BOOL)doRender; // decides whether or not to actually do a render for
- // this particular game cycle... currently, always returns a YES.
- // you can override to make some cycles not get rendered (which will
- // make the game _appear_ to move faster, but it still calculates
- // all the unseen frames...)
-
- @end
-