pacman.engine
Class Physics

java.lang.Object
  extended by pacman.engine.Physics
All Implemented Interfaces:
java.awt.event.KeyListener, java.lang.Runnable, java.util.EventListener

public class Physics
extends java.lang.Object
implements java.lang.Runnable, java.awt.event.KeyListener

A class that handles the movement through the scene and the keyboard input.


Field Summary
private  int animStart
          Keeps track of what frame the current animation started on
private  int flag
          Determines whether to turn left (-1), turn right (1), turn around (-2 or 2) or move (0)
private  int frame
          Keeps track of which frame of the animation is being rendered
private  int lastFlag
          Keeps track of the last animation run and ensures that animStart is not constantly overwritten
(package private) static javax.vecmath.Matrix3d m3d
           
private  MenuPanel menu
           
private  boolean modflag
          Determines whether or not the flag variable can be modified
private  java.lang.Thread t
           
(package private) static javax.media.j3d.Transform3D t3d
           
(package private) static javax.media.j3d.TransformGroup tg
           
(package private) static javax.vecmath.Vector3d v3d
           
private  double viewAngle
          Keeps track of the view's current angle (0 = the initial view direction)
(package private) static javax.vecmath.Vector3d vLook
           
(package private) static javax.vecmath.Vector3d vPos
           
private  World world
           
 
Constructor Summary
Physics(MenuPanel mp, World w)
          Instantiates the class with the specified parent MenuPanel and World.
 
Method Summary
 void keyPressed(java.awt.event.KeyEvent ke)
          Handles keyboard input.
 void keyReleased(java.awt.event.KeyEvent ke)
          Remnant of KeyListener interface; not used.
 void keyTyped(java.awt.event.KeyEvent ke)
          Remnant of KeyListener interface; not used.
 void move()
          Moves the camera forward.
 void run()
          This method runs the Physics processing.
 void start()
          Starts the thread.
 void stop()
          Stops the thread.
 void turnLeft()
          Turns left by rotating the camera counterclockwise.
 void turnRight()
          Turns right by rotating the camera clockwise.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

menu

private MenuPanel menu

world

private World world

t

private java.lang.Thread t

flag

private int flag
Determines whether to turn left (-1), turn right (1), turn around (-2 or 2) or move (0)


lastFlag

private int lastFlag
Keeps track of the last animation run and ensures that animStart is not constantly overwritten


modflag

private boolean modflag
Determines whether or not the flag variable can be modified


frame

private int frame
Keeps track of which frame of the animation is being rendered


animStart

private int animStart
Keeps track of what frame the current animation started on


viewAngle

private double viewAngle
Keeps track of the view's current angle (0 = the initial view direction)


tg

static javax.media.j3d.TransformGroup tg

t3d

static javax.media.j3d.Transform3D t3d

m3d

static javax.vecmath.Matrix3d m3d

v3d

static javax.vecmath.Vector3d v3d

vPos

static javax.vecmath.Vector3d vPos

vLook

static javax.vecmath.Vector3d vLook
Constructor Detail

Physics

public Physics(MenuPanel mp,
               World w)
Instantiates the class with the specified parent MenuPanel and World.

Method Detail

start

public void start()
Starts the thread.


stop

public void stop()
Stops the thread.


run

public void run()
This method runs the Physics processing. It is designed to run at a fixed framerate of 75fps, if such a framerate is attainable, and ensures that the JVM garbage collector does not get overloaded

Specified by:
run in interface java.lang.Runnable

move

public void move()
Moves the camera forward.


turnRight

public void turnRight()
Turns right by rotating the camera clockwise.


turnLeft

public void turnLeft()
Turns left by rotating the camera counterclockwise.


keyPressed

public void keyPressed(java.awt.event.KeyEvent ke)
Handles keyboard input. Inputs used and their respective functions detailed in the Control section of the main menu.

Specified by:
keyPressed in interface java.awt.event.KeyListener

keyTyped

public void keyTyped(java.awt.event.KeyEvent ke)
Remnant of KeyListener interface; not used.

Specified by:
keyTyped in interface java.awt.event.KeyListener

keyReleased

public void keyReleased(java.awt.event.KeyEvent ke)
Remnant of KeyListener interface; not used.

Specified by:
keyReleased in interface java.awt.event.KeyListener