Skip to content

A lightweight game framework, utilizing the Entity-Component-System architecture

License

Notifications You must be signed in to change notification settings

RodRitter/TerraJS

Repository files navigation

TerraJS uses the Entity-Component-System (ECS) pattern to create lightweight games.

What is ECS?

Entity - This is essentially an 'object' or thing within your game's world. (Enemy, Bullets, etc)

Component - Components are attached to Entities and provide a lego-like approach to assigning behavior to an Entity. (Health, Position, etc)

System - This is where you logic will live. A System will control all Entities that pertain to itself. (BulletSystem, EnemySystem, etc)

Documentation

You can find the documentation here

Setup

Include the TerraJS library script

<script src="path/to/terra.js"></script>

Usage

Create game instance

var Game = new Terra.Game(500, 300);

Create a Component

var position = new Terra.Component('Position', {x: 0, y: 0});
var attack = new Terra.Component('Attack', {damage: 50});

Create an Entity

var monsterEntity = new Terra.Entity('Monster', [position, attack]);

Create a System

var monsterSystem = new Terra.System('MonsterSystem', monsterSystemStart, monsterSystemUpdate);

function monsterSystemStart(system) {} // Happens on startup
function monsterSystemUpdate(system, time) {} // Happens every frame

Start the Game

Game.onStart = function() {} // Happens on game start
Game.onUpdate = function() {} // Happens every frame of the game.

Game.start();

Building & Contributing

Once you make changes to the code, you need to build

npm run webpack

Please make sure to write tests for any new functionality (test/test.js). You can run tests with the command below.

npm test

You can run webpack, tests & documentation all together

npm run build

About

A lightweight game framework, utilizing the Entity-Component-System architecture

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published