feat: robins
This commit is contained in:
parent
a4490f7a20
commit
bd88d3cbd6
12 changed files with 159 additions and 54 deletions
20
app/level.ts
20
app/level.ts
|
|
@ -125,6 +125,7 @@ const FLOWER_COLORS: FlowerColor[] = ["white", "red", "yellow"]
|
|||
* frame (frustum-culled), not baked into the static chunks. */
|
||||
const FROG_COUNT = 40
|
||||
const BEE_COUNT = 30
|
||||
const ROBIN_COUNT = 30
|
||||
const MOB_SEED = 0x30B
|
||||
const MOB_REACH = 0.5
|
||||
|
||||
|
|
@ -407,14 +408,14 @@ function placeFlowers(): Flower[] {
|
|||
return flowers
|
||||
}
|
||||
|
||||
/** Scatter frogs + bees across the grass (like the boulders), each at its home
|
||||
* anchor with a random heading and size. No colliders here -- mobs move, so their
|
||||
* block/stand-on AABBs are rebuilt per frame in `main`. */
|
||||
/** Scatter frogs, bees + robins across the grass (like the boulders), each at its
|
||||
* home anchor with a random heading and size. No colliders here -- mobs move, so
|
||||
* their block/stand-on AABBs are rebuilt per frame in `main`. */
|
||||
function placeMobs(): Mob[] {
|
||||
const rand = mulberry(MOB_SEED)
|
||||
const maxDist = TERRAIN.outer * MOB_REACH
|
||||
const mobs: Mob[] = []
|
||||
const total = FROG_COUNT + BEE_COUNT
|
||||
const total = FROG_COUNT + BEE_COUNT + ROBIN_COUNT
|
||||
for (let guard = 0; mobs.length < total && guard < total * 20; guard++) {
|
||||
const angle = rand() * Math.PI * 2
|
||||
const dist = ARENA + 3 + rand() * (maxDist - ARENA - 3)
|
||||
|
|
@ -423,9 +424,10 @@ function placeMobs(): Mob[] {
|
|||
if (Math.max(Math.abs(x), Math.abs(z)) < TERRAIN.inner + 2) {
|
||||
continue
|
||||
}
|
||||
const kind: MobKind = mobs.length < FROG_COUNT ? "frog" : "bee"
|
||||
const n = mobs.length
|
||||
const kind: MobKind = n < FROG_COUNT ? "frog" : n < FROG_COUNT + BEE_COUNT ? "bee" : "robin"
|
||||
const y = Terrain.height(TERRAIN, x, z)
|
||||
const scale = kind === "frog" ? 0.5 + rand() * 0.35 : 0.5 + rand() * 0.3
|
||||
const scale = kind === "frog" ? 0.5 + rand() * 0.35 : kind === "robin" ? 0.4 + rand() * 0.25 : 0.5 + rand() * 0.3
|
||||
mobs.push({
|
||||
kind,
|
||||
home: { x, y, z },
|
||||
|
|
@ -437,8 +439,10 @@ function placeMobs(): Mob[] {
|
|||
vz: 0,
|
||||
vy: 0,
|
||||
timer: rand() * 1.5,
|
||||
phase: rand() * 10,
|
||||
grounded: true,
|
||||
// Bees hover (never grounded) and use phase for the bob; frogs/robins start
|
||||
// resting on the ground.
|
||||
phase: kind === "bee" ? rand() * 10 : 0,
|
||||
grounded: kind !== "bee",
|
||||
})
|
||||
}
|
||||
return mobs
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue