feat: assetish

This commit is contained in:
2026-07-27 10:52:05 -04:00
parent 81961e53f3
commit 5b97b362c6
19 changed files with 30 additions and 1 deletions

BIN
assets/actors Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 38 KiB

BIN
assets/grasss.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 332 B

BIN
assets/link.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.6 KiB

BIN
assets/link2.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.7 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.6 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.9 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 48 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 58 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 50 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.5 MiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 81 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 31 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.1 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.0 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 559 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 99 KiB

View File

@ -36,7 +36,7 @@ export function addLink(k, world, onLeave) {
const link = k.add([ const link = k.add([
...visual(k, "link"), ...visual(k, "link"),
k.pos(p), k.pos(p),
k.area({ collisionIgnore: ["player", "chicken"] }), k.area({ collisionIgnore: ["player", "chicken"], scale: 0.5 }),
k.body(), k.body(),
k.state("seek", ["seek", "throw", "cutGrass", "hitChicken", "flee", "leave"]), k.state("seek", ["seek", "throw", "cutGrass", "hitChicken", "flee", "leave"]),
"link", "link",

View File

@ -15,6 +15,25 @@ const k = kaplay({
// No gravity: this is a top-down game. // No gravity: this is a top-down game.
k.setGravity(0); k.setGravity(0);
// Actor sprites.
k.loadSprite("link", "assets/link.png");
// Background music. Browsers block autoplay until the user interacts, so start
// looping on the first key/click and keep the handle across scene changes.
k.loadSound("bg-music", "src/assets/bg-music.mp3");
let music = null;
let muted = false;
function startMusic() {
if (music || muted) return;
music = k.play("bg-music", { loop: true, volume: 0.5 });
}
k.onKeyPress(startMusic);
k.onMousePress(startMusic);
k.onKeyPress("m", () => {
muted = !muted;
if (music) music.paused = muted;
});
registerGameScene(k); registerGameScene(k);
registerEndScenes(k); registerEndScenes(k);
k.go("game"); k.go("game");

View File

@ -13,7 +13,17 @@ const SPEC = {
shard: { shape: "rect", w: 12, h: 12, radius: 2, color: [212, 152, 90], outline: [132, 82, 40] }, shard: { shape: "rect", w: 12, h: 12, radius: 2, color: [212, 152, 90], outline: [132, 82, 40] },
}; };
// Kinds backed by a real loaded sprite (loadSprite name + render scale). Others
// fall back to the placeholder shapes in SPEC.
const SPRITES = {
link: { name: "link", scale: 0.44 },
};
export function visual(k, kind) { export function visual(k, kind) {
const sp = SPRITES[kind];
if (sp) {
return [k.sprite(sp.name), k.anchor("center"), k.scale(sp.scale)];
}
const s = SPEC[kind]; const s = SPEC[kind];
const comps = const comps =
s.shape === "circle" s.shape === "circle"