Skip to content

Commit b9bd6c8

Browse files
jsvdclaude
andcommitted
Revert asteroids drawCircle: restore rotation, opacity fade, additive blend
The scanline circle primitive is too expensive for per-frame gameplay objects and the refactor dropped bullet opacity fade + additive blend. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
1 parent 8c2d072 commit b9bd6c8

1 file changed

Lines changed: 24 additions & 5 deletions

File tree

demos/asteroids/asteroids.ts

Lines changed: 24 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,6 @@ import {
2929
setEffectParam,
3030
} from "../../runtime/rendering/index.ts";
3131
import { rgb } from "../../runtime/ui/types.ts";
32-
import { drawCircle } from "../../runtime/ui/index.ts";
3332
import { createGame, drawColorSprite } from "../../runtime/game/index.ts";
3433
import { registerAgent } from "../../runtime/agent/index.ts";
3534
import { createRng } from "../../runtime/state/index.ts";
@@ -499,15 +498,35 @@ function render(s: GameState): void {
499498
});
500499
}
501500

502-
// Asteroids (circles)
501+
// Asteroids (rotation)
503502
for (const a of s.asteroids) {
504503
const r = ASTEROID_SIZES[a.size];
505-
drawCircle(a.x, a.y, r, { color: COL_ASTEROID, layer: 2 });
504+
drawColorSprite({
505+
color: COL_ASTEROID,
506+
x: a.x - r,
507+
y: a.y - r,
508+
w: r * 2,
509+
h: r * 2,
510+
layer: 2,
511+
rotation: a.angle,
512+
originX: 0.5,
513+
originY: 0.5,
514+
});
506515
}
507516

508-
// Bullets (circles)
517+
// Bullets
509518
for (const b of s.bullets) {
510-
drawCircle(b.x, b.y, BULLET_SIZE / 2, { color: COL_BULLET, layer: 3 });
519+
const opacity = Math.min(b.life / 0.3, 1);
520+
drawColorSprite({
521+
color: COL_BULLET,
522+
x: b.x - BULLET_SIZE / 2,
523+
y: b.y - BULLET_SIZE / 2,
524+
w: BULLET_SIZE,
525+
h: BULLET_SIZE,
526+
layer: 3,
527+
opacity,
528+
blendMode: "additive",
529+
});
511530
}
512531

513532
// Ship

0 commit comments

Comments
 (0)