Class republikensoft.Player
All Packages  Class Hierarchy  This Package  Previous  Next  Index

Class republikensoft.Player

java.lang.Object
   |
   +----republikensoft.Moving
           |
           +----republikensoft.Player

public class Player
extends Moving
This class controls the players.

Variable Index

 o magSize
How many bullets each player has.
 o otherPlayer
Used to be able to give the other player points when hit by a bullet and to find out which player died.

Constructor Index

 o Player(Image[], int[], boolean)

Method Index

 o die()
This method is called when the player been hit by a bullet.
 o draw(Graphics)
Draws the player.
 o drawBullets(Graphics)
Draws the players moving bullets.
 o getAmmo()
 o getHit()
 o shoot()
Fire the gun.
 o update()
Updates the player and his bullets.
 o userInput(int, boolean)
Acts on user input if the player doesn't collide with something.

Variables

 o magSize
  public final static int magSize
How many bullets each player has. Currently set to 6, and will always be.
 o otherPlayer
  public int otherPlayer
Used to be able to give the other player points when hit by a bullet and to find out which player died.

Constructors

 o Player
  public Player(Image f[],
                int props[],
                boolean fr)
Parameters:
f - Player frames.
props - Contains a lot of different values that initialises the player. See the Player.java and Gunfighter.java for more details.
fr - Determines if the player starts facing right or not. Also used to determine which player the player is.

Methods

 o die
  public void die()
This method is called when the player been hit by a bullet. Makes the player scream. Updates the score too.
 o draw
  public void draw(Graphics g)
Draws the player. Uncomment the commented lines if you would like to see how the walk and hit rectangles work.
Overrides:
draw in class Moving
 o drawBullets
  public void drawBullets(Graphics g)
Draws the players moving bullets.
 o getAmmo
  public int getAmmo()
Returns:
How many bullets the player has left.
See Also:
drawStatus
 o getHit
  public Rectangle getHit()
Returns:
The rectangle where it's fatal to get a bullet.
 o shoot
  public void shoot()
Fire the gun. But only if we have ammo and we're able.
 o update
  public void update()
Updates the player and his bullets.
Overrides:
update in class Moving
 o userInput
  public void userInput(int key,
                        boolean key_pressed)
Acts on user input if the player doesn't collide with something.

All Packages  Class Hierarchy  This Package  Previous  Next  Index