time for a snapshot

This commit is contained in:
Schluffe
2026-07-11 17:48:28 +02:00
parent 135b7c3042
commit 7262752e16
47 changed files with 1712 additions and 61 deletions
+31
View File
@@ -0,0 +1,31 @@
# Step 01 — Vectors
> You know this cold. The point of this step is to make the red→green loop
> automatic, not to teach you arithmetic. Blast through it.
## Concept
A **vector** here is nothing mystical: a pair of numbers `(x, y)`. We use the
same value to mean two different things depending on context:
- a **position** — a point in the world.
- a **displacement / velocity** — an arrow: "move this much in x, this much in y."
That's it. All of 2D physics is built on adding, subtracting, and scaling these
pairs.
- `add(a, b)` → `(a.x + b.x, a.y + b.y)` — apply an arrow to a point.
- `sub(a, b)` → `(a.x - b.x, a.y - b.y)` — the arrow that points *from b to a*.
- `scale(a, s)` → `(a.x * s, a.y * s)` — make an arrow longer/shorter.
> Note: we return **new** objects (pure functions) here for clarity. Your real
> engine mutates vectors in place to avoid garbage collection — that's a speed
> optimization we'll deliberately ignore until the very end.
## Task
Implement `vec`, `add`, `sub`, and `scale` in `vector.ts`.
```sh
bun test workshop/steps/01-vectors
```