From b54853559fdfa84308231a707c3d847ec5889923 Mon Sep 17 00:00:00 2001 From: Catalin Constantin Mititiuc Date: Tue, 10 Feb 2026 16:08:18 -0800 Subject: [PATCH] WIP: toggle gravity effect per ship --- html/images/space.svg | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/html/images/space.svg b/html/images/space.svg index 7d3fe75..d2ca691 100644 --- a/html/images/space.svg +++ b/html/images/space.svg @@ -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)`; }