A simple and flexible HTML5 and JavaScript powered game engine.
View Project on GitHub Download Pixel.js (v0.9b)
Represents a generic game entity that can be drawn to the game scene.
| Name | Description |
|---|---|
| asset | The Asset that is used to give a visual representation of the entity. |
| canMoveDown | A boolean value indicating whether the entity can be moved downards. |
| canMoveLeft | A boolean value indicating whether the entity can be moved to the left. |
| canMoveRight | A boolean value indicating whether the entity can be moved to the right. |
| canMoveUp | A boolean value indicating whether the entity can be moved upwards. |
| dragButton | The Mouse Button to be used to drag the entity. |
| isClickable | A boolean value indicating whether the entity should react to being clicked by the mouse. |
| isCollidable | A boolean value indicating whether the entity can collide with other collidable entities. |
| isDraggable | A boolean value indicating whether the entity can be dragged by the mouse. |
| isDragging | A boolean value indicating whether the entity is being dragged. |
| layer | The Layer that the entity is registered to. |
| opacity | A decimal value between 0 and 1 representing the opacity of the entity; 0 being completely opaque and 1 being completely visible. |
| pos | The position of the entity on screen relative to the top-left corner of the scene. |
| size | The size of the entity. |
| velocity | The velocity at which the entity moves. |
| visible | A boolean value indicating whether the entity is visible. |
| Name | Description |
|---|---|
| addToLayer | Adds the entity to the collection of registered entities on a Layer. |
| collidesWith | Checks if the entity collides with another entity. |
| dispose | Removes all internal references to the entity allowing for it to be destroyed by the owning application and collected by the garbage collector. |
| draw | Calls the draw method of the assigned Asset. |
| fadeTo | Fades the entity to a new opacity level. |
| moveDown | Moves the entity down based on the velocity of the entity and the deltaTime since the last update. |
| moveLeft | Moves the entity left based on the velocity of the entity and the deltaTime since the last update. |
| moveRight | Moves the entity right based on the velocity of the entity and the deltaTime since the last update. |
| moveTo | Moves the entity to a new position. |
| moveUp | Moves the entity up based on the velocity of the entity and the deltaTime since the last update. |
| onCollide | Registers the callback to be invoked when the entity has collided with another entity. |
| onDrag | Registers the callback to be invoked when the entity is being dragged by the mouse. |
| onDrop | Registers the callback to be invoked when the entity has stopped being dragged. |
| onMouseDown | Registers the callback to be invoked when a mouse button is pressed down on the entity. |
| onMouseHover | Registers the callback to be invoked when the mouse is hovered over the entity. |
| onMouseUp | Registers the callback to be invoked when a mouse button is released after being pressed down on an entity. |
| update | An abstract method with the purpose of updating the entity's state. |
In order to make the most of the Pixel.js engine, all drawable game components should be subclasses of the Entity class. See the Player Class for a practical example of this.
Google Chrome, Mozilla FireFox, Internet Explorer 9+, Opera, Safari.