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.
-
magSize
- How many bullets each player has.
-
otherPlayer
- Used to be able to give the other player points
when hit by a bullet and to find out which player died.
-
Player(Image[], int[], boolean)
-
-
die()
- This method is called when the player been hit by a bullet.
-
draw(Graphics)
- Draws the player.
-
drawBullets(Graphics)
- Draws the players moving bullets.
-
getAmmo()
-
-
getHit()
-
-
shoot()
- Fire the gun.
-
update()
- Updates the player and his bullets.
-
userInput(int, boolean)
- Acts on user input if the player doesn't collide with something.
magSize
public final static int magSize
- How many bullets each player has.
Currently set to 6, and will always be.
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.
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.
die
public void die()
- This method is called when the player been hit by a bullet.
Makes the player scream. Updates the score too.
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
drawBullets
public void drawBullets(Graphics g)
- Draws the players moving bullets.
getAmmo
public int getAmmo()
- Returns:
- How many bullets the player has left.
- See Also:
- drawStatus
getHit
public Rectangle getHit()
- Returns:
- The rectangle where it's fatal to get a bullet.
shoot
public void shoot()
- Fire the gun.
But only if we have ammo and we're able.
update
public void update()
- Updates the player and his bullets.
- Overrides:
- update in class Moving
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