Skip to content
This repository has been archived by the owner on Jun 1, 2022. It is now read-only.

Commit

Permalink
Merge pull request #197 from MozillaReality/update-docs
Browse files Browse the repository at this point in the history
Update Docs for New Component Schemas
  • Loading branch information
fernandojsg authored Jun 26, 2020
2 parents cb11017 + 78ff448 commit 8c89c78
Show file tree
Hide file tree
Showing 10 changed files with 275 additions and 237 deletions.
42 changes: 24 additions & 18 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ npm install --save ecsy
</style>

<script type="module">
import { World, System, TagComponent } from "https://ecsy.io/build/ecsy.module.js";
import { World, System, Component, TagComponent, Types } from "https://ecsy.io/build/ecsy.module.js";
const NUM_ELEMENTS = 50;
const SPEED_MULTIPLIER = 0.3;
Expand All @@ -79,25 +79,27 @@ npm install --save ecsy
//----------------------
// Velocity component
class Velocity {
constructor() {
this.x = this.y = 0;
}
}
class Velocity extends Component {}
Velocity.schema = {
x: { type: Types.Number },
y: { type: Types.Number }
};
// Position component
class Position {
constructor() {
this.x = this.y = 0;
}
}
class Position extends Component {}
Position.schema = {
x: { type: Types.Number },
y: { type: Types.Number }
};
// Shape component
class Shape {
constructor() {
this.primitive = 'box';
}
}
class Shape extends Component {}
Shape.schema = {
primitive: { type: Types.String, default: 'box' }
};
// Renderable component
class Renderable extends TagComponent {}
Expand Down Expand Up @@ -178,9 +180,13 @@ npm install --save ecsy
renderables: { components: [Renderable, Shape] }
}
// Create world and register the systems on it
// Create world and register the components and systems on it
var world = new World();
world
.registerComponent(Velocity)
.registerComponent(Position)
.registerComponent(Shape)
.registerComponent(Renderable)
.registerSystem(MovableSystem)
.registerSystem(RendererSystem);
Expand Down Expand Up @@ -236,7 +242,7 @@ npm install --save ecsy
</body>
</html>
```
[Try it on glitch](https://glitch.com/~ecsy-boxes-and-circles)
[Try it on glitch](https://glitch.com/~ecsy-0-3-0-boxes-and-circles)


You can also include the hosted javascript directly on your HTML:
Expand Down
Loading

0 comments on commit 8c89c78

Please sign in to comment.