Skip to content
This repository


Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP

Lightweight library for HTML5 2D Game Development

branch: master



Pentagine is a lightweight Javascript library for HTML5 2D Game Development that renders to <canvas>. For now, it consists of a State Machine, a Sprite class to load and draw images and some keyboard input functions. Soon, I expect it to have much more.


Clone pentagine with git clone and then open examples/index.html for a list of examples.

Here's a small example of all the Javascript code necessary to draw a ball and make it movable:

function PlayState() {
  this.setup = function() {
    this.ball = new Sprite("ball.png", 100, 50);

  this.update = function() {
    if (isDown("up"))
    else if (isDown("down"))
    else if (isDown("left"))
    else if (isDown("right"))

  this.draw = function() {


   If desiredFPS is not declared, the game will run as fast as
   possible, and on any State, you can use 'this.dt' to get the
   delta time between two ticks and use it to make movement
   smooth. If desiredFPS is declared, this.dt also works.
desiredFPS = 60;

/* Prevents the following keys to be sent to the web page. */
preventKeys("down", "right", "left", "right", "space");

switchState(new PlayState());

A "real-life" example of a game that uses Pentagine is Multitaskor, a game I created for Ludum Dare 27.


Pentagine is licensed under the MIT License.


I'd like to thank to ippa because Pentagine is inspired on his HTML5 Game Development library - jaws. I also used some of his code, but this is not a fork, the two libraries are quite different.

Pentagine also uses stats.js, a great monitor for HTML5 performance. It was made by mrdoob, who is credited on the LICENSE.

Something went wrong with that request. Please try again.