A simple and flexible HTML5 and JavaScript powered game engine.
View Project on GitHub Download Pixel.js (v0.9b)
Represents a player that can be controlled using the directional keys on a keyboard.
Name | Description |
---|---|
allowDiagonalMovement | A boolean value indicating whether to allow diagonal movement. |
asset | The Asset that is used to give a visual representation of the entity. (Inherited from Entity.) |
canMoveDown | A boolean value indicating whether the entity can be moved downards. (Inherited from Entity.) |
canMoveLeft | A boolean value indicating whether the entity can be moved to the left. (Inherited from Entity.) |
canMoveRight | A boolean value indicating whether the entity can be moved to the right. (Inherited from Entity.) |
canMoveUp | A boolean value indicating whether the entity can be moved upwards. (Inherited from Entity.) |
direction | The Direction the player is facing. |
isAnimatedSprite | A boolean value indicating whether the asset assigned to the player is an AnimatedSprite. |
isCollidable | A boolean value indicating whether the entity can collide with other collidable entities. (Inherited from Entity.) |
layer | The Layer that the entity is registered to. (Inherited from Entity.) |
pos | The position of the entity on screen relative to the top-left corner of the scene. (Inherited from Entity.) |
size | The size of the entity. (Inherited from Entity.) |
velocity | The velocity at which the entity moves. (Inherited from Entity.) |
visible | A boolean value indicating whether the entity is visible. (Inherited from Entity.) |
Name | Description |
---|---|
addToLayer | Adds the entity to the collection of registered entities on a Layer. (Inherited from Entity.) |
collidesWith | Checks if the entity collides with another entity. (Inherited from Entity.) |
draw | Calls the draw method of the assigned Asset. (Inherited from Entity.) |
moveDown | Moves the entity down based on the velocity of the entity and the deltaTime since the last update. (Inherited from Entity.) |
moveLeft | Moves the entity left based on the velocity of the entity and the deltaTime since the last update. (Inherited from Entity.) |
moveRight | Moves the entity right based on the velocity of the entity and the deltaTime since the last update. (Inherited from Entity.) |
moveUp | Moves the entity up based on the velocity of the entity and the deltaTime since the last update. (Inherited from Entity.) |
onCollide | The function to be called when the entity has collided with another entity. (Inherited from Entity.) |
update | An abstract method with the purpose of updating the entity's state. (Inherited from Entity.) |
When using this class with an AnimatedSprite, the sprite sheet should contain the character frames for each direction in the same format as the sprite sheet below:
Google Chrome, Mozilla FireFox, Internet Explorer 9+, Opera, Safari.