Repository navigation
Village gathering
A player of the Village walk can gather things about the village: herbs, mushrooms, berries, ore, coins from a chest, lost trinkets and fish. The use button gathers the thing in reach. A heads-up display shows what the player holds.
The modules are extensions/village/gathering.mojo and extensions/village/hud.mojo. VillageGame builds a Gathering from PlayParameters.gathering, and runs it in each tick.
Walk to a spot. A gold marker turns over it when it is in reach. Then press the use button: E on the keyboard, or the west button of a gamepad. The west button is X on an Xbox controller and the square on a PlayStation controller.
A held button gathers once. Let it go and press it again to gather again.
GatherKind is a type with is_valid. A bare integer does not compile.
| Kind | What it is | A use gives | It comes back |
|---|---|---|---|
HERBS |
A tuft of leaves with pale violet flowers | 1 herb | After the respawn time |
MUSHROOMS |
A cluster of five red-capped mushrooms | 2 mushrooms | After the respawn time |
BERRIES |
A low bush hung with berries. The bush stays. | 3 berries | After the respawn time |
ORE |
A boulder with copper nuggets. It takes STRIKES, three, uses. The boulder stays. |
1 ore | After the respawn time |
CHEST |
An iron-bound chest. Its lid swings open. |
CHEST_COINS, twelve, coins |
Never |
TRINKET |
A gold ring hung with a gem, which bobs and turns 90 centimeters up | 1 trinket | Never |
FISH |
An oak stake and a creel on the pond's shore | 1 fish, when hooked | It is never used up |
A boulder, a chest and a berry bush stop a character. Gathering.obstacles gives each as round: 0.6, 0.45 and 0.4 meters across. A character walks through herbs, mushrooms and trinkets.
A fishing spot's float lies on the water CAST, 3.2 meters, out along the spot's turn. Turn the spot to face the pond.
- A press casts the float. The prompt says
E REEL IN. - After two to six seconds a fish bites. The float dips and jerks for
BITE, 1.2 seconds. The prompt saysE HOOK IT!. - A press while the fish bites hooks it, and the satchel holds one more fish.
A press before the bite reels the line in, and nothing is caught. A bite that is missed lets the fish get away. A player who walks out of reach reels the line in.
from extensions.village.gathering import (
HERBS,
GatherParameters,
Gathering,
Spot,
)
from units.si import RADIAN, SECOND, Angle, Duration
var parameters = GatherParameters()
parameters.spots.append(Spot(HERBS, 4, 12, Angle(0.5, RADIAN)))
parameters.respawn = Duration(30.0, SECOND)
var gathering = Gathering(scene, assets, looks, parameters, ground, lots)Gathering leaves out each spot on a lot or its apron, and each spot in the water, as the meadow does with a tree. The spots wear the houses' materials, HouseLooks. A boulder is the meadow's boulder.
GatherParameters() holds the default village's 17 spots, with a fishing spot on the pond's west shore. Its reach is 1.8 meters, and its respawn time is 60 seconds.
Gathering.update runs one frame:
- Each spot that waits counts down its respawn time. A spot whose time is over is ready again, and shows.
- The focus is the ready spot nearest the player's feet. It must be within the reach, and less than 1.5 meters above or below the feet.
- On a new press of the use button, the focus is used. What it gives goes into the
Satchel. The part that is gathered hides. A boulder gives its ore on its last strike only. - Each trinket bobs and turns. Each chest's lid swings open at 2 radians a second, to 1.9 radians.
- A shimmer of four gold motes turns over each ready spot. The marker turns and bobs over the focus, and hides when there is none.
update returns the kind that gave something this frame, or None. Satchel.last holds how many things it gave.
The player's skills change three settings of Gathering: ore_strikes, forage_bonus and fish_haste. See Village skills.
draw_hud writes these things over the window's frame, after the frame is stretched:
| Part | Where | What it says |
|---|---|---|
| The satchel | The bottom left | A swatch and a count for each kind the player holds |
| The prompt | The bottom middle | What the use button does at the focus, such as E MINE ORE 1/3
|
| The note | Over the prompt | What the player gathered, such as +3 BERRIES, for 2 seconds. It fades over its last half second. |
| The speech | Over the note | What a villager said, for 5 seconds. See Village errands. |
| The errands | The top right | Each errand taken and not done |
| The skills | The top left | Each skill's level and experience. See Village skills. |
The font has 5 by 7 dots and needs no font file. It draws capitals, digits, and + / : . , ! ? ' -. A dot is hud_scale pixels on a side: one pixel for each 270 pixels of the frame's height. So the text keeps its size on the screen. Each line has a dark shadow, so it reads over the sky and the grass.
Set PlayParameters.hud to False for a frame with no display.
- A spot does not stop the camera.
- The satchel counts things. It does not hold items with their own state. An errand takes things out of it: see Village errands.
- The note shows the last thing gathered only.
- Coins are spent nowhere yet.
Tutorials
How-to
- Install
- Run the checks
- GPU backend
- Coverage
- Measure examples
- Add a feature
- Add a scanned building
- Write documentation
Reference
- Scene graph
- Rotations
- Cameras
- Geometry
- Geometry addons
- Lofts and clipping groups
- Sculptor
- Procedural generators
- Meshes and assets
- Lines
- Points and sprites
- Helpers
- Scene objects
- Animated objects
- Raycasting
- Curves and paths
- Animation
- Skinning
- Materials
- Node materials
- TSL functions
- Lights
- Lighting addons
- Fog
- Textures
- Renderer
- Renderer hooks and material flags
- Rasterization
- GPU backend
- Render target
- Post-processing
- GPU computation
- Compute nodes
- Progressive light map
- Gaussian splats
- Voxel global illumination
- SVG renderer
- Image files
- Image decode queue
- Model files
- More model files
- Exporters
- Scene JSON
- Windowing and controls
- C ABI and hosts
- Math
- Norm consumers
- Math addons
- Units
- Coverage tool
- Commands
- Examples
- Benchmarks
- Extensions
- Shared physics
- Physics query snapshots
- Continuous collision
- Tick force restoration
- Water
- Vegetation
- Village
- Streamline
- Animals
- Buildings
- CARLA
- Femur
- Tibia
- Fibula
- Patella
- Knee
- Muscles
- Vessels
- Lymph
- Nerves
- Integument
- Leg
- Foot
- Pelvis
- Torso
- Arm
- Hand
- Head
- Genome
- Game humanoid
- Humanoid fidelity
- Mixamo animations
- Audio-aligned game faces
- Converted assets
- Mesh quality
- Garments
- Outfits and armor
- Cloth and spring bones
- Attire estimates
- Segment inertia
Explanation
- Software rasterizer
- Scene graph as an array
- Linear color
- Normals are not colors
- Perspective correction
- Fixed-point coverage
- Per-fragment shading
- Mipmaps
- Sorted transparency
- Types and checks
- Render hooks as a trait
- Shared CPU and GPU code
- Bands and threads
- PNG structure
- Extensions beside the port
- Scans as building models
- CUDA teardown hang
- Mojo compiler hang