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