feat: physics++

This commit is contained in:
cha0s 2019-03-23 18:32:16 -05:00
parent e195064210
commit 3cfd46b982
2 changed files with 4 additions and 5 deletions

View File

@ -3,12 +3,14 @@ import {EntityList} from '@avocado/entity';
import {ActionRegistry} from '@avocado/input'; import {ActionRegistry} from '@avocado/input';
import {Container, Renderer, ShapeView} from '@avocado/graphics'; import {Container, Renderer, ShapeView} from '@avocado/graphics';
import {shapeFromJSON} from '@avocado/physics'; import {shapeFromJSON} from '@avocado/physics';
import {World} from '@avocado/physics/dummy';
import {StateSynchronizer} from '@avocado/state'; import {StateSynchronizer} from '@avocado/state';
import {Animation} from '@avocado/timing'; import {Animation} from '@avocado/timing';
const stage = new Container(); const stage = new Container();
const entityList = new EntityList(); const entityList = new EntityList();
entityList.world = new World();
const stateSynchronizer = new StateSynchronizer({ const stateSynchronizer = new StateSynchronizer({
entityList, entityList,
}); });
@ -21,11 +23,6 @@ entityList.on('entityAdded', (entity) => {
// Add to graphics. // Add to graphics.
if ('container' in entity) { if ('container' in entity) {
stage.addChild(entity.container); stage.addChild(entity.container);
if (entity.hasTrait('physical')) {
const shapeView = new ShapeView(entity.shape);
shapeView.zIndex = 100;
entity.container.addChild(shapeView);
}
} }
// Set self entity. // Set self entity.
if ('string' === typeof selfEntity) { if ('string' === typeof selfEntity) {

View File

@ -8,6 +8,7 @@ import {
EntityList, EntityList,
registerTrait, registerTrait,
} from '@avocado/entity'; } from '@avocado/entity';
import {World} from '@avocado/physics/dummy';
import {StateSynchronizer} from '@avocado/state'; import {StateSynchronizer} from '@avocado/state';
// Create game. // Create game.
export default function(avocadoServer) { export default function(avocadoServer) {
@ -16,6 +17,7 @@ export default function(avocadoServer) {
} }
// Entity tracking. // Entity tracking.
const entityList = new EntityList(); const entityList = new EntityList();
entityList.world = new World();
const informables = []; const informables = [];
const stateSynchronizer = new StateSynchronizer({ const stateSynchronizer = new StateSynchronizer({
entityList, entityList,