All Packages  This Package  Previous  Next  Index

Class gamelet.Gamelet

java.lang.Object
   |
   +----java.awt.Component
           |
           +----java.awt.Canvas
                   |
                   +----gamelet.Gamelet

public abstract class Gamelet
extends Canvas
implements Runnable

Constructor Index

 o Gamelet(String, int, int, String)
Initialize and display a Gamelet, set a Background image.

Method Index

 o addActor(Actor)
Add an actor to the gamelet.
 o deltaTickTimeMillis()
Calculate the difference between the current tick and the last one.
 o getHeight()
Return height of visible area.
 o getImage(String)
Load an image for use in an Actor.
 o getInfo()
Provide standard Gamelet info.
 o getWidth()
Return width of visible area.
 o handleEvent(Event)
Pass the event along to the EventManager for handling.
 o paint(Graphics)
Pass the Graphics onto the DisplayManager.
 o randBetween(double, double)
Generate a random double between two doubles.
 o removeActor(Actor)
Remove an actor from the gamelet.
 o run()
Execution loop.
 o runGame()
Start the game.
 o stop()
Stop the game.
 o update(Graphics)
Override update to avoid screen clears.

Constructors

 o Gamelet
 public Gamelet(String title,
                int width,
                int height,
                String backgroundImageFile)
Initialize and display a Gamelet, set a Background image.

Parameters:
title - The window title for the Gamelet.
width - The width of the Gamelet window.
height - The height of the Gamelet window.
backgroundImageFile - A GIF-Image containing a background tile.

The background tile is automatically repeated to fill the background. After construction add your actors with the method addActor() and then invoke method runGame() to start the game.

Methods

 o getImage
 public Image getImage(String name)
Load an image for use in an Actor.

Parameters:
name - The name of a file containing a GIF-Image. Use this method in an actor to load an image for use in Actor.setImage().
 o getWidth
 public int getWidth()
Return width of visible area. Position (0,0) is upper left corner.

 o getHeight
 public int getHeight()
Return height of visible area. Position (0,0) is upper left corner.

 o addActor
 public void addActor(Actor theActor)
Add an actor to the gamelet.

 o removeActor
 public void removeActor(Actor theActor)
Remove an actor from the gamelet.

 o randBetween
 public static double randBetween(double a,
                                  double b)
Generate a random double between two doubles.

 o runGame
 public void runGame()
Start the game. Invoke this to perform continuous update of the gamelet and the actors.

 o stop
 public void stop()
Stop the game.

 o run
 public void run()
Execution loop. Implements the Runnable interface. Called from Thread().

 o handleEvent
 public boolean handleEvent(Event theEvent)
Pass the event along to the EventManager for handling.

Overrides:
handleEvent in class Component
 o deltaTickTimeMillis
 public double deltaTickTimeMillis()
Calculate the difference between the current tick and the last one.

 o update
 public void update(Graphics g)
Override update to avoid screen clears.

Overrides:
update in class Component
 o paint
 public void paint(Graphics g)
Pass the Graphics onto the DisplayManager.

Overrides:
paint in class Canvas
 o getInfo
 public static String getInfo()
Provide standard Gamelet info.


All Packages  This Package  Previous  Next  Index