Skip to content

Commit 9424961

Browse files
author
DavidQ
committed
BUILD_PR_GAMES_88A_ASTEROIDS_ENTITY_COPY_STEP2 &
BUILD_PR_GAMES_89A_ASTEROIDS_ENTITY_IMPORT_FIX_STEP2 & BUILD_PR_GAMES_90A_ASTEROIDS_ENTITY_VALIDATE_STEP2
1 parent 67a28a9 commit 9424961

7 files changed

Lines changed: 81 additions & 4 deletions

docs/dev/CODEX_COMMANDS.md

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
MODEL: GPT-5.4-codex
22
REASONING: medium
33
COMMAND:
4-
Execute docs/pr/BUILD_PR_GAMES_87_ASTEROIDS_SINGLE_SLICE_MIGRATION.md exactly.
5-
Package to <project folder>/tmp/BUILD_PR_GAMES_87_ASTEROIDS_SINGLE_SLICE_MIGRATION_delta.zip
4+
Execute PR exactly and package delta zip.

docs/dev/COMMIT_COMMENT.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
Copy first entity slice into new template structure
1+
BUILD_PR_GAMES_90A_ASTEROIDS_ENTITY_VALIDATE_STEP2
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Copy one additional entity file from asteroids to asteroids_new. Copy only.
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Fix imports only inside asteroids_new entities if needed. No logic changes.
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Validate new entity slice. No changes unless required.

games/asteroids_new/entities/Bullet.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ David Quesenberry
44
03/22/2026
55
Bullet.js
66
*/
7-
import { wrap } from '../utils/math.js';
7+
import { wrap } from "../../asteroids/utils/math.js";
88

99
export default class Bullet {
1010
constructor(x, y, vx, vy, life = 1.1) {
Lines changed: 75 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,75 @@
1+
/*
2+
Toolbox Aid
3+
David Quesenberry
4+
03/22/2026
5+
Ship.js
6+
*/
7+
import { wrap } from "../../asteroids/utils/math.js";
8+
import { transformPoints } from '../../../src/engine/vector/index.js';
9+
10+
const SMALL_VECTOR_MAP = [
11+
{ x: 14, y: 0 },
12+
{ x: -10, y: -8 },
13+
{ x: -6, y: -3 },
14+
{ x: -6, y: 3 },
15+
{ x: -10, y: 8 },
16+
{ x: 14, y: 0 },
17+
];
18+
19+
export default class Ship {
20+
constructor(x, y) {
21+
this.spawnX = x;
22+
this.spawnY = y;
23+
this.reset();
24+
}
25+
26+
reset() {
27+
this.x = this.spawnX;
28+
this.y = this.spawnY;
29+
this.vx = 0;
30+
this.vy = 0;
31+
this.angle = -Math.PI / 2;
32+
this.invulnerable = 2;
33+
this.thrusting = false;
34+
}
35+
36+
update(dtSeconds, bounds, input) {
37+
if (input?.isDown('ArrowLeft')) {
38+
this.angle -= 3.8 * dtSeconds;
39+
}
40+
if (input?.isDown('ArrowRight')) {
41+
this.angle += 3.8 * dtSeconds;
42+
}
43+
44+
this.thrusting = Boolean(input?.isDown('ArrowUp'));
45+
if (this.thrusting) {
46+
this.vx += Math.cos(this.angle) * 170 * dtSeconds;
47+
this.vy += Math.sin(this.angle) * 170 * dtSeconds;
48+
}
49+
50+
this.vx *= 0.992;
51+
this.vy *= 0.992;
52+
this.x = wrap(this.x + this.vx * dtSeconds, bounds.width);
53+
this.y = wrap(this.y + this.vy * dtSeconds, bounds.height);
54+
this.invulnerable = Math.max(0, this.invulnerable - dtSeconds);
55+
}
56+
57+
getPoints() {
58+
return transformPoints(SMALL_VECTOR_MAP, {
59+
x: this.x,
60+
y: this.y,
61+
rotation: this.angle,
62+
});
63+
}
64+
65+
getFlamePoints(pulse = 1) {
66+
const rear = this.angle + Math.PI;
67+
const flameReach = (18 + pulse * 9) * 0.5;
68+
const wingSpread = (8 + pulse * 2) * 0.5;
69+
return [
70+
{ x: this.x + Math.cos(rear) * flameReach, y: this.y + Math.sin(rear) * flameReach },
71+
{ x: this.x + Math.cos(this.angle + 2.7) * wingSpread, y: this.y + Math.sin(this.angle + 2.7) * wingSpread },
72+
{ x: this.x + Math.cos(this.angle - 2.7) * wingSpread, y: this.y + Math.sin(this.angle - 2.7) * wingSpread },
73+
];
74+
}
75+
}

0 commit comments

Comments
 (0)