Constructor
new module:PlayerCommon(name, hp, spriteName, floor)
Parameters:
Name | Type | Description |
---|---|---|
name |
string | The name of the player. Should be the same as user.username |
hp |
int | The player's hitpoints |
spriteName |
string | The name of the sprite for this player. |
floor |
floor | The floor this player is on. |
- Source:
Methods
_getOrientation(p, q, r)
Determine the orientation of three points
Parameters:
Name | Type | Description |
---|---|---|
p |
||
q |
||
r |
- Source:
_intersects(line1p1, line1p2, line2p1, line2p2)
Check if two points intersect
Parameters:
Name | Type | Description |
---|---|---|
line1p1 |
||
line1p2 |
||
line2p1 |
||
line2p2 |
- Source:
_isHittingRect()
Check if the attack line is hitting a monster
- Source:
_isOnLine(point1, point2, iPoint)
Check if iPoint is on the line formed by point1 and point2
Parameters:
Name | Type | Description |
---|---|---|
point1 |
||
point2 |
||
iPoint |
- Source:
attack(monster)
Player attacks monster
Parameters:
Name | Type | Description |
---|---|---|
monster |
* | The monster to attack |
- Source:
beAttacked(hp)
Monster attacks player
Parameters:
Name | Type | Description |
---|---|---|
hp |
* | health points that the player's health decrements by |
- Source:
collisionEntities() → {boolean}
Checks to see if there's a monster colliding with this monster.
Compares corners of each sprite to do so.
- Source:
Returns:
- Type
- boolean
dropConfirmed()
Drop all confirmed frames
- Source:
getHp() → {int}
Get the hp of this player
- Source:
Returns:
This player's hp.
- Type
- int
getName() → {String}
Get the name of the player
- Source:
Returns:
Name of this player.
- Type
- String
getPosition() → {object}
Get the position of the player.
- Source:
Returns:
- Type
- object
getVelocity() → {object}
Get the velocity of the player
- Source:
Returns:
{ vx: int, vy: int }
- Type
- object
handleKeyPress(type, e)
Update the player's velocity from key input.
Parameters:
Name | Type | Description |
---|---|---|
type |
string | Either down or up |
e |
event | User's keyboard input, |
- Source:
handleMouse()
Handle mouse positions
- Source:
move()
Update the player's position based off the player's velocity
- Source:
setCoordinates(x, y)
Set coordinates for this player
Parameters:
Name | Type | Description |
---|---|---|
x |
int | new x-coordinate, |
y |
int | new y-coordinate |
- Source:
spriteIsOnMap() → {boolean}
Checks to see if whole sprite is on the map. (Same as monster class)
- Source:
Returns:
- Type
- boolean