# laro

> Yet another Entity-Component-System game micro-framework in JavaScript. Only this time, written in ES6.

Latest version **0.0.5** (published 2016-05-29) · MIT license · 0 weekly downloads

## Install

```sh
npm install laro
pnpm add laro
yarn add laro
bun add laro
```

## Health

**Score 15/100 (F)** — status: abandoned.

Positive: no vulnerabilities.

Warnings: low downloads; no types; no esm support; pre 1.0.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 0.0.5 |
| Published | 2016-05-29 |
| First published | 2016-05-25 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 0 |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 6 |
| Author | James O. Florentino |
| Maintainers | jamesflorentino |

## Links

- npm: https://www.npmjs.com/package/laro
- Repository: https://github.com/jamesflorentino/laro
- Homepage: https://github.com/jamesflorentino/laro#readme
- Issues: https://github.com/jamesflorentino/laro/issues
- npm.io page: https://npm.io/package/laro

## Recent versions

- 0.0.5 (latest) — 2016-05-29
- 0.0.4 — 2016-05-27
- 0.0.3 — 2016-05-25
- 0.0.2 — 2016-05-25
- 0.0.1 — 2016-05-25

## README

> WARNING: This framework is currently under development.

# laro.js

Yet another Entity-Component-System game micro-framework in JavaScript. Only
this time, written in ES6. It also auto-generates a documentation page of your
code if you write them in jsdoc syntax in your actual code.

Goals
=====

- To provide a sustainable design pattern for writing large, complex and ambitious HTML5 JavaScript games
- To be easy to integrate with other JavaScript frameworks.
- To provide a deterministic architecture that can be used for server-side logic

Installation
============

- `npm install laro --save`

Basic Usaage
============

```javascript
import laro from 'laro'
import StatsComponent from './components/StatsComponent'
import CharacterComponent from './components/CharacterComponent'
import CombatComponent from './components/CombatComponent'
import CombatSystem from './systems/CombatSystem'

/*
  A world object ties the entities and systems together
 */
let world = new laro.World()

/*
  We register pre-defined component classes in our game world to be instantiated
  and used later by generated entities.
 */
world.components
  .register(StatsComponent)
  .register(CharacterComponent)
  .register(CombatComponent)

/*
  A System object handles different kinds of logic.
 */
world.register(CombatSystem, [ StatsComponent, CombatComponent ])

/*
  Creating an entity can be configured from a .json file.

  file: ./data/entities/hero.json

  {
    "stats": { "hp": 100, "atk": 100, "def": 30 }
    "character": { "name": "Hitomi", "type": "hero"},
    "player": true,
    "combat": true
  }

  file: ./data/entities/monster.json

  {
    "stats": { "hp": 100, "atk": 10, "def": 0 }
    "character": { "name": "Bakemono", "type": "hero"},
    "combat": true
  }
 */

let hero = world.addEntity(require('./data/entities/hero.json'))
let monster = world.addEntity(require('./data/entities/monster.json'))

/*
  You can expose and call functions of your component.
 */

hero.components.combat.setTarget(monster)

/*
  Updates are ticks that advances the frame of the game. All system logic
  are executed.
 */

world.update(1)

console.log(monster.components.stats.attribute.health.isEmpty()) // => true
console.log(monster.components.character.name) // => Bakemono
console.log(monster.components.character.type) // => monster
```

Design Patterns
===============

- Components are data. Extend `laro.Component` as your base class
- Systems are the logic. Extend `laro.System` as yoru base class
- Entities are just component containers with a basic API for attaching and detaching them.

Acknowledgment
==============

James Florentino

License
=======

MIT License
Copyright (c) 2016 James Florentino

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

---
_Source: https://npm.io/package/laro · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
