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.
-
actor
- actor[0] - The Good (blue)
actor[1] - The Bad and Ugly (red)
-
gameState
- This variable controls the behavior of the game.
-
obstacles
- This array contains the obstacles for the current playfield.
-
scenes
- Array of arrays containing tripples with object types and coordinates.
-
screenHeight
- Playfield height.
-
screenWidth
- Playfield width.
-
sfx
- The sound effects.
-
textures
- All the obstacle's textures and the bullet texture.
-
Gunfighter()
-
-
handleEvent(Event)
- Takes care of user input.
-
init()
- Sets up some drawing areas, fonts, colours and builds the
obstacle polygons.
-
paint(Graphics)
- Draws the offscreen buffer into the screen.
-
run()
- The main loop of the game.
-
start()
- Creates a new game thread.
-
stop()
- Stops the game and soundplaying.
-
update(Graphics)
- Draws into offscreen depending of gameState.
actor
public static Player actor[]
- actor[0] - The Good (blue)
actor[1] - The Bad and Ugly (red)
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.
obstacles
public static Obstacle obstacles[]
- This array contains the obstacles for the current playfield.
scenes
public final short scenes[][]
- Array of arrays containing tripples with object types and coordinates.
screenHeight
public final static int screenHeight
- Playfield height.
Currently set to 440 pixels.
screenWidth
public final static int screenWidth
- Playfield width.
Currently set to 740 pixels.
sfx
public static AudioClip sfx[]
- The sound effects.
0 - shoot | 1 - ricochet | 2 - click | 3 - reload |
4 - scream | 5 - prepare | 6 - intro |
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 |
Gunfighter
public Gunfighter()
handleEvent
public boolean handleEvent(Event e)
- Takes care of user input.
- Overrides:
- handleEvent in class Component
init
public void init()
- Sets up some drawing areas, fonts, colours and builds the
obstacle polygons.
- Overrides:
- init in class Applet
paint
public void paint(Graphics g)
- Draws the offscreen buffer into the screen.
- Overrides:
- paint in class Component
run
public void run()
- The main loop of the game.
Sleep, update game, repaint and loop.
start
public void start()
- Creates a new game thread.
- Overrides:
- start in class Applet
stop
public void stop()
- Stops the game and soundplaying.
- Overrides:
- stop in class Applet
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