feat: more assets
This commit is contained in:
BIN
assets/actor.png
Normal file
BIN
assets/actor.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 169 KiB |
BIN
assets/chicken.png
Normal file
BIN
assets/chicken.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 591 B |
BIN
assets/pot.png
Normal file
BIN
assets/pot.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 1.6 MiB |
BIN
assets/shard.png
Normal file
BIN
assets/shard.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 96 KiB |
@ -17,7 +17,7 @@ export function addChicken(k, world, tile) {
|
||||
const chicken = k.add([
|
||||
...visual(k, "chicken"),
|
||||
k.pos(p),
|
||||
k.area({ collisionIgnore: ["player", "link", "chicken"] }),
|
||||
k.area({ collisionIgnore: ["player", "link", "chicken"], scale: 0.7 }),
|
||||
k.body(),
|
||||
k.state("idle", ["idle", "chase"]),
|
||||
"chicken",
|
||||
@ -49,8 +49,10 @@ export function addChicken(k, world, tile) {
|
||||
}
|
||||
if (chicken.wanderTarget) {
|
||||
const d = world.tc(chicken.wanderTarget).sub(chicken.pos);
|
||||
if (d.len() > 2) chicken.move(d.unit().scale(CHICKEN_SPEED * 0.4));
|
||||
else chicken.wanderTarget = null;
|
||||
if (d.len() > 2) {
|
||||
if (Math.abs(d.x) > 1) chicken.flipX = d.x < 0;
|
||||
chicken.move(d.unit().scale(CHICKEN_SPEED * 0.4));
|
||||
} else chicken.wanderTarget = null;
|
||||
}
|
||||
});
|
||||
|
||||
@ -64,7 +66,10 @@ export function addChicken(k, world, tile) {
|
||||
return;
|
||||
}
|
||||
const d = tgt.pos.sub(chicken.pos);
|
||||
if (d.len() > 2) chicken.move(d.unit().scale(CHICKEN_SPEED));
|
||||
if (d.len() > 2) {
|
||||
if (Math.abs(d.x) > 1) chicken.flipX = d.x < 0;
|
||||
chicken.move(d.unit().scale(CHICKEN_SPEED));
|
||||
}
|
||||
});
|
||||
|
||||
chicken.onUpdate(() => {
|
||||
|
||||
@ -8,7 +8,7 @@ export function addPlayer(k, world) {
|
||||
const player = k.add([
|
||||
...visual(k, "player"),
|
||||
k.pos(p),
|
||||
k.area({ collisionIgnore: ["link", "chicken"] }),
|
||||
k.area({ collisionIgnore: ["link", "chicken"], scale: 0.4 }),
|
||||
k.body(), // dynamic body: pushed out of static obstacles/walls
|
||||
"player",
|
||||
]);
|
||||
|
||||
@ -17,6 +17,10 @@ k.setGravity(0);
|
||||
|
||||
// Actor sprites.
|
||||
k.loadSprite("link", "assets/link.png");
|
||||
k.loadSprite("grass", "assets/grasss.png");
|
||||
k.loadSprite("player", "assets/actor.png");
|
||||
k.loadSprite("shard", "assets/shard.png");
|
||||
k.loadSprite("chicken", "assets/chicken.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.
|
||||
|
||||
@ -112,9 +112,9 @@ function spawnShard(k, world, tile) {
|
||||
const s = k.add([
|
||||
...visual(k, "shard"),
|
||||
k.pos(p.x + jx, p.y + jy),
|
||||
k.area(),
|
||||
k.area({ scale: 0.55 }),
|
||||
k.z(p.y),
|
||||
k.rotate(k.rand() * 360),
|
||||
k.rotate((k.rand() - 0.5) * 24), // slight tilt; keep debris upright-ish
|
||||
"shard",
|
||||
]);
|
||||
return s;
|
||||
|
||||
@ -17,6 +17,10 @@ const SPEC = {
|
||||
// fall back to the placeholder shapes in SPEC.
|
||||
const SPRITES = {
|
||||
link: { name: "link", scale: 0.44 },
|
||||
grass: { name: "grass", scale: 1.6 }, // 16px tile -> ~26px clump
|
||||
player: { name: "player", scale: 0.13 }, // 428px art -> ~52px tall
|
||||
shard: { name: "shard", scale: 0.085 }, // 500px debris -> ~26px clump
|
||||
chicken: { name: "chicken", scale: 1.1 },
|
||||
};
|
||||
|
||||
export function visual(k, kind) {
|
||||
|
||||
Reference in New Issue
Block a user