|
|||||||||||
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 MouseController
MouseController.pollMouse()
public void pollKeyboard()
KeyboardController
pollKeyboard
updates the state of the key variables to
be either true or false depending on the current keyboard.
pollKeyboard
in interface KeyboardController
KeyboardController.pollKeyboard()
public boolean isKeyDown(java.lang.Object keyCode)
KeyboardController
isKeyDown
returns a boolean value if a key is pressed or
not. True is returned if the key is pressed, false otherwise.
isKeyDown
in interface KeyboardController
keyCode
- which key to check for. Implementations job to define
how a keyCode is defined.
KeyboardController.isKeyDown(Object)
public void setBuffered()
KeyboardController
setBuffered
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 KeyboardController
KeyboardController.setBuffered()
public int next()
KeyboardController
next
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 KeyboardController
KeyboardController.next()
public int getMousePositionX()
MouseController
getMousePositionX
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 MouseController
MouseController.getMousePositionX()
public int getMousePositionY()
MouseController
getMousePositionY
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 MouseController
MouseController.getMousePositionY()
public int getAbsoluteMousePositionX()
MouseController
getAbsoluteMousePositionX
retrieves the actual x position
of the mouse cursor.
getAbsoluteMousePositionX
in interface MouseController
MouseController.getAbsoluteMousePositionX()
public int getAbsoluteMousePositionY()
MouseController
getAbsoluteMousePositionY
retrieves the actual y position
of the mouse cursor.
getAbsoluteMousePositionY
in interface MouseController
MouseController.getAbsoluteMousePositionY()
public int getMouseDeltaX()
MouseController
getMouseDeltaX
returns the change in the X coordinate of
the mouse since the previous frame.
getMouseDeltaX
in interface MouseController
MouseController.getMouseDeltaX()
public int getMouseDeltaY()
MouseController
getMouseDeltaY
returns the change in the Y coordinate of
the mouse since the previous frame.
getMouseDeltaY
in interface MouseController
MouseController.getMouseDeltaY()
public void setMousePosition(int x, int y)
MouseController
setMousePosition
sets the x and y coordinate of the mouse
within the cooridnates of the application window.
setMousePosition
in interface MouseController
x
- the new x coordinate.y
- the new y coordinate.MouseController.setMousePosition(int, int)
public int getNumberOfButtons()
MouseController
getNumberOfButtons
returns the number of buttons
assigned to the mouse.
getNumberOfButtons
in interface MouseController
public boolean isButtonDown(int mouseButton)
MouseController
isButtonDown
returns true if a specified button is currently
pressed on the mouse, false if it is not.
isButtonDown
in interface MouseController
mouseButton
- the button id to check.
MouseController.isButtonDown(int)
public void setEntityPosition(Vector position)
EntityController
setEntityPosition
sets the position of the Entity to the
vector passed.
setEntityPosition
in interface EntityController
position
- 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 EntityController
angle
- the yaw angle of the controlled entity.public void setEntityRoll(float angle)
setEntityRoll
sets the roll of the controlled entity.
setEntityRoll
in interface EntityController
angle
- the roll angle of the controlled entity.public void setEntityPitch(float angle)
setEntityPitch
sets the pitch of the controlled entity.
setEntityPitch
in interface EntityController
angle
- the pitch angle of the controlled entity.public Vector getEntityPosition()
EntityController
getEntityPosition
returns the current location in
three dimensional space of the Entity.
getEntityPosition
in interface EntityController
EntityController.getEntityPosition()
public abstract void render()
EntityController
render
sets the model view matrix to that defined by the
Entity's position, view and up vectors.
render
in interface EntityController
EntityController.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 |