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, ourFacingDirection, tomahawkDamageMultiplier, VALID_WEAPON_CODES
 
Fields inherited from class group1.model.gameobject.GameObj
acceleration, ENEMY_TEAM, GRID_SPACE_SIZE, id, isMovable, JEFF_TEAM, myState, NO_TEAM, regions, shape, THICKNESS, velocity
 
Constructor Summary
Jeff()
          Default constructor.
Jeff(double x, double y, PictureList p)
          Constructor.
Jeff(PictureList p)
          Constructor with no position values.
 
Method Summary
 void changeWeapon(char nextWeapon)
          Change the weapon to the specified one.
 void fillHP()
          Fill Jeff's HP.
 void giveDamage()
          Makes Jeff bounce off of enemies.
 void giveHP(int hp)
          Give Jeff HP.
 XYPair move(Environment env)
          Movement function that should be called by the Enviroment at each time click.
 void resetMovement()
          Reset Jeff's movements, to begin a new level cleanly.
 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.
 boolean shouldBeBlinking()
          Whether or not Jeff is invincible and should be "blinking." (Overrides GameObj template method.)
 int takeDamage(double damage, char damageType)
          Calculations for Jeff taking damage.
 
Methods inherited from class group1.model.gameobject.LivingObj
changeDirectionFacing, decrementInvincibilityCounter, die, facingWhichDirection, getCurrentWeapon, getCurrHP, getMaxHP, hasFireball, hasKatana, hasLaser, hasTomahawk, hasWeapon, hasWeaponIndex, isInvincible, setInvincibilityPeriod, setVulnerable
 
Methods inherited from class group1.model.gameobject.GameObj
addRegion, addRegion, equals, getAcceleration, getAccelerationX, getAccelerationY, getFilm, getHeight, getID, getNumRegions, getPictureList, getPosition, getPositionX, getPositionY, getRectangle, getRegion, getState, getTeam, getVelocity, getVelocityX, getVelocityY, getWidth, intersectRegions, isMovable, isSameState, makeBottomSideRegion, makeLeftSideRegion, makeRegions, makeRightSideRegion, makeSolid, makeSolidTop, makeTopSideRegion, playAudio, resizeBottomRegion, resizeLeftRegion, resizeRightRegion, resizeTopRegion, 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.


Jeff

public Jeff(PictureList p)
Constructor with no position values. 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

giveDamage

public void giveDamage()
Makes Jeff bounce off of enemies. Also cues audio and a score increase. (Overrides GameObj template function.)

Overrides:
giveDamage in class GameObj

takeDamage

public int takeDamage(double damage,
                      char damageType)
Calculations for Jeff taking damage. If Jeff actually takes damage, this produces a sound. (Overrides and calls LivingObj function to actually take the damage.)

Overrides:
takeDamage in class LivingObj
Parameters:
damage - The amount of damage to inflict.
damageType - The type of damage.
Returns:
The amount of damage taken.
See Also:
LivingObj

shouldBeBlinking

public boolean shouldBeBlinking()
Whether or not Jeff is invincible and should be "blinking." (Overrides GameObj template method.)

Overrides:
shouldBeBlinking in class GameObj
Returns:
true if this GameObj should be blinking, false if not.

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:
change - Whether or not Jeff should be trying to change his weapon.

setToDuck

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

Parameters:
duck - 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. Possibly handy when starting a level.


giveHP

public void giveHP(int hp)
Give Jeff HP. Useful for health-restoring items.

Parameters:
hp - The amount of HP to restore.

resetMovement

public void resetMovement()
Reset Jeff's movements, to begin a new level cleanly.