Skip to content

treydavis/canvas-node-tree

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

5 Commits
 
 
 
 
 
 

Repository files navigation

#canvas-node-tree

This project is intended to be the simplest possible 2D game engine for modern browsers using the canvas element.

###NodePrototype The key object is the NodePrototype. You create a tree of nodes that are rendered on every frame. The nodes have their own nested transformations, allowing for convenient organization of the scene.

var sprite = {
    skewX: 0.1,
    scaleX: 0.3, scaleY: 0.3,
    update: function(delta) {
        this.x += 6*delta
    },
    draw: function(context) {
        context.drawImage(img, 0, 0)
    }
}
sprite.__proto__ = NodePrototype

On each frame, update then draw are called. update receives a delta in seconds since the last frame. draw receives a CanvasRenderingContext2D object after transformations have been applied. Above is an example of a basic sprite object.

About

The simplest possible 2D game engine for <canvas>.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published