|
|||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||||
java.lang.Objectjme.controller.AbstractGameController
AbstractGameController defines common keyboard, mouse and
camera behavior. It provides some convienience methods for handling
mouse input, keyboard input and camera control as defined by
KeyboardController, MouseController and
EntityController.
| Field Summary | |
protected Entity |
entity
|
| Constructor Summary | |
AbstractGameController()
|
|
| Method Summary | |
int |
getAbsoluteMousePositionX()
getAbsoluteMousePositionX retrieves the actual x position
of the mouse cursor. |
int |
getAbsoluteMousePositionY()
getAbsoluteMousePositionY retrieves the actual y position
of the mouse cursor. |
Vector |
getEntityPosition()
getEntityPosition returns the current location in
three dimensional space of the Entity. |
int |
getMouseDeltaX()
getMouseDeltaX returns the change in the X coordinate of
the mouse since the previous frame. |
int |
getMouseDeltaY()
getMouseDeltaY returns the change in the Y coordinate of
the mouse since the previous frame. |
int |
getMousePositionX()
getMousePositionX returns the x coordinate of the mouse
within the application window. |
int |
getMousePositionY()
getMousePositionY returns the y coordinate of the mouse
within the application window. |
int |
getNumberOfButtons()
getNumberOfButtons returns the number of buttons
assigned to the mouse. |
boolean |
isButtonDown(int mouseButton)
isButtonDown returns true if a specified button is currently
pressed on the mouse, false if it is not. |
boolean |
isKeyDown(java.lang.Object keyCode)
isKeyDown returns a boolean value if a key is pressed or
not. |
int |
next()
next returns the key code of the next key in the buffer. |
void |
pollKeyboard()
pollKeyboard updates the state of the key variables to
be either true or false depending on the current keyboard. |
void |
pollMouse()
pollMouse updates the mouse position and the absolute
mouse position. |
abstract void |
render()
render sets the model view matrix to that defined by the
Entity's position, view and up vectors. |
void |
setBuffered()
setBuffered sets the keyboard to buffered mode. |
void |
setEntityPitch(float angle)
setEntityPitch sets the pitch of the controlled entity. |
void |
setEntityPosition(Vector position)
setEntityPosition sets the position of the Entity to the
vector passed. |
void |
setEntityRoll(float angle)
setEntityRoll sets the roll of the controlled entity. |
void |
setEntityYaw(float angle)
setEntityYaw sets the yaw of the controlled entity. |
void |
setMousePosition(int x,
int y)
setMousePosition sets the x and y coordinate of the mouse
within the cooridnates of the application window. |
abstract boolean |
update(float frameRate)
update defines a method that should be called each round
or frame. |
| Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Field Detail |
protected Entity entity
| Constructor Detail |
public AbstractGameController()
| Method Detail |
public void pollMouse()
pollMouse updates the mouse position and the absolute
mouse position.
pollMouse in interface MouseControllerMouseController.pollMouse()public void pollKeyboard()
KeyboardControllerpollKeyboard updates the state of the key variables to
be either true or false depending on the current keyboard.
pollKeyboard in interface KeyboardControllerKeyboardController.pollKeyboard()public boolean isKeyDown(java.lang.Object keyCode)
KeyboardControllerisKeyDown returns a boolean value if a key is pressed or
not. True is returned if the key is pressed, false otherwise.
isKeyDown in interface KeyboardControllerkeyCode - which key to check for. Implementations job to define
how a keyCode is defined.
KeyboardController.isKeyDown(Object)public void setBuffered()
KeyboardControllersetBuffered sets the keyboard to buffered mode. All keyboard
input will be placed in the buffer and can be retrieved one key press
at a time using next.
setBuffered in interface KeyboardControllerKeyboardController.setBuffered()public int next()
KeyboardControllernext returns the key code of the next key in the buffer.
To correctly use this, a call to setBuffered needs to be
made.
next in interface KeyboardControllerKeyboardController.next()public int getMousePositionX()
MouseControllergetMousePositionX returns the x coordinate of the mouse
within the application window. If the mouse moves out of the window,
the position will set the correct coordinate to the window's extreme.
getMousePositionX in interface MouseControllerMouseController.getMousePositionX()public int getMousePositionY()
MouseControllergetMousePositionY returns the y coordinate of the mouse
within the application window. If the mouse moves out of the window,
the position will set the correct coordinate to the window's extreme.
getMousePositionY in interface MouseControllerMouseController.getMousePositionY()public int getAbsoluteMousePositionX()
MouseControllergetAbsoluteMousePositionX retrieves the actual x position
of the mouse cursor.
getAbsoluteMousePositionX in interface MouseControllerMouseController.getAbsoluteMousePositionX()public int getAbsoluteMousePositionY()
MouseControllergetAbsoluteMousePositionY retrieves the actual y position
of the mouse cursor.
getAbsoluteMousePositionY in interface MouseControllerMouseController.getAbsoluteMousePositionY()public int getMouseDeltaX()
MouseControllergetMouseDeltaX returns the change in the X coordinate of
the mouse since the previous frame.
getMouseDeltaX in interface MouseControllerMouseController.getMouseDeltaX()public int getMouseDeltaY()
MouseControllergetMouseDeltaY returns the change in the Y coordinate of
the mouse since the previous frame.
getMouseDeltaY in interface MouseControllerMouseController.getMouseDeltaY()
public void setMousePosition(int x,
int y)
MouseControllersetMousePosition sets the x and y coordinate of the mouse
within the cooridnates of the application window.
setMousePosition in interface MouseControllerx - the new x coordinate.y - the new y coordinate.MouseController.setMousePosition(int, int)public int getNumberOfButtons()
MouseControllergetNumberOfButtons returns the number of buttons
assigned to the mouse.
getNumberOfButtons in interface MouseControllerpublic boolean isButtonDown(int mouseButton)
MouseControllerisButtonDown returns true if a specified button is currently
pressed on the mouse, false if it is not.
isButtonDown in interface MouseControllermouseButton - the button id to check.
MouseController.isButtonDown(int)public void setEntityPosition(Vector position)
EntityControllersetEntityPosition sets the position of the Entity to the
vector passed.
setEntityPosition in interface EntityControllerposition - the new position of the Entity.EntityController.setEntityPosition(Vector)public void setEntityYaw(float angle)
setEntityYaw sets the yaw of the controlled entity.
setEntityYaw in interface EntityControllerangle - the yaw angle of the controlled entity.public void setEntityRoll(float angle)
setEntityRoll sets the roll of the controlled entity.
setEntityRoll in interface EntityControllerangle - the roll angle of the controlled entity.public void setEntityPitch(float angle)
setEntityPitch sets the pitch of the controlled entity.
setEntityPitch in interface EntityControllerangle - the pitch angle of the controlled entity.public Vector getEntityPosition()
EntityControllergetEntityPosition returns the current location in
three dimensional space of the Entity.
getEntityPosition in interface EntityControllerEntityController.getEntityPosition()public abstract void render()
EntityControllerrender sets the model view matrix to that defined by the
Entity's position, view and up vectors.
render in interface EntityControllerEntityController.render()public abstract boolean update(float frameRate)
update defines a method that should be called each round
or frame. What occurs during this update is the responsiblity of
the subclass. A typical implementation would be to poll all devices,
process input, then update the state of the entity.
frameRate - denotes the current speed of the rendering, to allow
for time based movements.
|
|||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||||