A Mediocre JavaScript Game Engine
Last updated 6 years ago by talon .
The Artistic License 2.0 · Repository · Bugs · Original npm · Tarball · package.json
$ cnpm install nicolas 
SYNC missed versions from official npm registry.

Nicolas Engine

:boom: A mediocre JavaScript game engine. :boom:

As seen in such hits as:


$ npm install nicolas



  • Require the engine.
  • Clone the engine
  • Add Entities
  • Initialize with a canvas id

Or as I like to remember it: RCAEI

var engine = require('nicolas')

var Game = Object.create(engine, {
  debug: {
    value: true // Will talk about itself in the JS console.


 * This must be the value of the `id` attribute of the `canvas` on which you
 * want the game to display. Not a class or jQuery object or anything else.


aliases: addEntities, updateEntity, updateEntities

Takes an entity or an array of entities and adds an id to it then pushes it to onto the engine.entities array!



Entities are JavaScript objects with all the properties described in core/entity :alien:


This is the mind of the entity. What is it thinking? What is it doing? What are its passions and motivations? You could implement movement in this method


This is the physical representation of the entity. Here is where you use the HTML5 canvas API to draw your entity. Pro Tip: Use the properties defined in the entities .update method to display your entity in a more dynamic manner.


An object with x and y properties.

var player = {
  pos: {x: 0, y: 0}
  size: {w: 5, h: 5}
  update: function() {
     * The player can walk!
    if (engine.controls.isDown(engine.controls.keys.left)) {
      this.pos.x -= this.speed
    else if (engine.controls.isDown(engine.controls.keys.right)) {
      this.pos.x += this.speed
    else if (engine.controls.isDown(engine.controls.keys.up)) {
      this.pos.y -= this.speed
    else if (engine.controls.isDown(engine.controls.keys.down)) {
      this.pos.y += this.speed
  draw: function() {
     * The player has a physical representation. Let's judge him for it.
      this.pos.x,  // x
      this.pos.y,  // y
      this.size.w, // width
      this.size.h  // height



Refer to above sample code of an entity (specifically the .draw() method to see how this can be useful.


This method is useful for checking if a key is down or not.


This is a dictionary of keys mapped to human words so that it's easier to read code involving keycodes. If you were so inclined you could change this object to fit the needs of your game. I would document all the mappings here but just run console.log(engine.controls.keys).

Collision Detection


.areColliding(entityA, entityB)

Pass in two entities and recieve true if they're colliding otherwise, false.

var entityCollisions = engine.entities.filter(function (entity) {
  return engine.collisin.areColliding(entity, player)

if (entityCollisions) {
  entityCollisions.forEach(function(entity) {
    console.log('player is colliding with', entity)
} else {
  console.log('player is not colliding with anything')


.on(namespace, fn)

perform the fn when events in the namespace happen.


used internally to emit events (call all the functions attached to a namespace

below is a list of events and what they pass to the functions subscribed to them


  • tick: engine

and so much more

later anyway

Bugs, Requests and Questions

:two_hearts: File 'em

Pull Requests

welcome. :man:



Hit me up on Twitter @legittalon

We can talk about this or life or whatever really.

Current Tags

  • 2.0.0-alpha                                ...           latest (6 years ago)

2 Versions

  • 2.0.0-alpha                                ...           6 years ago
  • 1.0.1-alpha                                ...           6 years ago
Maintainers (1)
Today 0
This Week 0
This Month 0
Last Day 0
Last Week 0
Last Month 0
Dependencies (3)
Dev Dependencies (1)
Dependents (0)

Copyright 2014 - 2016 © |