feat: physics
This commit is contained in:
parent
ac14a8bba8
commit
a89d167839
|
@ -1,7 +1,8 @@
|
||||||
import {create as createClient} from '@avocado/client';
|
import {create as createClient} from '@avocado/client';
|
||||||
import {EntityList} from '@avocado/entity';
|
import {EntityList} from '@avocado/entity';
|
||||||
import {ActionRegistry} from '@avocado/input';
|
import {ActionRegistry} from '@avocado/input';
|
||||||
import {AnimationView, Color, Container, Primitives, Renderer} from '@avocado/graphics';
|
import {Container, Renderer, ShapeView} from '@avocado/graphics';
|
||||||
|
import {shapeFromJSON} from '@avocado/physics';
|
||||||
import {StateSynchronizer} from '@avocado/state';
|
import {StateSynchronizer} from '@avocado/state';
|
||||||
import {Animation} from '@avocado/timing';
|
import {Animation} from '@avocado/timing';
|
||||||
|
|
||||||
|
@ -20,6 +21,11 @@ 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) {
|
||||||
|
|
|
@ -29,6 +29,7 @@
|
||||||
"@avocado/graphics": "1.x",
|
"@avocado/graphics": "1.x",
|
||||||
"@avocado/input": "1.x",
|
"@avocado/input": "1.x",
|
||||||
"@avocado/mixins": "1.x",
|
"@avocado/mixins": "1.x",
|
||||||
|
"@avocado/physics": "^1.0.0",
|
||||||
"@avocado/resource": "1.x",
|
"@avocado/resource": "1.x",
|
||||||
"@avocado/server": "1.x",
|
"@avocado/server": "1.x",
|
||||||
"@avocado/state": "1.x",
|
"@avocado/state": "1.x",
|
||||||
|
|
|
@ -88,6 +88,15 @@ function createEntityForConnection(socket) {
|
||||||
speed: 400,
|
speed: 400,
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
physical: {
|
||||||
|
params: {
|
||||||
|
shape: {
|
||||||
|
type: 'rectangle',
|
||||||
|
position: [0, 0],
|
||||||
|
size: [32, 32],
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
positioned: {
|
positioned: {
|
||||||
state: {
|
state: {
|
||||||
x: 100,
|
x: 100,
|
||||||
|
@ -126,6 +135,15 @@ function createFlowerBarrelEntity(position) {
|
||||||
},
|
},
|
||||||
existent: {},
|
existent: {},
|
||||||
graphical: {},
|
graphical: {},
|
||||||
|
physical: {
|
||||||
|
params: {
|
||||||
|
shape: {
|
||||||
|
type: 'rectangle',
|
||||||
|
position: [0, 0],
|
||||||
|
size: [32, 32],
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
positioned: {
|
positioned: {
|
||||||
state: {
|
state: {
|
||||||
x: position[0],
|
x: position[0],
|
||||||
|
|
|
@ -56,6 +56,10 @@
|
||||||
version "1.0.0"
|
version "1.0.0"
|
||||||
resolved "https://npm.i12e.cha0s.io/@avocado%2fmixins/-/mixins-1.0.0.tgz#6fe5f8c9d340d502ec4797827efb004a0c833977"
|
resolved "https://npm.i12e.cha0s.io/@avocado%2fmixins/-/mixins-1.0.0.tgz#6fe5f8c9d340d502ec4797827efb004a0c833977"
|
||||||
|
|
||||||
|
"@avocado/physics@^1.0.0":
|
||||||
|
version "1.0.0"
|
||||||
|
resolved "https://npm.i12e.cha0s.io/@avocado%2fphysics/-/physics-1.0.0.tgz#d165c45d832ab07030dc841d40eb1ab4af62bff5"
|
||||||
|
|
||||||
"@avocado/resource@1.x":
|
"@avocado/resource@1.x":
|
||||||
version "1.0.0"
|
version "1.0.0"
|
||||||
resolved "https://npm.i12e.cha0s.io/@avocado%2fresource/-/resource-1.0.0.tgz#3cb94928c59207b1d79fd491818f9d87c9a376be"
|
resolved "https://npm.i12e.cha0s.io/@avocado%2fresource/-/resource-1.0.0.tgz#3cb94928c59207b1d79fd491818f9d87c9a376be"
|
||||||
|
|
Loading…
Reference in New Issue
Block a user