Skip to content

Commit c5c1d32

Browse files
committed
add controls info
1 parent 8ce7c37 commit c5c1d32

File tree

2 files changed

+45
-29
lines changed

2 files changed

+45
-29
lines changed

src/App.tsx

Lines changed: 33 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ import { STATIC_GROUP } from "./collisionGroups";
55
import { Car } from "./components/Car";
66
import { Cones } from "./components/Cones";
77
import { Ramp } from "./components/Ramp";
8+
import { Ui } from "./components/Ui";
89

910
function AppWrapper({ children }: PropsWithChildren) {
1011
return (
@@ -26,35 +27,38 @@ function App() {
2627
const shadow_map_size = 2048;
2728

2829
return (
29-
<AppWrapper>
30-
<ambientLight intensity={0.2} />
31-
<directionalLight
32-
position={[-5, 5, 0]}
33-
shadow-camera-top={shadow_size}
34-
shadow-camera-right={shadow_size}
35-
shadow-camera-bottom={-shadow_size}
36-
shadow-camera-left={-shadow_size}
37-
shadow-mapSize-height={shadow_map_size}
38-
shadow-mapSize-width={shadow_map_size}
39-
castShadow
40-
ref={lightRef}
41-
/>
42-
<Car lightRef={lightRef} />
43-
<RigidBody
44-
collisionGroups={interactionGroups(STATIC_GROUP)}
45-
type="fixed"
46-
position={[0, -2, 0]}
47-
>
48-
<mesh position={[75, 0, 0]} receiveShadow>
49-
<boxGeometry args={[300, 2, 150]} />
50-
<meshStandardMaterial />
51-
</mesh>
52-
</RigidBody>
53-
<Ramp position={[30, -2, 0]} />
54-
<Ramp position={[70, -2, 0]} />
55-
<Ramp position={[110, -2, 0]} />
56-
<Cones />
57-
</AppWrapper>
30+
<>
31+
<Ui />
32+
<AppWrapper>
33+
<ambientLight intensity={0.2} />
34+
<directionalLight
35+
position={[-5, 5, 0]}
36+
shadow-camera-top={shadow_size}
37+
shadow-camera-right={shadow_size}
38+
shadow-camera-bottom={-shadow_size}
39+
shadow-camera-left={-shadow_size}
40+
shadow-mapSize-height={shadow_map_size}
41+
shadow-mapSize-width={shadow_map_size}
42+
castShadow
43+
ref={lightRef}
44+
/>
45+
<Car lightRef={lightRef} />
46+
<RigidBody
47+
collisionGroups={interactionGroups(STATIC_GROUP)}
48+
type="fixed"
49+
position={[0, -2, 0]}
50+
>
51+
<mesh position={[75, 0, 0]} receiveShadow>
52+
<boxGeometry args={[300, 2, 150]} />
53+
<meshStandardMaterial />
54+
</mesh>
55+
</RigidBody>
56+
<Ramp position={[30, -2, 0]} />
57+
<Ramp position={[70, -2, 0]} />
58+
<Ramp position={[110, -2, 0]} />
59+
<Cones />
60+
</AppWrapper>
61+
</>
5862
);
5963
}
6064

src/components/Ui.tsx

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
export function Ui() {
2+
return (
3+
<div
4+
className="w-fit p-2 pr-4 rounded-br-2xl flex flex-col justify-center bg-neutral-900/50 font-mono"
5+
style={{ textShadow: "1px 1px 1px black" }}
6+
>
7+
<h3 className="text-xl">Controls:</h3>
8+
<p>wasd: drive</p>
9+
<p>r: flip car</p>
10+
</div>
11+
);
12+
}

0 commit comments

Comments
 (0)