NetDragons Last Samurai Posters | Beck Posters
Games | Free Web Hosting | DVD | Books | Shop | Posters
Google
Name
Password
Save Password?



[-]NetDragons.com
[-]Games
 | [-]24 Hour Games
 |  | [-]Nelzan
 |  |  | [+]Capital Ships
 |  |  | [+]Light Fighters
 |  |  | [+]Medium Fighters
 |  |  | [+]Play It Now!
 |  |  | [+]Player
 |  |  | [+]Forum
 |  |  | [-]Source Code
 |  | [+]Space Frag I
 |  | [+]GNet Server
 |  | [+]About
 |  | [+]Forum
 |  | [+]License
 | [+]Cards of Tridala
 | [+]Flash Games
 | [+]Vagabond's Quest+
 | [+]Vagabond's Quest v.2
 | [+]Projects
[+]NetDragons.com Live!
[+]Reward Center
[+]Software Center
[+]Company Information
[+]Personal Services
[+]Member Directory
[+]Free E-mail
[+]Buy Cool Stuff
[+]Posters
[+]Your Privacy

Class Player


[ Source | Index | Back to Nelzan ]

class Player
extends Object
Nelzan - Handles all information dealing with the player

Controls Player Movement, shields, weapons, lives, score, painting, and collisions.


Variable Index

 o activeWeapon
 o comp
Instance of Applet, for call backs.
 o count
 o dir
 o direction
Array for storing directions.
 o fire
 o fireX
 o fireY
 o invincible
 o level
Level Player is on.
 o lives
Number of lives the player has.
 o myImages
 o myX
 o myY
 o originalX
 o originalY
 o prevX
 o prevY
 o score
Player Score.
 o shieldColor
Array of colors used for drawing Shields and weapons.
 o shields
Current Level of shields.
 o weapon
 o weaponDamage
 o weaponRange
 o weaponSpeed

Constructor Index

 o Player(Image[], int, int, Applet)
Creates a player at and an x, y location with specified images.

Method Index

 o addLife()
Addes one life to the player.
 o addShield(int)
Addes power back to the player's shields.
 o addWeapon(int)
Addes one level to a Weapon.
 o buildShieldColor()
Builds an array of shield colors for later use.
 o checkAttack(int, int, int, int, int)
Checks to see if the Enemy's weapon is hitting the player.
 o checkBounds()
Makes sure the player doesn't leave the playing area.
 o damage(int, int, int, int, int, int)
This fuction handles collisions.
 o fire()
Tells the player to fire it's weapon if it can.
 o getActiveWeapon()
Gets the number of the current weapon.
 o getWeaponLevel()
Gets the currently selected Weapons level.
 o getYMovement(int)
Function allows enemy weapons to home in on players location.
 o givePowerUp(int)
Function handles giving the player powerup's like shields, weapons, and extra lives.
 o killFire(int)
Removes a fired weapon from the array.
 o killMe()
Kills the player.
 o move(int)
Tells the player to move in direction i.
 o paint(Graphics)
Used to paint the player and weapons.
 o setActiveWeapon(int)
Sets players weapon to inputed value.
 o setMoveFalse(int)
Sets direction[i] to false.
 o setMoveTrue(int)
Sets direction[i] to true.
 o update()
Updates player and fired ammo location.

Variables

 o myImages
 private Image myImages[]
 o myX
 private int myX
 o myY
 private int myY
 o dir
 private int dir
 o prevX
 private int prevX[]
 o prevY
 private int prevY[]
 o activeWeapon
 private int activeWeapon
 o weapon
 private int weapon[]
 o weaponDamage
 private static final int weaponDamage[]
 o weaponRange
 private static final int weaponRange[]
 o weaponSpeed
 private static final int weaponSpeed[]
 o fire
 private int fire[]
 o fireX
 private int fireX[]
 o fireY
 private int fireY[]
 o count
 private int count
 o invincible
 private int invincible
 o originalX
 private int originalX
 o originalY
 private int originalY
 o score
 public int score
Player Score.

 o lives
 public int lives
Number of lives the player has.

 o shields
 public int shields
Current Level of shields.

 o level
 public int level
Level Player is on.

 o direction
 boolean direction[]
Array for storing directions.

 o shieldColor
 public Color shieldColor[]
