apes
Class Banana

java.lang.Object
  extended by apes.ImageObject
      extended by apes.CollidableImageObject
          extended by apes.Banana
All Implemented Interfaces:
ICollidableObject, ILevelObject

public class Banana
extends CollidableImageObject

This class represents a Banana (or really any object that may be thrown in a parabolic trajectory).

The actual current position will be saved in the position field of this classes super class (ImageObject). The position passed to the constructor will be used as current actual position as well as spawning point in the future.


Field Summary
 
Fields inherited from class apes.ImageObject
image, name, position
 
Constructor Summary
Banana(java.lang.String name, org.newdawn.slick.Image image, org.newdawn.slick.geom.Vector2f position, org.newdawn.slick.geom.Shape collisionShape)
          constructs a new banana with given arguments.
 
Method Summary
 org.newdawn.slick.geom.Vector2f getPositionBeforSpawn()
          returns the last actual position before the last respawn.
 org.newdawn.slick.geom.Vector2f getSpawnPosition()
          returns the position where this banana will respawn after hitting the border or a collidable object.
 org.newdawn.slick.geom.Path getYForX(float g, float beta, float vel, org.newdawn.slick.GameContainer gc)
          creates a path representing the current parabolic trajectory.
 boolean isMoving()
          returns weather or not the banana is currently moving.
 boolean isStartedThrow()
          returns weather or not a throw has been started.
 void moveBanana(float g, float time, org.newdawn.slick.GameContainer gc)
          moves banana one step further on parabolic trajectory.
 void resetBanana()
          returns the banana instantly to its spawn position provided at construction.
 void startThrow(float betaRadian, float velocity)
          starts a throw in the given angle and with the given velocity.
 
Methods inherited from class apes.CollidableImageObject
getCollisionShape, getNormalCollisionShape, isCollidingWith, render, setPosition
 
Methods inherited from class apes.ImageObject
getName, getPosition, update
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

Banana

public Banana(java.lang.String name,
              org.newdawn.slick.Image image,
              org.newdawn.slick.geom.Vector2f position,
              org.newdawn.slick.geom.Shape collisionShape)
constructs a new banana with given arguments.

Parameters:
name -
image -
position - current actual position as well as future spawning position
collisionShape -
Method Detail

getPositionBeforSpawn

public org.newdawn.slick.geom.Vector2f getPositionBeforSpawn()
returns the last actual position before the last respawn. This will be either a position on the border of the screen or an collision element from the map.

Returns:

isStartedThrow

public boolean isStartedThrow()
returns weather or not a throw has been started.

used by the ai.

Returns:
See Also:
IEnemyAI

isMoving

public boolean isMoving()
returns weather or not the banana is currently moving.

Returns:

getSpawnPosition

public org.newdawn.slick.geom.Vector2f getSpawnPosition()
returns the position where this banana will respawn after hitting the border or a collidable object.

Returns:

resetBanana

public void resetBanana()
returns the banana instantly to its spawn position provided at construction. Also updates moving, startedThrow and positionBeforSpawn fields.


startThrow

public void startThrow(float betaRadian,
                       float velocity)
starts a throw in the given angle and with the given velocity. Sets moving and startedThrow true, resets objOnThrowParabel to (0,0), and saves the given arguments in this class.

It does not actually carry out the throw. To archive this, see moveBanana.

Parameters:
g - gravity
betaRadian - the angle in radian
velocity - the starting velocity

moveBanana

public void moveBanana(float g,
                       float time,
                       org.newdawn.slick.GameContainer gc)
moves banana one step further on parabolic trajectory. uses the provided time to calculate the logical next position of the object. If the object moves outside of the screen (provided by GameContainer) the object will be reset to its spawning position.

Parameters:
time -
gc -

getYForX

public org.newdawn.slick.geom.Path getYForX(float g,
                                            float beta,
                                            float vel,
                                            org.newdawn.slick.GameContainer gc)
creates a path representing the current parabolic trajectory. It can be printed on the screen for debug and is also used by some of the implementations of IEnemyAI.

Parameters:
beta - angle (in degrees)
vel - velocity
gc -
Returns:
the complete path this banana will fly with given vel and beta
See Also:
IEnemyAI