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
-
Gamelet(String, int, int, String)
- Initialize and display a Gamelet, set a Background image.
-
addActor(Actor)
- Add an actor to the gamelet.
-
deltaTickTimeMillis()
- Calculate the difference between the current tick and the last one.
-
getHeight()
- Return height of visible area.
-
getImage(String)
- Load an image for use in an Actor.
-
getInfo()
- Provide standard Gamelet info.
-
getWidth()
- Return width of visible area.
-
handleEvent(Event)
- Pass the event along to the EventManager for handling.
-
paint(Graphics)
- Pass the Graphics onto the DisplayManager.
-
randBetween(double, double)
- Generate a random double between two doubles.
-
removeActor(Actor)
- Remove an actor from the gamelet.
-
run()
- Execution loop.
-
runGame()
- Start the game.
-
stop()
- Stop the game.
-
update(Graphics)
- Override update to avoid screen clears.
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.
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().
getWidth
public int getWidth()
- Return width of visible area.
Position (0,0) is upper left corner.
getHeight
public int getHeight()
- Return height of visible area.
Position (0,0) is upper left corner.
addActor
public void addActor(Actor theActor)
- Add an actor to the gamelet.
removeActor
public void removeActor(Actor theActor)
- Remove an actor from the gamelet.
randBetween
public static double randBetween(double a,
double b)
- Generate a random double between two doubles.
runGame
public void runGame()
- Start the game.
Invoke this to perform continuous update of the gamelet and the actors.
stop
public void stop()
- Stop the game.
run
public void run()
- Execution loop. Implements the Runnable interface.
Called from Thread().
handleEvent
public boolean handleEvent(Event theEvent)
- Pass the event along to the EventManager for handling.
- Overrides:
- handleEvent in class Component
deltaTickTimeMillis
public double deltaTickTimeMillis()
- Calculate the difference between the current tick and the last one.
update
public void update(Graphics g)
- Override update to avoid screen clears.
- Overrides:
- update in class Component
paint
public void paint(Graphics g)
- Pass the Graphics onto the DisplayManager.
- Overrides:
- paint in class Canvas
getInfo
public static String getInfo()
- Provide standard Gamelet info.
All Packages This Package Previous Next Index