|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectapes.AbstractEnemyAI
public abstract class AbstractEnemyAI
An abstract implementation of the IEnemyAI interface. If executeNextMove is called, it checks if the banana is still moving, or if a throw was already started. If so it returns immediately. Otherwise, it checks weather or not it still needs to think about its next move. If so, it will again do nothing. If it is called and does know what it wants to to, it calls the calculateBeta and calculateVelocity methods (which must be implemented in a sub-class) and starts a throw with the provided values.
Currently, it is assumed, that the ai stands to the right of the player. If this is not desired, the MIN and MAX values in this code must be changed.
Field Summary | |
---|---|
protected int |
currentThinking
current thinking time. |
protected org.newdawn.slick.GameContainer |
gc
|
protected BlockMap |
map
|
protected static float |
MAXBETA
maximal allowed beta. |
protected int |
MAXTHINKINGTIME
minimal thinking time the ai should have. |
protected static float |
MAXVELOCITY
maximal allowed velocity. |
protected static float |
MINBETA
minimal allowed beta. |
protected int |
MINTHINKINGTIME
maximal thinking time the ai should have. |
protected static float |
MINVELOCITY
minimal allowed velocity. |
Constructor Summary | |
---|---|
AbstractEnemyAI(BlockMap map)
constructs a new ai that controlls the given banana. |
Method Summary | |
---|---|
abstract void |
calculateVelocityBeta()
calculates angles which will be returned by getBeta and getVelocity. |
void |
executeNextMove(float time,
org.newdawn.slick.GameContainer gc)
if the banana is not moving, it will check if it wants to make a new throw. |
abstract float |
getBeta()
returns an angle that should be used in a throw. |
abstract float |
getVelocity()
returns a velocity that should be used in a throw. |
protected static int |
randomBetween(int start,
int end)
returns a random integer in between start and end. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
protected int MAXTHINKINGTIME
protected int MINTHINKINGTIME
protected static final float MINVELOCITY
protected static final float MINBETA
protected static final float MAXVELOCITY
protected static final float MAXBETA
protected int currentThinking
protected org.newdawn.slick.GameContainer gc
protected BlockMap map
Constructor Detail |
---|
public AbstractEnemyAI(BlockMap map)
banana
- Method Detail |
---|
public final void executeNextMove(float time, org.newdawn.slick.GameContainer gc)
executeNextMove
in interface IEnemyAI
time
- gc
- protected static int randomBetween(int start, int end)
start
- end
-
public abstract void calculateVelocityBeta()
public abstract float getBeta()
public abstract float getVelocity()
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |