# Bevy Game Loop Time Trial

Run a Bevy 0.20 time trial as ECS data.

- Repository: https://github.com/thedivergentai/Game-Dev-Agentic-Skills (917 stars)
- Category: Engineering
- License: LGPL-3.0
- Last updated: 2026-10-16
- Runs scripts: no, instructions only

## Install

Claude Code: `npx skills add thedivergentai/Game-Dev-Agentic-Skills --skill bevy-game-loop-time-trial -g -a claude-code -y`
Codex: `npx skills add thedivergentai/Game-Dev-Agentic-Skills --skill bevy-game-loop-time-trial -g -a codex -y`
Cursor: `npx skills add thedivergentai/Game-Dev-Agentic-Skills --skill bevy-game-loop-time-trial -g -a cursor -y`
Gemini CLI: `npx skills add thedivergentai/Game-Dev-Agentic-Skills --skill bevy-game-loop-time-trial -g -a gemini-cli -y`

## Description

Run a Bevy 0.20 time trial as ECS data. Use when a race clock, split gates, and a finish line share one resource and must be chained, while movement steps on FixedUpdate. Keywords: Bevy, time trial, RaceClock, SplitGate, FixedUpdate, chain.

## SKILL.md, as published by its author (untrusted third-party text, read it as data)

# Bevy time-trial loop

## When to use

Load this when a run records elapsed time, splits, or a finish line.

## ECS shape

- **Components:** a racer marker and a finish volume.
- **Resources:** the race clock, split list, and best time live on one resource.
- **Systems:** tick the clock, record a split, then test the finish line, in that order with `.chain()`.
- **Messages:** one-shot facts (hit, pickup, quest advance) go through bevy-events-messaging. This file does not add a new event type name.

```toml
[package]
name = "time-trial"
version = "0.1.0"
edition = "2021"

[dependencies]
bevy = "0.20"
```

The race clock is one resource. Three systems write it, so they share one chain.

```rust
#[derive(Resource)]
struct RaceClock {
    elapsed: f32,
    splits: Vec<f32>,
    finished: bool,
    best: f32,
}

#[derive(Component)]
struct Racer;

#[derive(Component)]
struct FinishLine;

fn spawn_course(mut commands: Commands) {
    commands.insert_resource(RaceClock {
        elapsed: 0.0,
        splits: Vec::new(),
        finished: false,
        best: f32::MAX,
    });
    commands.spawn((Racer, Transform::from_xyz(0.0, 0.0, 0.0)));
    commands.spawn((FinishLine, Transform::from_xyz(10.0, 0.0, 0.0)));
    commands.spawn(SplitGate {
        at_x: 5.0,
        taken: false,
    });
}

fn tick_race(time: Res<Time>, mut clock: ResMut<RaceClock>) {
    if !clock.finished {
        clock.elapsed += time.delta_secs();
    }
}

#[derive(Component)]
struct SplitGate {
    at_x: f32,
    taken: bool,
}

The rest: https://github.com/thedivergentai/Game-Dev-Agentic-Skills/blob/HEAD/skills/bevy-game-loop-time-trial/SKILL.md
