group1.model.gameobject
Class Jeff

java.lang.Object
  extended by group1.model.gameobject.GameObj
      extended by group1.model.gameobject.LivingObj
          extended by group1.model.gameobject.Jeff

public class Jeff
extends LivingObj

Jeff, the hero of the game. A unique GameObj that determines its movement entirely on user input.


Field Summary
 
Fields inherited from class group1.model.gameobject.LivingObj
contactDamageMultiplier, curr_hp, fireDamageMultiplier, katanaDamageMultiplier, laserDamageMultiplier, max_hp, tomahawkDamageMultiplier, VALID_WEAPON_CODES
 
Fields inherited from class group1.model.gameobject.GameObj
acceleration, ENEMY_TEAM, GRID_SPACE_SIZE, id, isMovable, JEFF_TEAM, NO_TEAM, regions, shape, velocity
 
Constructor Summary
Jeff()
          Default constructor.
Jeff(double x, double y, PictureList p)
          Constructor.
 
Method Summary
 void changeWeapon(char nextWeapon)
          Change the weapon to the specified one.
 void fillHP()
          Fill Jeff's HP.
 XYPair move(Environment env)
          Movement function that should be called by the Enviroment at each time click.
 void setToAttack(boolean attack)
          Set Jeff to attack.
 void setToChangeWeapons(boolean change)
          Set Jeff to change his weapon.
 void setToDuck(boolean duck)
          Set Jeff to duck.
 void setToExtendJump(boolean extend)
          Set Jeff to extend his jump.
 void setToJump(boolean jump)
          Set Jeff to jump.
 void setToMove(Direction direction)
          Set Jeff to move left, right, or neither.
 void setToMoveOnLadder(LadderDirection direction)
          Set Jeff to move up a ladder, down a ladder, or neither.
 void setToRun(boolean run)
          Set Jeff to run.
 
Methods inherited from class group1.model.gameobject.LivingObj
die, getCurrentWeapon, getCurrHP, getMaxHP, hasFireball, hasKatana, hasLaser, hasTomahawk, hasWeapon, hasWeaponIndex, takeDamage
 
Methods inherited from class group1.model.gameobject.GameObj
addRegion, addRegion, equals, getAcceleration, getAccelerationX, getAccelerationY, getFilm, getFilm, getHeight, getID, getNumRegions, getPictureList, getPosition, getPositionX, getPositionY, getRectangle, getRegion, getState, getTeam, getVelocity, getVelocityX, getVelocityY, getWidth, intersectRegions, isMovable, isSameState, makeRegions, makeSolid, makeSolidTop, setAcceleration, setAcceleration, setAccelerationX, setAccelerationY, setID, setPictureList, setPosition, setPosition, setPositionX, setPositionY, setRectangle, setSize, setState, setTeam, setVelocity, setVelocity, setVelocityX, setVelocityY, stopHorizontal, stopVertical
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

Jeff

public Jeff()
Default constructor. Can be used by Game, for instance.


Jeff

public Jeff(double x,
            double y,
            PictureList p)
Constructor.

Parameters:
x - The x-coordinate of the position.
y - The y-coordinate of the position.
Method Detail

move

public XYPair move(Environment env)
Movement function that should be called by the Enviroment at each time click. This returns the "expected" velocity of this object. It's up to the environment to check hit detection of the various objects, and report back with the correct values. Jeff's case is easily the most complex. We figure out all movement from the keyboard inputs. Note that we freely change the current acceleration, but we only calculate and return temporary velocities.

Specified by:
move in class GameObj
Parameters:
env - The environment this object is moving in.
Returns:
An pair of 2 values: the proposed horizontal velocity, and the proposed vertical velocity.

changeWeapon

public void changeWeapon(char nextWeapon)
Change the weapon to the specified one. Prints an error message if the values don't make sense.

Overrides:
changeWeapon in class LivingObj
Parameters:
nextWeapon - A value representing the next weapon. Should be 'k', 'f', 'l', 't', or ' '.

setToJump

public void setToJump(boolean jump)
Set Jeff to jump. (Note that this only lasts one time click. Afterwards, we set to false.)

Parameters:
jump - Whether or not Jeff should be trying to jump.

setToExtendJump

public void setToExtendJump(boolean extend)
Set Jeff to extend his jump.

Parameters:
extend - Whether or not Jeff should be trying to extend his jump.

setToAttack

public void setToAttack(boolean attack)
Set Jeff to attack. (Note that this only lasts one time click. Afterwards, we set to false.)

Parameters:
attack - Whether or not Jeff should be trying to attack.

setToRun

public void setToRun(boolean run)
Set Jeff to run.

Parameters:
run - Whether or not Jeff should be trying to run.

setToChangeWeapons

public void setToChangeWeapons(boolean change)
Set Jeff to change his weapon. (Note that this only lasts one time click. Afterwards, we set to false.)

Parameters:
run - Whether or not Jeff should be trying to change his weapon.

setToDuck

public void setToDuck(boolean duck)
Set Jeff to duck.

Parameters:
run - Whether or not Jeff should be trying to duck.

setToMove

public void setToMove(Direction direction)
Set Jeff to move left, right, or neither.

Parameters:
direction - The direction Jeff should move.

setToMoveOnLadder

public void setToMoveOnLadder(LadderDirection direction)
Set Jeff to move up a ladder, down a ladder, or neither.

Parameters:
direction - The direction Jeff should move on any ladders he happens to be near.

fillHP

public void fillHP()
Fill Jeff's HP. Handy when starting a level.