WIP: toggle gravity effect per ship
This commit is contained in:
@@ -257,6 +257,7 @@ const AngularVelocity = {};
|
|||||||
const Degrees = {};
|
const Degrees = {};
|
||||||
const Nodes = {};
|
const Nodes = {};
|
||||||
const CannonNodes = {};
|
const CannonNodes = {};
|
||||||
|
const GravityEffect = {}
|
||||||
|
|
||||||
// Points = {
|
// Points = {
|
||||||
// "wall_1": "0,0 2,0 1,1",
|
// "wall_1": "0,0 2,0 1,1",
|
||||||
@@ -794,10 +795,11 @@ const Move = (() => {
|
|||||||
update: ({ entity_id }, elapsed) => {
|
update: ({ entity_id }, elapsed) => {
|
||||||
const gravity = 0.1;
|
const gravity = 0.1;
|
||||||
// affectedByWalls & affectedByGravity toggles?
|
// affectedByWalls & affectedByGravity toggles?
|
||||||
|
const isAffectedByGravity = GravityEffect[entity_id];
|
||||||
const { x: px, y: py } = Position[entity_id];
|
const { x: px, y: py } = Position[entity_id];
|
||||||
const { x: vx, y: vy } = Velocity[entity_id];
|
const { x: vx, y: vy } = Velocity[entity_id];
|
||||||
let { x: ax, y: ay } = Acceleration[entity_id];
|
const ax = Acceleration[entity_id].x;
|
||||||
ay += gravity;
|
const ay = isAffectedByGravity ? Acceleration[entity_id].y + gravity : Acceleration[entity_id].y;
|
||||||
|
|
||||||
const vr = {
|
const vr = {
|
||||||
x: Math.round(vx * 100 + ax * 100) / 100,
|
x: Math.round(vx * 100 + ax * 100) / 100,
|
||||||
@@ -1058,6 +1060,7 @@ function init() {
|
|||||||
Degrees[entity_id] = s.degrees;
|
Degrees[entity_id] = s.degrees;
|
||||||
Nodes[entity_id] = document.querySelector(`#${entity_id}`);
|
Nodes[entity_id] = document.querySelector(`#${entity_id}`);
|
||||||
CannonNodes[entity_id] = document.querySelector(`#${entity_id} .cannon`);
|
CannonNodes[entity_id] = document.querySelector(`#${entity_id} .cannon`);
|
||||||
|
GravityEffect[entity_id] = true;
|
||||||
// let node = document.querySelector(`#${entity_id}`);
|
// let node = document.querySelector(`#${entity_id}`);
|
||||||
// node.style.transform = `translate(${s.position.x}px, ${s.position.y}px)`;
|
// node.style.transform = `translate(${s.position.x}px, ${s.position.y}px)`;
|
||||||
}
|
}
|
||||||
|
|||||||
|
Before Width: | Height: | Size: 52 KiB After Width: | Height: | Size: 52 KiB |
Reference in New Issue
Block a user