1.9 KiB
1.9 KiB
Bevy Quick Reference
Core mental model
Bevy app = plugins + schedules + systems + ECS data.
- Entity: ID
- Component: data attached to entity
- System: function operating on ECS data
- Resource: singleton global-ish state
- Event: decoupled message
- State: app/game phase control
- Plugin: feature boundary
Default 2D startup
Typical minimum:
- add
DefaultPlugins - spawn
Camera2d - later: sprites, transforms, input systems
Good first feature order
- camera
- player entity
- movement
- bounds / collision
- score / HUD
- game state
- win / lose loop
- juice: audio, particles, animation
ECS rules
Good:
- data-only components
- small systems
- clear queries
- events for cross-feature signaling
Bad:
- single mega resource for all state
- one system doing input + movement + combat + UI
- hidden state mutation in many places
- coupling features through direct queries everywhere
Naming
Prefer:
PlayerVelocityHealthScoreGameStatespawn_playermove_playerupdate_score_ui
Avoid vague names:
DataInfodo_stuffmanager
Common patterns
Resource pattern
Use for global config, score, timers, handles, current run state.
Event pattern
Use when one system announces and another reacts:
- enemy died
- score changed
- level completed
- damage taken
State pattern
Use for flow:
LoadingMenuPlayingPausedGameOver
Plugin pattern
Use for feature isolation:
- player
- UI
- combat
- level
Performance-first habits
- query only data needed
- avoid expensive string churn each frame
- keep UI rebuilds scoped
- avoid asset reloading loops
- prefer change detection / explicit triggers when useful
Workshop-safe scope
Keep small:
- one-screen loop
- one mechanic
- one UI counter
- one win/lose condition
- one polish pass