fun: furballs

This commit is contained in:
cha0s 2024-07-22 03:18:02 -05:00
parent 947e2cf380
commit b95a2e2bb9
9 changed files with 53 additions and 0 deletions

View File

@ -0,0 +1,19 @@
import Component from '@/ecs/component.js';
export default class Tags extends Component {
instanceFromSchema() {
return class TagsInstance extends super.instanceFromSchema() {
has(tag) {
return this.tags.includes(tag);
}
};
}
static properties = {
tags: {
type: 'array',
subtype: {
type: 'string',
},
},
};
}

View File

@ -123,6 +123,7 @@ export default async function createHomestead(id) {
source: '/assets/kitty/kitty.json', source: '/assets/kitty/kitty.json',
speed: 0.115, speed: 0.115,
}, },
Tags: {tags: ['kittan']},
Ticking: {}, Ticking: {},
VisibleAabb: {}, VisibleAabb: {},
}; };

View File

@ -38,6 +38,10 @@ export default async function createPlayer(id) {
qty: 1, qty: 1,
source: '/assets/hoe/hoe.json', source: '/assets/hoe/hoe.json',
}, },
5: {
qty: 1,
source: '/assets/brush/brush.json',
},
}, },
}, },
Health: {health: 100}, Health: {health: 100},

View File

@ -0,0 +1,4 @@
{
"icon": "/assets/brush/brush.png",
"start": "/assets/brush/start.js"
}

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.8 KiB

Binary file not shown.

View File

@ -0,0 +1,22 @@
const {Collider, Controlled, Interacts, Inventory, Sound, Sprite} = wielder
const entities = Collider.closest(Interacts.aabb());
for (const entity of entities) {
const {Tags} = entity;
if (Tags && Tags.has('kittan')) {
Controlled.locked = 1
const [, direction] = Sprite.animation.split(':')
for (let i = 0; i < 2; ++i) {
Sound.play('/assets/brush/brush.wav');
Sprite.animation = ['moving', direction].join(':');
await wait(0.3)
Sprite.animation = ['idle', direction].join(':');
await wait(0.1)
}
Inventory.give({
qty: 1,
source: '/assets/furball/furball.json',
});
Controlled.locked = 0;
break;
}
}

View File

@ -0,0 +1,3 @@
{
"icon": "/assets/furball/furball.png"
}

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.9 KiB