Array of colors used for drawing Shields and weapons.

 o comp
 Applet comp
Instance of Applet, for call backs.

Constructors

 o Player
 Player(Image img[],
        int startX,
        int startY,
        Applet c)
Creates a player at and an x, y location with specified images.

Parameters:
img - Images that represent the player.
startX - Players starting X location.
startY - Players starting Y location.
c - Instance of an Applet, for call backs.

Methods

 o paint
 public void paint(Graphics g)
Used to paint the player and weapons.

Parameters:
g - Graphics to paint to.
 o update
 public void update()
Updates player and fired ammo location.

 o getActiveWeapon
 public int getActiveWeapon()
Gets the number of the current weapon.

Returns:
an int based on the selected weapon.
 o getWeaponLevel
 public int getWeaponLevel()
Gets the currently selected Weapons level.

Returns:
an int based on the selected weapon's level.
 o setActiveWeapon
 public void setActiveWeapon(int i)
Sets players weapon to inputed value. It only does this if the level of the weapon is greater than 0.

Parameters:
i - Weapon number to set to.
 o fire
 public void fire()
Tells the player to fire it's weapon if it can.

 o setMoveTrue
 public void setMoveTrue(int i)
Sets direction[i] to true. This is used so the player will continually move in the selected direction until setMoveFalse(i) is called.

Parameters:
i - The direction to set.
See Also:
setMoveFalse
 o setMoveFalse
 public void setMoveFalse(int i)
Sets direction[i] to false. This is used so the player will stop moving in the selected direction.

Parameters:
i - The direction to set.
 o move
 public void move(int i)
Tells the player to move in direction i.

Parameters:
i - The Direction to move.
 o getYMovement
 public int getYMovement(int y)
Function allows enemy weapons to home in on players location. Depending on the weapons location, the function will return a positive, negative, or zero.

Parameters:
y - Fired weapons y location.
Returns:
2 if y > player Y, -2 otherwise.
 o damage
 public int damage(int x,
                   int y,
                   int w,
                   int h,
                   int t,
                   int d)
This fuction handles collisions. If the player or the players' weapons hit the an enemy object, this function will return the damage that is done, and cause damage when needed.

Parameters:
x - Enemy x location.
y - Enemy y location.
w - Enemy's width.
h - Enemy's height.
t - Enemy's Type.
d - Enemy's Shield level.
Returns:
WeaponDamage if getting hit by weapon, d if coliding with player, 0 otherwise.
 o checkAttack
 public boolean checkAttack(int x,
                            int y,
                            int w,
                            int h,
                            int d)
Checks to see if the Enemy's weapon is hitting the player.

Parameters:
x - Enemy x location.
y - Enemy y location.
w - Enemy's width.
h - Enemy's height.
d - How much damage the weapon will cause.
Returns:
true if the weapon hits, false otherwise.
 o givePowerUp
 private void givePowerUp(int t)
Function handles giving the player powerup's like shields, weapons, and extra lives.

Parameters:
i - Type of power up to give.
 o addShield
 private void addShield(int a)
Addes power back to the player's shields. Shields cannot exceed 200, so proper checks are in place.

Parameters:
a - Value to add to current shield levels.
 o addWeapon
 private void addWeapon(int i)
Addes one level to a Weapon. Weapons cannot exceed a level of 10, so proper checks are in place.

Parameters:
i - Weapon number to add 1 to.
 o addLife
 private void addLife()
Addes one life to the player. Lives cannot exceed 7, so proper checks are in place.

 o checkBounds
 private boolean checkBounds()
Makes sure the player doesn't leave the playing area.

Returns:
true if the player is out of bounds, false otherwise.
 o killFire
 private void killFire(int w)
Removes a fired weapon from the array. Because weapons can move at different speeds this is a little more complex, but it gets the job done.

Parameters:
w - Weapon to kill.
 o killMe
 public void killMe()
Kills the player. Causes them to move back to the original starting x, y, and will give them about 2 second "free" play.

 o buildShieldColor
 private void buildShieldColor()
Builds an array of shield colors for later use. This Array and function is designed to save speed at runtime.

ND: VQ+, Mail, Shop, Free Web Hosting CMCSA Stock Chart

Free Stock Charts
Copyrighted �, 2000, 2001 by NetDragons.com
Last Updated Saturday, December 5, 1998 - 21:17 EST