Skip to content

giladgray/rocket-engine

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

92 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Rocket Engine Build Status

A little game engine that'll take you over the moon.

Development

  1. npm install
  2. gulp watch to lint and test ☕

Usage

Rocket = require 'rocket-engine'

rocket = new Rocket

# 1. define components as functions that assign values...
rocket.component 'position', (cmp, options) ->
  cmp = {x: options.x ? 0, y: options.y ? 0}
# ...or as default value objects
rocket.component 'velocity', {x: 0, y: 0}

# 2. define systems that operate on keys with specific components
rocket.systemForEach 'move',
  # required components for a key
  ['position', 'velocity'],
  # function to call for each key that has all components
  (rocket, key, position, velocity) ->
    position.x += velocity.x
    position.y += velocity.y

# 3. add keys that contain components
rocket.key {
  spaceship : true # a label, for filtering
  velocity  : null # use default component values
  position  : {x: WIDTH / 2, y: HEIGHT / 2}
}

Advanced Systems Design

Data Components