Modify terrain and remove buttons

This commit is contained in:
2025-12-19 13:05:58 -08:00
parent 8705b5779d
commit 5a5b4e9272

View File

@@ -59,7 +59,7 @@
</g> </g>
</g> </g>
<polygon id="wall" points="-20,-20 -20,-30 30,-30 30,30 -10,40 -20,30 20,20 20,-20" /> <polygon id="wall" points="-20,-30 -10,-40 30,-50 60,-30 80,0 150,0 150,10 60,50 -10,40 -20,20 20,20 20,-20" />
<!-- <rect id="rect1" x="30" y="30" width="20" height="20"/> --> <!-- <rect id="rect1" x="30" y="30" width="20" height="20"/> -->
<g id="lines"> <g id="lines">
</g> </g>
@@ -72,13 +72,13 @@
<span id="fps" xmlns="http://www.w3.org/1999/xhtml">0</span> fps <span id="fps" xmlns="http://www.w3.org/1999/xhtml">0</span> fps
</div> </div>
<button id="turn-left" xmlns="http://www.w3.org/1999/xhtml">🡐</button> <!-- <button id="turn-left" xmlns="http://www.w3.org/1999/xhtml">🡐</button> -->
<button id="move-backward" xmlns="http://www.w3.org/1999/xhtml">🡑</button> <!-- <button id="move-backward" xmlns="http://www.w3.org/1999/xhtml">🡑</button> -->
<button id="move-forward" xmlns="http://www.w3.org/1999/xhtml">🡓</button> <!-- <button id="move-forward" xmlns="http://www.w3.org/1999/xhtml">🡓</button> -->
<button id="turn-right" xmlns="http://www.w3.org/1999/xhtml">🡒</button> <!-- <button id="turn-right" xmlns="http://www.w3.org/1999/xhtml">🡒</button> -->
<button id="rotate-ccw" xmlns="http://www.w3.org/1999/xhtml"></button> <!-- <button id="rotate-ccw" xmlns="http://www.w3.org/1999/xhtml">⟲</button> -->
<button id="rotate-cw" xmlns="http://www.w3.org/1999/xhtml"></button> <!-- <button id="rotate-cw" xmlns="http://www.w3.org/1999/xhtml">⟳</button> -->
<button id="fire" xmlns="http://www.w3.org/1999/xhtml">Fire</button> <!-- <button id="fire" xmlns="http://www.w3.org/1999/xhtml">Fire</button> -->
<pre id="debug" xmlns="http://www.w3.org/1999/xhtml"></pre> <pre id="debug" xmlns="http://www.w3.org/1999/xhtml"></pre>
</foreignObject> </foreignObject>
@@ -168,14 +168,17 @@
const pos = `${positionX},${positionY}`; const pos = `${positionX},${positionY}`;
const cwOrientation = det < 0; const cwOrientation = det < 0;
const isClockwise = det < 0;
if (pos !== attr.pop()) { if (pos !== attr.pop()) {
attr.push(pos); attr.push(pos);
t.setAttribute('points', attr.join(delim)); t.setAttribute('points', attr.join(delim));
} }
t.classList[cwOrientation ? "add" : "remove"](className); t.classList[isClockwise ? "add" : "remove"](className);
if (cwOrientation) visible.push(t); if (isClockwise) visible.push(t);
// return isClockwise ? [t, ...acc] : acc;
// i think i can also discard obtuse triangles? // i think i can also discard obtuse triangles?
// if all the triangles are obtuse, i only need to check the nearest corner for a collision // if all the triangles are obtuse, i only need to check the nearest corner for a collision
@@ -527,58 +530,58 @@
} }
}); });
leftTurnButton.addEventListener("mousedown", function (e) { // leftTurnButton.addEventListener("mousedown", function (e) {
acceleration[0] = -force; // acceleration[0] = -force;
}); // });
//
leftTurnButton.addEventListener("mouseup", function (e) { // leftTurnButton.addEventListener("mouseup", function (e) {
acceleration[0] = 0; // acceleration[0] = 0;
}); // });
//
rightTurnButton.addEventListener("mousedown", function (e) { // rightTurnButton.addEventListener("mousedown", function (e) {
acceleration[0] = force; // acceleration[0] = force;
}); // });
//
rightTurnButton.addEventListener("mouseup", function (e) { // rightTurnButton.addEventListener("mouseup", function (e) {
acceleration[0] = 0; // acceleration[0] = 0;
}); // });
//
reverseMoveButton.addEventListener("mousedown", function (e) { // reverseMoveButton.addEventListener("mousedown", function (e) {
acceleration[1] = -force; // acceleration[1] = -force;
}); // });
//
reverseMoveButton.addEventListener("mouseup", function (e) { // reverseMoveButton.addEventListener("mouseup", function (e) {
acceleration[1] = 0; // acceleration[1] = 0;
}); // });
//
forwardMoveButton.addEventListener("mousedown", function (e) { // forwardMoveButton.addEventListener("mousedown", function (e) {
acceleration[1] = force; // acceleration[1] = force;
}); // });
//
forwardMoveButton.addEventListener("mouseup", function (e) { // forwardMoveButton.addEventListener("mouseup", function (e) {
acceleration[1] = 0; // acceleration[1] = 0;
}); // });
//
rotateCWButton.addEventListener("mousedown", function (e) { // rotateCWButton.addEventListener("mousedown", function (e) {
rotate = 1; // rotate = 1;
}); // });
//
rotateCWButton.addEventListener("mouseup", function (e) { // rotateCWButton.addEventListener("mouseup", function (e) {
rotate = 0; // rotate = 0;
}); // });
//
rotateCCWButton.addEventListener("mousedown", function (e) { // rotateCCWButton.addEventListener("mousedown", function (e) {
rotate = -1; // rotate = -1;
}); // });
//
rotateCCWButton.addEventListener("mouseup", function (e) { // rotateCCWButton.addEventListener("mouseup", function (e) {
rotate = 0; // rotate = 0;
}); // });
//
fireButton.addEventListener("click", function (e) { // fireButton.addEventListener("click", function (e) {
const [x, y] = getTranslate(hitbox); // const [x, y] = getTranslate(hitbox);
fireBullet(x, y, velocity); // fireBullet(x, y, velocity);
}); // });
//]]></script> //]]></script>
</svg> </svg>

Before

Width:  |  Height:  |  Size: 17 KiB

After

Width:  |  Height:  |  Size: 18 KiB