1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
|
/*
* ============================================================
* FILE: world.c
*
* PURPOSE: The blank test world: an empty, flat square of ground where we
* tune movement. It stays empty on purpose, like the test space
* SM64's team used before building real levels.
*
* FITS IN: Implements world.h. Has no dependencies besides config.h and
* math3d.h. physics.c is its main caller.
*
* IMPLEMENT:
* - world_init(): nothing to do yet. Leave a comment saying this is where
* level data would be loaded.
* - world_ground_height(x, z): return 0.0f. Mark the unused parameters with
* (void)x; (void)z; so -Wextra stays quiet, and add a comment saying this
* is where a heightmap/platform lookup will go.
* - world_clamp_to_bounds(p): clamp p.x and p.z with clampf from math3d.h.
* - world_spawn_point(): return vec3_make(0, 0, 0).
* - world_half_extent(): return WORLD_HALF_EXTENT.
*
* CONVENTIONS: Y up. The ground surface is the plane y = world_ground_height.
*
* NOT IN SCOPE: Anything that isn't flat ground. Don't build a collision
* system "for later"; add it when the first platform shows up.
*
* DONE WHEN: It compiles warning-free, and the player can't leave the square.
* ============================================================
*/
#include "config.h"
#include "world.h"
void world_init(void)
{
/* Nothing to do yet. This is where level data would be loaded. */
}
float world_ground_height(float x, float z)
{
/* The world is flat for now. This is where a heightmap/platform lookup
* will go once there's terrain to stand on. */
(void)x;
(void)z;
return 0.0f;
}
/* Keeps x and z on the ground square; y (height) is untouched. */
Vec3 world_clamp_to_bounds(Vec3 p)
{
p.x = clampf(p.x, -WORLD_HALF_EXTENT, WORLD_HALF_EXTENT);
p.z = clampf(p.z, -WORLD_HALF_EXTENT, WORLD_HALF_EXTENT);
return p;
}
Vec3 world_spawn_point(void)
{
return vec3_make(0.0f, 0.0f, 0.0f);
}
float world_half_extent(void)
{
return WORLD_HALF_EXTENT;
}
|