Class republikensoft.Gunfighter
All Packages  Class Hierarchy  This Package  Previous  Next  Index

Class republikensoft.Gunfighter

java.lang.Object
   |
   +----java.awt.Component
           |
           +----java.awt.Container
                   |
                   +----java.awt.Panel
                           |
                           +----java.applet.Applet
                                   |
                                   +----republikensoft.Gunfighter

public class Gunfighter
extends Applet
implements Runnable
This class is the main program that controls the game. To make communication with other classes easier, some methods and variables are made static. This is no limitation since we only have one instance of this class. Some important variables are made public just to show up in this page.

Variable Index

 o actor
actor[0] - The Good (blue)
actor[1] - The Bad and Ugly (red)
 o gameState
This variable controls the behavior of the game.
 o obstacles
This array contains the obstacles for the current playfield.
 o scenes
Array of arrays containing tripples with object types and coordinates.
 o screenHeight
Playfield height.
 o screenWidth
Playfield width.
 o sfx
The sound effects.
 o textures
All the obstacle's textures and the bullet texture.

Constructor Index

 o Gunfighter()

Method Index

 o handleEvent(Event)
Takes care of user input.
 o init()
Sets up some drawing areas, fonts, colours and builds the obstacle polygons.
 o paint(Graphics)
Draws the offscreen buffer into the screen.
 o run()
The main loop of the game.
 o start()
Creates a new game thread.
 o stop()
Stops the game and soundplaying.
 o update(Graphics)
Draws into offscreen depending of gameState.

Variables

 o actor
  public static Player actor[]
actor[0] - The Good (blue)
actor[1] - The Bad and Ugly (red)
 o gameState
  public static int gameState
This variable controls the behavior of the game. The states are: loading, intro, new game, new duel, action, player dead, between level and game over.
 o obstacles
  public static Obstacle obstacles[]
This array contains the obstacles for the current playfield.
 o scenes
  public final short scenes[][]
Array of arrays containing tripples with object types and coordinates.
 o screenHeight
  public final static int screenHeight
Playfield height. Currently set to 440 pixels.
 o screenWidth
  public final static int screenWidth
Playfield width. Currently set to 740 pixels.
 o sfx
  public static AudioClip sfx[]
The sound effects.
0 - shoot 1 - ricochet 2 - click 3 - reload
4 - scream 5 - prepare 6 - intro
 o textures
  public static Image textures[]
All the obstacle's textures and the bullet texture.
0 - blue ammo box 1 - red ammo box 2 - big rock left 3 - small rock right
4 - big rock right 5 - small rock left 6 - spuce 7 - triange bush
8 - round tree light 9 - round tree dark 10 - bullet

Constructors

 o Gunfighter
  public Gunfighter()

Methods

 o handleEvent
  public boolean handleEvent(Event e)
Takes care of user input.
Overrides:
handleEvent in class Component
 o init
  public void init()
Sets up some drawing areas, fonts, colours and builds the obstacle polygons.
Overrides:
init in class Applet
 o paint
  public void paint(Graphics g)
Draws the offscreen buffer into the screen.
Overrides:
paint in class Component
 o run
  public void run()
The main loop of the game. Sleep, update game, repaint and loop.
 o start
  public void start()
Creates a new game thread.
Overrides:
start in class Applet
 o stop
  public void stop()
Stops the game and soundplaying.
Overrides:
stop in class Applet
 o update
  public void update(Graphics g)
Draws into offscreen depending of gameState.
Overrides:
update in class Component

All Packages  Class Hierarchy  This Package  Previous  Next  Index