fun: furballs
This commit is contained in:
parent
947e2cf380
commit
b95a2e2bb9
19
app/ecs/components/tags.js
Normal file
19
app/ecs/components/tags.js
Normal 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',
|
||||||
|
},
|
||||||
|
},
|
||||||
|
};
|
||||||
|
}
|
|
@ -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: {},
|
||||||
};
|
};
|
||||||
|
|
|
@ -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},
|
||||||
|
|
4
public/assets/brush/brush.json
Normal file
4
public/assets/brush/brush.json
Normal file
|
@ -0,0 +1,4 @@
|
||||||
|
{
|
||||||
|
"icon": "/assets/brush/brush.png",
|
||||||
|
"start": "/assets/brush/start.js"
|
||||||
|
}
|
BIN
public/assets/brush/brush.png
Normal file
BIN
public/assets/brush/brush.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 1.8 KiB |
BIN
public/assets/brush/brush.wav
Normal file
BIN
public/assets/brush/brush.wav
Normal file
Binary file not shown.
22
public/assets/brush/start.js
Normal file
22
public/assets/brush/start.js
Normal 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;
|
||||||
|
}
|
||||||
|
}
|
3
public/assets/furball/furball.json
Normal file
3
public/assets/furball/furball.json
Normal file
|
@ -0,0 +1,3 @@
|
||||||
|
{
|
||||||
|
"icon": "/assets/furball/furball.png"
|
||||||
|
}
|
BIN
public/assets/furball/furball.png
Normal file
BIN
public/assets/furball/furball.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 1.9 KiB |
Loading…
Reference in New Issue
Block a user