
Bevy Game Loop Collection
Bevy 0.20 collection loop: pickup markers, a quota resource, one score per entity per...
Install
npx skills add thedivergentai/Game-Dev-Agentic-Skills --skill bevy-game-loop-collection -g -a claude-code -y- Repository
- thedivergentai/Game-Dev-Agentic-Skills917
- Category
- Engineering
- Updated
- 19d ago
- License
- LGPL-3.0
- Context cost
- Mediumabout 2,060 tokens
- Runs scripts
- No, instructions only
What it does
Bevy 0.20 collection loop: pickup markers, a quota resource, one score per entity per pass, and NextState when the quota is met. Use when the run is about collecting objects. Keywords: Bevy, collection, pickup, quota, NextState, ECS.
Bevy collection loop
When to use
Load this when the run is about picking up objects and reaching a count.
ECS shape
- Components: a collected flag and a quota resource you define.
- Resources: run-wide tables live in a resource (bevy-data-resources), not an autoload.
- Systems: mutate those components on
Updateor the fixed timestep. Use.chain()when damage must land before death. - Messages: one-shot facts (hit, pickup, quest advance) go through bevy-events-messaging. This file does not add a new event type name.
Engine counterparts
| Godot idea | Bevy idiom |
|---|---|
| Pickup | A component marker. Detection waits on spatial queries. |
| Quota | A resource count. |
| Win | A state change via bevy-state-machines. |
Scope
A collectible is a marker component. Overlap is a distance check you own until a physics skill supplies contacts. Mark each entity once per pass: Commands::despawn applies later, so a second collector would otherwise score the same pickup. The quota is a resource. Reaching it writes NextState, which the state schedule applies after this system.
[dependencies]
bevy = "0.20"
#[derive(Component)]
struct Collectible {
points: u32,
}
#[derive(Component)]
struct Collector;
#[derive(Resource)]
struct CollectionScore {
points: u32,
quota: u32,
}
#[derive(States, Debug, Clone, Copy, PartialEq, Eq, Hash, Default)]
enum RunState {
#[default]
Playing,
Won,
}
