fun: animules

This commit is contained in:
cha0s 2024-08-05 23:23:00 -05:00
parent 8e4bfaf6b7
commit 219ee71c2c

View File

@ -1,5 +1,27 @@
import data from '../../../public/assets/dev/homestead.json'; import data from '../../../public/assets/dev/homestead.json';
function animal() {
return {
Alive: {health: 100},
Behaving: {},
Collider: {},
Controlled: {},
Direction: {},
Emitter: {},
Forces: {},
Interlocutor: {},
Position: {},
Speed: {speed: 20},
Sprite: {
animation: 'moving:down',
},
Tags: {},
Ticking: {},
VisibleAabb: {},
Vulnerable: {},
};
}
export default async function createHomestead(id) { export default async function createHomestead(id) {
const area = {x: 100, y: 60}; const area = {x: 100, y: 60};
const entities = []; const entities = [];
@ -138,8 +160,10 @@ export default async function createHomestead(id) {
Ticking: {}, Ticking: {},
VisibleAabb: {}, VisibleAabb: {},
}); });
const kitty = { const animalJson = animal();
Alive: {health: 100}, for (let i = 0; i < 50; ++i) {
entities.push({
...animalJson,
Behaving: { Behaving: {
routines: { routines: {
initial: '/assets/kitty/initial.js', initial: '/assets/kitty/initial.js',
@ -157,10 +181,6 @@ export default async function createHomestead(id) {
}, },
], ],
}, },
Controlled: {},
Direction: {},
Emitter: {},
Forces: {},
Interactive: { Interactive: {
interacting: 1, interacting: 1,
interactScript: ` interactScript: `
@ -181,28 +201,120 @@ export default async function createHomestead(id) {
}) })
`, `,
}, },
Interlocutor: {}, Position: {
Position: {x: 250, y: 250}, x: 250 + (Math.random() - 0.5) * 300,
Speed: {speed: 20}, y: 250 + (Math.random() - 0.5) * 300,
},
Sprite: { Sprite: {
...animalJson.Sprite,
anchorX: 0.5, anchorX: 0.5,
anchorY: 0.7, anchorY: 0.7,
animation: 'moving:down',
source: '/assets/kitty/kitty.json', source: '/assets/kitty/kitty.json',
speed: 0.115, speed: 0.115,
}, },
Tags: {tags: ['kittan']}, Tags: {tags: ['kittan']},
Ticking: {}, });
VisibleAabb: {}, }
Vulnerable: {},
};
for (let i = 0; i < 50; ++i) { for (let i = 0; i < 50; ++i) {
entities.push({ entities.push({
...kitty, ...animalJson,
Behaving: {
routines: {
initial: '/assets/farm/animals/cow-adult/initial.js',
},
},
Collider: {
bodies: [
{
points: [
{x: -3.5, y: -3.5},
{x: 3.5, y: -3.5},
{x: 3.5, y: 3.5},
{x: -3.5, y: 3.5},
],
},
],
},
Interactive: {
interacting: 1,
interactScript: `
const lines = [
'sno<shake>rr</shake>t',
'm<wave>ooooooooooo</wave>',
];
const line = lines[Math.floor(Math.random() * lines.length)];
subject.Interlocutor.dialogue({
body: line,
linger: 2,
offset: {x: 0, y: -16},
origin: 'track',
position: 'track',
})
`,
},
Position: { Position: {
...kitty.Position, x: 350 + (Math.random() - 0.5) * 300,
x: 250 + (Math.random() - 0.5) * 300, y: 350 + (Math.random() - 0.5) * 300,
y: 250 + (Math.random() - 0.5) * 300, },
Sprite: {
...animalJson.Sprite,
anchorX: 0.5,
anchorY: 0.8,
source: '/assets/farm/animals/cow-adult/cow-adult.json',
speed: 0.25,
},
});
}
for (let i = 0; i < 50; ++i) {
entities.push({
...animalJson,
Behaving: {
routines: {
initial: '/assets/farm/animals/goat-white/initial.js',
},
},
Collider: {
bodies: [
{
points: [
{x: -7, y: -3.5},
{x: 7, y: -3.5},
{x: 7, y: 3.5},
{x: -7, y: 3.5},
],
},
],
},
Interactive: {
interacting: 1,
interactScript: `
const lines = [
'mrowwr',
'p<shake>rrr</shake>o<wave>wwwww</wave>',
'mew<rate frequency={0.5}> </rate>mew!',
'me<wave>wwwww</wave>',
'\\\\*pu<shake>rrrrr</shake>\\\\*',
];
const line = lines[Math.floor(Math.random() * lines.length)];
subject.Interlocutor.dialogue({
body: line,
linger: 2,
offset: {x: 0, y: -16},
origin: 'track',
position: 'track',
})
`,
},
Position: {
x: 350 + (Math.random() - 0.5) * 300,
y: 150 + (Math.random() - 0.5) * 300,
},
Sprite: {
...animalJson.Sprite,
anchorX: 0.5,
anchorY: 0.8,
source: '/assets/farm/animals/goat-white/goat-white.json',
speed: 0.25,
}, },
}); });
} }