This commit is contained in:
Schluffe
2026-09-04 13:57:52 +02:00
parent 71cfa64793
commit e961887953
24 changed files with 340 additions and 360 deletions
+13 -11
View File
@@ -19,27 +19,29 @@ bunx serve workshop/steps/11-capstone
```
Arrow keys move the pink box. Run it into the border, the ledge, the pillar, the
bar. Push diagonally into a wall and watch it **slide** along instead of sticking.
That sliding is your step-09 `dot`-product projection. The fact that it stops
*at* the wall instead of tunneling through, even at speed, is your step-07 swept
detection. The clean corners are your step-10 loop running twice in one frame.
bar. Push diagonally into a wall and watch it **slide** along instead of
sticking. That sliding is your step-09 `dot`-product projection. The fact that
it stops _at_ the wall instead of tunneling through, even at speed, is your
step-07 swept detection. The clean corners are your step-10 loop running twice
in one frame.
## Make it yours (optional)
- Open `game.js`. The top half is your kernel — read it and confirm it matches
what you wrote. Swap in your own `moveAndSlide` from step 10 and check it feels
identical (it will).
what you wrote. Swap in your own `moveAndSlide` from step 10 and check it
feels identical (it will).
- Add a wall to the `walls` array. Change `SPEED`. Make the player bigger.
- Try **deleting the `EPSILON` backoff** (`Math.max(0, nearest.time - EPSILON)`
→ `nearest.time`) and push into a wall. Watch it stick and jitter. Then put it
back. Now you've *felt* why that line exists in your real engine.
back. Now you've _felt_ why that line exists in your real engine.
## You're back
That's the whole climb: pairs of numbers → sweeping a point → sweeping a box via
Minkowski → detecting the hit → stopping and sliding → the full loop → a thing you
can play. Every rung is a function that exists, by name, inside your real
Minkowski → detecting the hit → stopping and sliding → the full loop → a thing
you can play. Every rung is a function that exists, by name, inside your real
`engine/system/physics.ts`.
Now go open the real `sweptAABB` with fresh eyes. You know exactly what every line
is *supposed* to do — so the two lines that don't should stand out. Happy hunting.
Now go open the real `sweptAABB` with fresh eyes. You know exactly what every
line is _supposed_ to do — so the two lines that don't should stand out. Happy
hunting.
+55 -55
View File
@@ -1,61 +1,61 @@
<!doctype html>
<html lang="en">
<head>
<meta charset="utf-8" />
<meta name="viewport" content="width=device-width, initial-scale=1" />
<title>nage physics kernel — capstone</title>
<style>
html,
body {
margin: 0;
height: 100%;
background: #0b0c10;
color: #c8cde0;
font: 14px/1.5 ui-monospace, "SF Mono", Menlo, monospace;
display: grid;
place-items: center;
}
.wrap {
text-align: center;
}
canvas {
width: 720px;
max-width: 96vw;
height: auto;
image-rendering: pixelated;
border: 1px solid #2e3550;
border-radius: 4px;
box-shadow: 0 10px 40px #0008;
}
h1 {
font-size: 15px;
font-weight: 600;
letter-spacing: 0.02em;
color: #ee459e;
margin: 0 0 12px;
}
p {
margin: 12px 0 0;
color: #7d84a0;
}
kbd {
background: #1b1f2b;
border: 1px solid #2e3550;
border-radius: 3px;
padding: 1px 6px;
color: #c8cde0;
}
</style>
</head>
<body>
<div class="wrap">
<h1>your swept-AABB kernel, live</h1>
<canvas id="view" width="240" height="160"></canvas>
<p>
<head>
<meta charset="utf-8" />
<meta name="viewport" content="width=device-width, initial-scale=1" />
<title>nage physics kernel — capstone</title>
<style>
html,
body {
margin: 0;
height: 100%;
background: #0b0c10;
color: #c8cde0;
font: 14px/1.5 ui-monospace, "SF Mono", Menlo, monospace;
display: grid;
place-items: center;
}
.wrap {
text-align: center;
}
canvas {
width: 720px;
max-width: 96vw;
height: auto;
image-rendering: pixelated;
border: 1px solid #2e3550;
border-radius: 4px;
box-shadow: 0 10px 40px #0008;
}
h1 {
font-size: 15px;
font-weight: 600;
letter-spacing: 0.02em;
color: #ee459e;
margin: 0 0 12px;
}
p {
margin: 12px 0 0;
color: #7d84a0;
}
kbd {
background: #1b1f2b;
border: 1px solid #2e3550;
border-radius: 3px;
padding: 1px 6px;
color: #c8cde0;
}
</style>
</head>
<body>
<div class="wrap">
<h1>your swept-AABB kernel, live</h1>
<canvas id="view" width="240" height="160"></canvas>
<p>
<kbd>↑</kbd> <kbd>↓</kbd> <kbd>←</kbd> <kbd>→</kbd> to move — run into
the walls and feel it slide
</p>
</div>
<script src="./game.js"></script>
</body>
</div>
<script src="./game.js"></script>
</body>
</html>