feat: physics++
This commit is contained in:
parent
e195064210
commit
3cfd46b982
|
@ -3,12 +3,14 @@ import {EntityList} from '@avocado/entity';
|
|||
import {ActionRegistry} from '@avocado/input';
|
||||
import {Container, Renderer, ShapeView} from '@avocado/graphics';
|
||||
import {shapeFromJSON} from '@avocado/physics';
|
||||
import {World} from '@avocado/physics/dummy';
|
||||
import {StateSynchronizer} from '@avocado/state';
|
||||
import {Animation} from '@avocado/timing';
|
||||
|
||||
const stage = new Container();
|
||||
|
||||
const entityList = new EntityList();
|
||||
entityList.world = new World();
|
||||
const stateSynchronizer = new StateSynchronizer({
|
||||
entityList,
|
||||
});
|
||||
|
@ -21,11 +23,6 @@ entityList.on('entityAdded', (entity) => {
|
|||
// Add to graphics.
|
||||
if ('container' in entity) {
|
||||
stage.addChild(entity.container);
|
||||
if (entity.hasTrait('physical')) {
|
||||
const shapeView = new ShapeView(entity.shape);
|
||||
shapeView.zIndex = 100;
|
||||
entity.container.addChild(shapeView);
|
||||
}
|
||||
}
|
||||
// Set self entity.
|
||||
if ('string' === typeof selfEntity) {
|
||||
|
|
|
@ -8,6 +8,7 @@ import {
|
|||
EntityList,
|
||||
registerTrait,
|
||||
} from '@avocado/entity';
|
||||
import {World} from '@avocado/physics/dummy';
|
||||
import {StateSynchronizer} from '@avocado/state';
|
||||
// Create game.
|
||||
export default function(avocadoServer) {
|
||||
|
@ -16,6 +17,7 @@ export default function(avocadoServer) {
|
|||
}
|
||||
// Entity tracking.
|
||||
const entityList = new EntityList();
|
||||
entityList.world = new World();
|
||||
const informables = [];
|
||||
const stateSynchronizer = new StateSynchronizer({
|
||||
entityList,
|
||||
|
|
Loading…
Reference in New Issue
Block a user