| assets | ||
| benchmarks | ||
| game | ||
| prototype | ||
| .editorconfig | ||
| .gitattributes | ||
| .gitignore | ||
| first-game-plan.md | ||
| first-game.md | ||
| Godot_4.7_Farm_v1.0.zip | ||
| icon.svg | ||
| icon.svg.import | ||
| plan.md | ||
| project.godot | ||
| README.md | ||
Harvest Season — horde survival prototype
A small enclosed 3D arena under a fixed orthographic isometric camera. Birds chase the player and attack at close range; the player shoots traveling, pooled projectiles. Three accepted hits kill the player; eliminating every bird wins. Restart restores the complete initial round.
Built with Godot 4.7.2 (stable, official) and typed GDScript only. Measured results are in
benchmarks/REPORT.md.
Running
Requirements: Godot 4.7.2 (Godot_v4.7.2-stable_linux.x86_64 was used; no other engine
version or language). The project is configured for the Mobile renderer (Vulkan).
The project's main scene is now the farm (res://game/scenes/farm.tscn, see
Farm scene); the prototype arena is launched by passing its scene explicitly:
# Farm (main scene; F5 in the editor)
godot --path .
# Prototype: normal demo, 50 birds
godot --path . res://prototype/scenes/main.tscn
# Prototype with 25 birds
godot --path . res://prototype/scenes/main.tscn -- --enemies=25
# Prototype with the performance overlay
godot --path . res://prototype/scenes/main.tscn -- --overlay
In the editor, open prototype/scenes/main.tscn and press F6 to run the prototype.
The default bird count is enemy_count in res://prototype/resources/default_config.tres.
Farm scene
The game proper: game/scenes/farm.tscn with the farmer (game/scenes/player.tscn, the
scarecrow from Step 4), a follow camera, sun + sky lighting, and props from the ithappy farm
pack (assets/farm/ithappy/farm/prefabs/assets/).
- Player —
PlayerCharacter(game/scripts/player_character.gd): camera-relative movement on themove_*actions with gravity; the model turns toward travel and crossfades idle / walk (partial stick) / run. Clips come fromgame/resources/player_animations.res, an AnimationLibrary of KayKit Rig_Medium clips (idle, walk, run, interact, pick-up, use item, dig, chop, hammer, wave) built bygame/tools/build_player_animations.gd— add clips to itsCLIPStable and re-run it with the editor closed. - Camera —
FollowCamera(game/scripts/follow_camera.gd): framing from pitch / yaw / distance (inspector), smoothed follow, mouse-wheel zoom. It is a tool script, so the editor viewport preview shows the in-game framing. - Level — ithappy prefabs instanced directly under
Level/, on a 120 × 120 m plane + box floor. The pack ships without collision, sogame/tools/build_prop_collision.gdadds aCollisionStaticBody3D (layer 1) to each prefab farm.tscn places: trimesh for ground / road tiles (walk on the visible surface), trunk cylinders for trees, cylinders for bushes and barrels, a ramp-edged slab forbox_005pads, a footprint box for everything else, nothing for crops (plant/). The shapes live in the prefab files, so every instance collides. After placing a new prefab type, re-run it with the editor closed (prefabs that already have a CollisionShape3D are skipped, so hand-tuned shapes survive;-- --forceregenerates its own). Animals (animal/) get none either; the open pen gate (fence_018) has a hand-made thin box. - Zones — the playable map is 60 × 60 m (x −13…47, z −45…15) inside a perimeter fence with 6
gaps; the rest of the farm is scenery.
Zones/holds oneFarmZoneper area (crop field, animal pen, supply shed, work area, woodlot, scrap heap, haystacks) with its props as children, the 30CropUnits of the crop field, and the perimeter (fence, gap and crowFarmMarkers, and scarecrow-onlyPlayerBoundson physics layer 3).ZoneBannershows the zone's name when the scarecrow walks in.FarmNavigationrasterizes the farm's collision into a 0.5 m grid for ground enemies. Details, travel times, and how to edit:game/LAYOUT.md.game/tools/render_overview.gdrenders a top-down picture (--zonesdraws the zones). - Campaign —
CampaignController(game/scripts/campaign_controller.gd) runs the five-night vacation: Morning → Day → Dusk → Night → Dawn per night, then the farmers' return, with Game Over from any phase.FarmState(farm_state.gd) is the single source of truth for what persists; settings are ingame/resources/game_config.tres(GameConfig). The rules are ingame/RULES.mdand the development plan infirst-game-plan.md. Until the real HUD arrives,CampaignDebugshows the phase and farm state top-left. Keys: Enter begins the day, F6 ends the current phase, F7 cycles 1× / 5× / 20× speed, F9 sets the scarecrow to 0 HP, F10 strips the farm, R retries after a Game Over, and N starts the night early (only whenallow_early_nightis on).
Controls
| Action | Keyboard / mouse | Gamepad |
|---|---|---|
| Move (camera-relative, normalized diagonals) | WASD or arrow keys | Left stick |
| Aim | Mouse cursor (aim marker shows the target) | Right stick (radial dead zone, last aim retained) |
| Fire (hold, 6 shots/s) | Left mouse button | Right trigger or right shoulder |
| Restart (any time) | R | Start |
| Restart button on the end screen | Click, Enter/Space | A (button is focused automatically) |
| Performance overlay | F3 | Back / Select |
The active aiming device switches only on deliberate input: 12 px of accumulated mouse travel or a click selects the mouse; right-stick deflection beyond the dead zone (0.3) or the fire trigger selects the gamepad. After any restart, fire must be released and pressed again.
Layout
game/
RULES.md rules of the vacation
LAYOUT.md the playable farm: zones, gaps, travel times
scenes/ farm.tscn (main scene), player.tscn
scripts/ player_character.gd, follow_camera.gd, campaign_controller.gd, farm_state.gd,
game_config.gd, campaign_debug.gd, farm_zones.gd, farm_zone.gd, farm_marker.gd,
crop_unit.gd, farm_navigation.gd, zone_banner.gd
resources/ player_animations.res (generated), game_config.tres
tests/ headless test runner and suites (campaign rules, farm layout)
tools/ build_player_animations.gd, build_prop_collision.gd, render_overview.gd
prototype/
scenes/ main.tscn (round), player.tscn, hud.tscn
scripts/ gameplay systems (one class per file, see Architecture)
resources/ default_config.tres, floor / bird / hit-flash shaders
tests/ headless test runner and suites
tools/ configure_project.gd, inspect_assets.gd, probe_hand_pose.gd
benchmarks/ run_benchmarks.sh, summarize.py, results/*.json, REPORT.md
assets/ the original asset kits (unchanged; referenced in place)
Configuration
All tunables live in one resource: res://prototype/resources/default_config.tres
(PrototypeConfig, prototype/scripts/prototype_config.gd). Key defaults:
| Setting | Value |
|---|---|
| Arena playable area | 32 × 32 m (compact); stress "enlarged" layout = labeled 2× copy |
| Camera | orthographic, 45° yaw, 35° pitch, frames the whole arena at any aspect |
| Physics tick | 60 Hz, physics interpolation on (player, birds, bullets) |
| Player | 6 m/s, capsule r = 0.4 m, 3 health, 1 s invulnerability after an accepted hit |
| Birds | 2.5 m/s, 1 hit, body radius 0.30 m, hit proxy 0.35 m, 1 s attack cooldown, reach 0.2 m |
| Weapon | 6 shots/s, 24 m/s, 2 s lifetime, pool 64 |
| Enemy pool | 64 (normal); stress presets allocate their capacity before the run |
| Navigation | 0.5 m cells, flow field rebuilt on player-cell change at ≤ 10 Hz, sliced 1200 cells/tick |
| Steering | 20 Hz per bird in 3 staggered cohorts, separation ≤ 16 candidates / ≤ 6 neighbors |
| Combat height | 1.1 m (gun muzzle, bullets, bird bodies) |
Project settings written by prototype/tools/configure_project.gd (re-runnable, editor closed):
main scene, 1920 × 1080 reference resolution, Mobile renderer, MSAA 2×, physics interpolation,
InputMap actions (move_*, aim_*, fire, restart, toggle_overlay; the built-in
ui_accept / ui_cancel cover UI confirm/cancel on keyboard and gamepad), and physics layer
names. All pre-existing settings (Jolt Physics, D3D12 on Windows, stretch mode) are preserved.
Collision layers
| Layer | Name | Used by |
|---|---|---|
| 1 | world |
One StaticBody3D ("WorldCollision"): floor box + one box per obstacle footprint |
| 2 | player |
The player CharacterBody3D (mask = world) |
Birds and bullets are not physics bodies. Bird ↔ world uses circle-vs-footprint queries
(ArenaNavigation), bullet ↔ world uses one physics ray per bullet per tick against layer 1,
bullet ↔ bird uses HordeSystem.sweep_hit. Every obstacle's physics box, navigation occupancy,
and visual are derived from the same authored footprint (ArenaLayout).
Asset inventory and mappings
Recorded with prototype/tools/inspect_assets.gd (full output:
prototype/tools/asset_inventory.txt). Source assets are never modified; derived data exists
only in memory and is built during LOADING.
Bird — res://assets/bird/Bird_01.obj (+ .mtl). One surface, 386 triangles, one material
(blinn3SG, albedo 0.01 — a black crow; the other .mtl entries are unused). Authored with +X
forward, +Z up, wings along ±Y, in ~cm (bounds 179 × 241 × 58). AssetCatalog builds a derived
mesh: re-centered on the torso (pivot 18.6, 0, 84 source units), scaled by 0.0055 (≈ 1.0 m long,
1.33 m wingspan) and rotated to Godot's −Z forward. Rendered by one MultiMeshInstance3D with a
shared shader (bird.gdshader: per-bird wing flap from instance custom data, rim light).
Birds are ground-bound (flat XZ navigation) and drawn hovering at combat height. Body collision
radius 0.30 m fits the torso (x[−39.9, 77.1], z[62.5, 105.5] source units), not the wings.
Player — res://assets/kaykit_characters/characters/Mannequin_Medium.glb: 6 mesh parts,
6,916 triangles, one embedded-texture material, 21-bone skeleton at Rig_Medium/Skeleton3D,
≈ 2.2 m tall, faces +Z (rotated 180°). The mannequin has no clips; they come from the shared
Rig_Medium_*.glb animation files (same rig root and bone names, plus handslot.l/.r, which the
mannequin lacks — those tracks are dropped when the library is built). All source clips are
non-looping and in place (root translation stays 0), so loop flags are set on the in-memory
copies and no root motion is used; gameplay owns the position.
| Role | Clip (file) | Notes / fallback |
|---|---|---|
| idle | Idle_A (General) |
|
| move forward | Running_A (MovementBasic) |
matches 6 m/s |
| move backward | Walking_Backwards (MovementAdvanced) |
no backward run clip: walking stride, some foot slide |
| strafe | Running_Strafe_Left/Right (MovementAdvanced) |
diagonals are BlendSpace2D blends |
| aim (right arm only) | Ranged_1H_Aiming (CombatRanged) |
filtered Blend2 on upperarm/lowerarm/wrist/hand.r |
| death | Death_A (General) |
holds the last frame |
| victory | Cheering (Simulation) |
Full-body facing follows the aim; legs use the 2D blend space in the facing frame. Hit_A
exists but is full-body, so the hit cue is a red flash on the mannequin plus a brief screen tint.
Gun — built from primitives (barrel cylinder, body box, grip box) on a stable aiming pivot
under the facing node, positioned so the grip sits in the aim clip's right hand
(hand.r measured at (0.35, 1.0, −0.6) in the facing frame by probe_hand_pose.gd). The
visible muzzle is exactly the gameplay muzzle (1.05 m forward, 0.35 m right, 1.1 m up).
Arena — res://assets/prototype_kit/Pieces/: fence.fbx (36 tris), box.fbx (108),
pillar.fbx (12), cube6.fbx (12, thin wall), wall.fbx (12), ground.fbx (2). The kit's
pieces carry baked offsets from their source scene (e.g. box.fbx spans x[2, 4]), so each piece
is fitted by its measured AABB onto its footprint. The FBX materials reference no texture (the
kit's 8×8 texture.png palette is not linked), so obstacle groups get flat tints. Layout: far
(−X/−Z) perimeter 2 m fence, near (+X/+Z) perimeter 0.6 m fence so the camera sees over it,
and five cover clusters at 1.5 m: crate L, U-shaped fence, pillar grove, two-wall corridor, and a
central wall. Passages are ≥ 2 m wide (≥ 3 bird diameters).
Not used: the Stylized Nature MegaKit, the KayKit large rig, and the prototype kit's character.
Architecture
Ordinary scenes for the arena, player, camera, weapon, and UI; the horde and projectiles are
centralized systems over preallocated packed arrays (no per-bird nodes, bodies, agents, timers,
or scripts). RoundController drives one deterministic simulation step per physics tick:
input → player move → flow field slice → bird motion + player contact + world collision → spatial grid → melee → firing → projectile sweeps → steering cohort → deferred removals → render upload → outcome (loss evaluated before victory).
| Component | File | Responsibility |
|---|---|---|
| RoundController | round_controller.gd |
LOADING → READY → PLAYING → WON/LOST (+ RESETTING), seed, restart |
| PrototypeConfig | prototype_config.gd |
all settings, capacities, stress flags |
| AssetCatalog | asset_catalog.gd |
explicit asset paths, derived bird mesh, filtered animation library |
| ArenaLayout / Arena | arena_layout.gd, arena.gd |
footprints → visuals + physics boxes |
| ArenaNavigation | arena_navigation.gd |
inflated occupancy, sliced octile flow field, footprint queries |
| SpatialGrid | spatial_grid.gd |
per-tick counting-sort buckets of bird indices |
| ChaseBehavior | chase_behavior.gd |
replaceable policy: desired direction per bird |
| HordeSystem | horde_system.gd |
dense pooled bird state, motion, contacts, melee, sweeps, removal |
| HordeRenderer | horde_renderer.gd |
MultiMesh dense prefix + interpolated buffer upload (birds and bullets) |
| ProjectileSystem | projectile_system.gd |
fixed pool, swept world + bird hits, expiry |
| PlayerController | player_controller.gd |
movement, facing, animation, authoritative health |
| WeaponController | weapon_controller.gd |
cadence, fresh-press rule, gun, fire requests |
| PlayerInput / ScriptedInput | player_input.gd, scripted_input.gd |
devices, dead zones, switching / benchmark script |
| CameraRig | camera_rig.gd |
fixed ortho framing, camera-relative basis, cursor projection |
| PrototypeHUD | prototype_hud.gd |
health, birds left, end screen, 4 Hz overlay |
| PerfStats / BenchmarkRunner | perf_stats.gd, benchmark_runner.gd |
timing rings, presets, reports |
Key mechanics:
- Pools. Birds: dense slots + stable ids with generation counters; swap-removal moves the last bird (all state + render slot) into the freed slot and updates id ↔ slot mappings. Kills are deferred to the end of the tick. Reused slots reset every field. Exhaustion skips the spawn and increments a visible counter; pools never grow mid-round and live bullets are never stolen.
- Rendering. One MultiMesh batch per pool with a fixed arena AABB;
visible_instance_count= active count, so dead birds and spent bullets stop rendering immediately. Buffers are written once per tick and interpolated by the RenderingServer (verified at a 2 Hz tick rate: birds move between frames of the same tick); spawned/swapped slots reset their interpolation. - Navigation. One shared flow field toward the player's reachable cell (nearest free cell if the player stands in the inflated clearance band). Obstacles are inflated by bird radius + 0.05 m; diagonal steps never cut a blocked corner; costs 5/7. Unreachable birds hold position. Within 2.5 m and with line of sight, birds steer straight at the player.
- Collision. Player:
CharacterBody3D(floating mode) against the world boxes. Birds: circle vs footprint push-out with sliding; every world resolve sees ≤ 0.19 m of displacement (one tick of motion + one bounded 0.15 m push), below half the thinnest footprint (0.25 m), so a bird can never tunnel. Birds yield to the player; birds pinned between player and wall push the player back through a collision-checked move. Crowds compress softly (measured ≤ 0.15 m bird/player overlap). - Projectiles. Zero-width rays with a visible tracer. Each tick the full segment is tested against the world (physics ray) and birds (exact relative-motion circle test over every grid cell the segment can touch, margin = hit radius + max per-tick bird displacement); the nearest hit wins, one bullet damages one bird. The weapon-origin → muzzle segment is tested at spawn.
- Melee. Birds in reach, off cooldown, with an unobstructed footprint line attack; the player's invulnerability is authoritative, so several same-tick attacks cost one health. A bird's cooldown starts on every attempt, accepted or not.
Decisions that differ from or refine the plan
- Mouse aim plane. The cursor is projected onto the horizontal plane at combat height, not the floor. At a 35° pitch, floor projection makes shots pass up to ~1.6 m from the cursor over a bird; the combat-height plane puts the cursor on the bullet path. The facing is corrected for the gun's 0.35 m side offset so the bullet line passes exactly through the cursor point.
- Flow-field slicing. Measured before adding it: a full rebuild costs ~2.2 ms (compact, 4,624 cells) / ~9 ms (enlarged, 17,956 cells) in GDScript. Rebuilds are processed 1,200 cells per tick (≤ 0.8 ms/tick); the previous field is used until the new one completes. No threads.
- Near-side fences are low (0.6 m) so the camera sees the whole floor; bullets fly over them and are recycled at the arena edge.
- Attack cooldown starts even when invulnerability rejects the hit.
Tests
godot --headless --path . --script res://game/tests/run_tests.gd # game
godot --headless --path . --fixed-fps 60 --script res://prototype/tests/run_tests.gd # prototype
Game: 298 checks, about 1.3 s. Covers FarmState round trips (also through JSON) and rejection
of invalid data, every outcome rule including the loss-before-completion tie on the final dawn,
failure in every phase, the untimed morning, phase order and lengths, exactly five nights,
starting the night early (off by default), per-night loss records, and retrying a failed night
from its morning. The farm layout suite checks one non-overlapping zone per kind inside the
60 × 60 m map, zone lookup, the 30 crop units, the gap and crow markers, a perimeter fence with no
holes outside its gaps, ground-enemy routes from every gap to every zone, that the scarecrow can't
walk out through a gap, zone-to-zone travel times (at most 12 s), and the zone banner.
Prototype: 107 checks, ~1.5 s. Covers pool acquire/release/exhaustion and swap identities, slot reuse hygiene and stale handles, U-shape routing, corner cutting, unreachable spawns, octile costs, nearest-hit / wall-blocks / high-speed / muzzle-through-wall / relative-motion / dead-target sweeps, bullet exhaustion and expiry, mouse aim in 96 directions, gamepad aim in 8 directions, dead zones, device switching, normalized diagonals, three-hit death, same-tick invulnerability, melee blocked by cover, fire cadence and fresh-press rule, victory, loss, the tie policy, idempotent restart, exact restarts from play/victory/death, 20 resets with stable object/node counts and signal connections, and 15 s of a 64-bird bottleneck crowd with zero footprint overlaps.
Benchmarks
./benchmarks/run_benchmarks.sh # fullscreen on screen 0, ~15 min, writes benchmarks/results
python3 benchmarks/summarize.py # Markdown table of all results
Single run example: godot --path . --fullscreen -- --preset=stress2000 --layout=enlarged --scenario=spread --bench --warmup=10 --duration=60 --vsync=off --quit-after=72. See the header
of prototype/scripts/benchmark_runner.gd for every option (--screenshot, --camera-zoom,
--physics-ticks, --seed, ...). Presets are labeled stress configurations: invulnerable
player, killed birds recycled, scripted route and sweeping fire — collision, melee, and
navigation stay fully enabled.
Known limitations and unverified items
- Not a release build. No export templates are installed; all measurements run the project with the 4.7.2 editor binary and are labeled as such.
- Gamepad not physically tested (no controller was connected). Gamepad aim, dead zones, and switching are covered by tests that inject actions/events, not by hardware.
- VSync and hidden windows. On this desktop (labwc via XWayland), a VSync-enabled window that is not visible is throttled to ~1 FPS by the compositor; VSync-on checks need a visible window.
- Measured on one machine only (see the report); minimum hardware is not defined.
- Native Wayland (
--display-driver wayland) was not tested; Godot ran under X11/XWayland. - Animation: backward movement uses a walking clip (foot slide at run speed); no hit reaction clip.
- Birds' wings overlap visually in dense crowds (collision fits the torso by design).
- GDScript bounds the scalable population (see report); native code would be a separate scope decision.