Version 0.8 - March 31, 1996
Mark Tacchi, mtacchi@NeXT.COM
The Gamelet Toolkit treats all animating objects such as ships, bullets, obstacles, etc. as Actor objects. Actors are simple objects that are responsible for displaying themselves and managing their own state. Therefore, they have control over where they are on the screen, what velocity they have, and what frame of animation they are to display if they are to display at all.
When Actors are created, they should be assigned to an ActorManager which is responsible for maintaining a list of all Actors for a given Scene. The ActorManager sends a heartbeat to each Actor for each Gamelet run-time cycle. It also performs collision detection and notifies Actors when they have collided.
All the frames for a given animation are stored within a single image. This was chosen to reduce the overhead of loading each image across the wire individually while at the same time gives the developer a convenient means to display and handle the frames during development.
Frames can be stored in any array of size nXm. Frames are numbered starting from the upper left hand corner, to coincide with Java's origin.
Default behaviour is to cycle through the animation frames beginning at frame zero continuing to the maximum number of frames and looping back to zero. This behaviour can be modified by overriding the ?????? method and controlling the instance variable currentFrame.
The Gamelet Toolkit was designed to incorporate highly optimized display management; this is necessary for quick action arcade style games. DisplayManager handles this with selective double buffering.
Two offscreen caches are used, one is a read only representation of a `clean' background, the other is the working copy used to build the current frame. Actor's are drawn on this working copy and then copied to the display. The extra step of copying to a working copy allows the DisplayManager to coalesce images when they are close so as to reduce the number of copy actions to the screen. It also solves the problem of cleaning up the last frame displayed.
ScoreManager maintains the current score and provides access methods for objects to access and update the score. It also allows objects to register for notification when a specific point level has been reached. This is useful for rewarding the player with a bonus.
Any object can request for notification when a specific event occurs by registering with the EventManager. Player objects will register for keyboard events to determine whether one of its control keys has been pressed. A game controller object may register for events to handle game pause, restart, or other pertinent events.
EventManager is passed the current event from Gamelet and delivers the event to all objects that requested an event of the current type.
(scheduled for v1.0)
Simple games that don't require drag'n drop or multiple views will define all Actors and game functionality within the game controller, a subclass of Gamelet. However, when games require more complexity, Scenes allow for the developer to segment the game into independent sections.
A scene may be used to segment a game into parts where the functionality of a game changes significantly enough to warrant a new set of Actors and a new ActorManager. This is useful for arcade games that have an intermission animation sequence, or separate game level.
Scenes are also useful for displaying multiple views at the same time. This can be used with games where different perspectives are visible at the same time, as in a tank game with left, front, and right views. Or where the actors within the Scenes are independent of the other Scene's actors.
Each Scene runs within it's own thread.
(scheduled for v1.0)
With multiple Scenes, the game developer can implement drag'n drop across the Scenes. The Scene class defines methods which provide drag'n drop functionality and can specifying what behaviour a specific Scene adopts for drag'n drop. This can lead to development tools written in Java where a palette of Actors can be dragged from one Scene and dropped onto another.