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
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
|
/*
* ============================================================
* FILE: config.h
*
* PURPOSE: Every tunable number in the game, in one place. When movement
* "feels wrong", this is the first (and usually only) file to edit.
*
* FITS IN: Included by almost every .c file. Contains only #defines,
* with no functions, no types and no includes.
* Nothing in the game should hard-code a number that appears here.
*
* INTERFACE: Plain #define constants, float literals with an `f` suffix.
* Give EVERY constant a one-line comment that says what it
* changes about the *feel*, e.g. "higher = snappier stops".
* Use these exact names (other files depend on them). The
* values are starting points for tuning:
*
* Window
* WINDOW_WIDTH 1280
* WINDOW_HEIGHT 720
* WINDOW_TITLE "platformer"
* SKY_COLOR_R/G/B 0.45f 0.65f 0.90f (clear color)
*
* Simulation timing
* TICK_HZ 60 (fixed logic rate; SM64 used 30)
* TICK_DT (1.0f / TICK_HZ) (seconds per tick)
* MAX_FRAME_TIME 0.25f (clamp to avoid a "spiral of death"
* after a stall / breakpoint)
*
* Input
* MOVE_DEADZONE 0.20f (radial, left stick)
* LOOK_DEADZONE 0.20f (radial, right stick)
* LOOK_AXIS_SNAP_DEG 15.0f (right stick: pushes this close
* to straight up/down/left/right
* become exactly that direction)
*
* Player: ground movement
* PLAYER_MAX_SPEED 6.0f m/s at full stick tilt (kept modest on purpose:
* later moves will be the way to go faster)
* PLAYER_GROUND_ACCEL 8.4f m/s^2 speeding up toward target speed
* PLAYER_GROUND_FRICTION 11.3f m/s^2 slowing down with no input (a short skid)
* PLAYER_TURN_RATE 12.0f rad/s max facing rotation on ground
* PLAYER_SNAP_TURN_DEG 90.0f degrees; from a standstill, stick pushes
* more than this away from facing turn
* instantly (smaller ones use the turn rate)
*
* Player: air movement
* PLAYER_AIR_CONTROL 0.30f 0..1 multiplier on turn rate in air
* PLAYER_AIR_ACCEL 9.0f m/s^2 speeding up toward target speed in air
* PLAYER_JUMP_VELOCITY 14.0f m/s upward at jump start (~2.4 m apex)
* PLAYER_JUMP_CUT 0.50f vel.y multiplier when A released while rising
* PLAYER_JUMP_MAX_SPEED 7.0f m/s top horizontal speed during a normal
* jump (a little past the run speed)
* PLAYER_JUMP_BOOST_ACCEL 1.5f m/s^2 how slowly speed builds past the run
* speed in a normal jump (~7 m/s by landing)
* PLAYER_OVERSPEED_DECEL 2.0f m/s^2 how slowly speed above the run speed
* eases back down on the ground
* PLAYER_SECOND_JUMP_VELOCITY 18.41f m/s upward at second-jump start (1.75x
* the first jump's height, ~4.1 m apex)
* PLAYER_SECOND_JUMP_WINDOW 0.2f s after landing a jump that the second
* jump is available (heightened_movement)
* PLAYER_SECOND_JUMP_MAX_SPEED 5.0f m/s top horizontal speed during the second
* jump (it trades speed for height)
* PLAYER_SECOND_JUMP_SLOWDOWN 3.5f m/s^2 how fast speed above that top speed
* bleeds off in the air (gradual on purpose)
*
* Player: skid and retreat jump
* PLAYER_SKID_ANGLE_DEG 120.0f degrees; pulling the stick more than this
* away from the run direction skids
* PLAYER_SKID_SPEED_FRACTION 0.95f of PLAYER_MAX_SPEED; a skid needs a full
* run (or faster, once later moves exist)
* PLAYER_SKID_DURATION 0.5f s a skid lasts; it always ends stopped
* PLAYER_SKID_GLIDE_POWER 2.0f shape of the skid's braking: speed =
* start * (1 - (t / duration)^power).
* 1 = even braking; higher = glides
* longer, then plants harder at the end
* PLAYER_RETREAT_JUMP_VELOCITY 19.66f m/s upward for the jump out of a skid
* (2x the first jump's height, ~4.7 m)
* PLAYER_RETREAT_JUMP_SPEED 4.0f m/s launched toward the stick, and the top
* speed until that jump lands
*
* Player: wall hang
* PLAYER_WALL_HANG_ANGLE_DEG 45.0f degrees; how far off head-on the player may
* hit a hangable wall and still hang
* PLAYER_WALL_HANG_DURATION 0.5f s the hang lasts before the player lets go
* PLAYER_WALL_SLIDE_ACCEL 3.0f m/s^2 how slowly the hang slides downward
* PLAYER_WALL_SLIDE_MAX_SPEED 2.0f m/s fastest slide down the wall
* PLAYER_WALL_JUMP_EARLY_TIME 0.1f s into the hang that a wall jump is still
* the high, second-jump-like one
*
* Physics
* GRAVITY 40.0f m/s^2 (stronger than real 9.8 on purpose:
* platformers feel floaty with real gravity)
* TERMINAL_VELOCITY 50.0f m/s max fall speed
*
* Player: size (used by render, and later by collision)
* PLAYER_HALF_WIDTH 0.4f m
* PLAYER_HEIGHT 1.6f m (body.pos is the player's FEET)
*
* Camera
* CAMERA_DISTANCE 10.0f m from target
* CAMERA_TARGET_HEIGHT 1.0f m above player's feet to look at
* CAMERA_PITCH_DEFAULT 0.35f rad above horizontal
* CAMERA_PITCH_MIN 0.05f rad
* CAMERA_PITCH_MAX 1.20f rad
* CAMERA_YAW_SPEED 2.5f rad/s at full right-stick tilt
* CAMERA_PITCH_SPEED 1.125f rad/s at full right-stick tilt
* CAMERA_FOLLOW_RATE 8.0f 1/s; how fast the camera's DISTANCE catches up
* when the player runs toward/away from it
* CAMERA_ZONE_INSET 0.05f fraction of the window between the resting
* zone and the running bound, on every side
* CAMERA_ZONE_TOP 0.50f window fraction (0 = bottom) of the resting
* zone's top edge; lower = more view ahead
* CAMERA_SETTLE_RATE 3.0f 1/s; how fast the camera re-frames a player
* who stopped outside the resting zone
* CAMERA_RECENTER_RATE 6.0f 1/s; how fast the recenter button swings
* behind the player and centers them
* CAMERA_MIN_HEIGHT 0.5f m; lowest the eye may go above the player's feet
* CAMERA_LEAD_RATE 1.0f 1/s; how fast a sideways run carries the player
* to the trailing thirds line (lead room ahead)
* CAMERA_SWING_OFFSET 0.52f rad (~30 deg) off directly-behind that a
* sideways run swings the camera toward
* CAMERA_SWING_SPEED 0.5f rad/s max swing rate on a fully sideways run
* CAMERA_AUTO_PITCH_DELAY 2.0f s without touching the camera before it tilts
* to its preferred angle on its own
* CAMERA_AUTO_PITCH_DEG 15.0f degrees; the preferred look-down angle
* CAMERA_AUTO_PITCH_SPEED 0.054f rad/s; top speed of that tilt
* CAMERA_AUTO_PITCH_ACCEL 0.045f rad/s^2; how gently the tilt speeds up
* and slows down (ease in/out)
* CAMERA_FOV_DEG 60.0f vertical field of view
* CAMERA_NEAR 0.1f
* CAMERA_FAR 500.0f
*
* World
* WORLD_HALF_EXTENT 100.0f m; the ground is a square of 2x this per side
* GRID_SPACING 1.0f m between grid lines
* GRID_MAJOR_EVERY 10 every Nth line drawn brighter
* WORLD_SEED 20260924u seed for the platform layout; change it
* for a different (but repeatable) level
* CLIFF_COURSE_SEED 20260930u seed for the cliff course's generated
* platforms (see level.c); change it for
* a different climb
* WORLD_PLATFORM_COUNT 40 how many platforms to scatter
* WORLD_PLATFORM_AREA 25.0f m; platforms land within this distance of
* spawn in x and z (smaller = denser)
*
* CONVENTIONS: 1 unit = 1 meter, seconds, radians (degrees only for names
* ending in _DEG, which are easier to tune by eye; converted where
* they're used). Include guard: CONFIG_H.
*
* NOT IN SCOPE: Runtime config files, command-line parsing, hot-reload.
*
* DONE WHEN: Every constant above exists with a comment, and no other
* file contains a magic number for any of these concepts.
* ============================================================
*/
#ifndef CONFIG_H
#define CONFIG_H
/* ---- Window ------------------------------------------------------------ */
#define WINDOW_WIDTH 1280 /* starting window width, pixels */
#define WINDOW_HEIGHT 720 /* starting window height, pixels */
#define WINDOW_TITLE "platformer" /* base title; main.c appends the debug readout */
#define SKY_COLOR_R 0.45f /* clear color: the "sky" behind everything */
#define SKY_COLOR_G 0.65f
#define SKY_COLOR_B 0.90f
/* ---- Simulation timing ------------------------------------------------- */
#define TICK_HZ 60 /* logic ticks per second; higher = lower input latency (SM64 used 30) */
#define TICK_DT (1.0f / TICK_HZ) /* seconds per tick; derived, don't edit */
#define MAX_FRAME_TIME 0.25f /* longest frame we catch up on; stops a "spiral of death" after a stall */
/* ---- Input ------------------------------------------------------------- */
#define MOVE_DEADZONE 0.20f /* left stick radius ignored; higher = less drift, less fine control */
#define LOOK_DEADZONE 0.20f /* right stick radius ignored; higher = camera harder to nudge */
#define LOOK_AXIS_SNAP_DEG 15.0f /* right stick pushes this close to an axis become pure up/down/left/right; 0 = off, keep < 45 */
/* ---- Player: ground movement ------------------------------------------- */
#define PLAYER_MAX_SPEED 6.0f /* m/s at full stick tilt; higher = faster top run speed (kept modest: later moves go faster) */
#define PLAYER_GROUND_ACCEL 8.4f /* m/s^2 toward target speed; lower = heavier, slower starts */
#define PLAYER_GROUND_FRICTION 11.3f /* m/s^2 slowdown with stick released; lower = longer skid to a stop */
#define PLAYER_TURN_RATE 12.0f /* rad/s max facing rotation on ground; higher = tighter turns */
#define PLAYER_SNAP_TURN_DEG 90.0f /* degrees; standing still, bigger turns than this are instant; lower = more snapping */
/* ---- Player: air movement ---------------------------------------------- */
#define PLAYER_AIR_CONTROL 0.30f /* 0..1 multiplier on turn rate in air; higher = jumps turn more sharply */
#define PLAYER_AIR_ACCEL 9.0f /* m/s^2 toward target speed in air; higher = more steerable jumps */
#define PLAYER_JUMP_VELOCITY 14.0f /* m/s upward at jump start; higher = taller jumps (~2.4 m apex at 14) */
#define PLAYER_JUMP_CUT 0.50f /* vel.y multiplier on early A release; lower = shorter taps */
#define PLAYER_JUMP_MAX_SPEED 7.0f /* m/s top horizontal speed in a normal jump; higher = bigger reward for jumping at full run */
#define PLAYER_JUMP_BOOST_ACCEL 1.5f /* m/s^2 build past run speed in a normal jump; higher = reaches PLAYER_JUMP_MAX_SPEED sooner */
#define PLAYER_OVERSPEED_DECEL 2.0f /* m/s^2 ease back down to run speed after landing (stick held); lower = keeps the extra speed longer */
#define PLAYER_SECOND_JUMP_VELOCITY 18.41f /* m/s upward for the second jump; tuned to 1.75x the first jump's height (4.08 m at 60 Hz) */
#define PLAYER_SECOND_JUMP_WINDOW 0.2f /* s after landing a normal or retreat jump that A gives the second jump; higher = more forgiving timing */
#define PLAYER_SECOND_JUMP_MAX_SPEED 5.0f /* m/s top horizontal speed until the second jump lands; lower = more vertical, less distance */
#define PLAYER_SECOND_JUMP_SLOWDOWN 3.5f /* m/s^2 bleed from run speed down to that top speed; lower = more gradual, higher = more abrupt */
/* ---- Player: skid and retreat jump ------------------------------------- */
#define PLAYER_SKID_ANGLE_DEG 120.0f /* degrees off the run direction that counts as "pulling back"; lower = skids trigger more easily */
#define PLAYER_SKID_SPEED_FRACTION 0.95f /* of PLAYER_MAX_SPEED needed to skid (full run or faster); lower = skid from slower runs */
#define PLAYER_SKID_DURATION 0.5f /* s from pulling back to stopped (and the retreat jump's window); higher = longer slide */
#define PLAYER_SKID_GLIDE_POWER 2.0f /* skid braking curve; 1 = even, higher = freer glide first, then a harder plant */
#define PLAYER_RETREAT_JUMP_VELOCITY 19.66f /* m/s upward for the jump out of a skid; tuned to 2x the first jump's height (4.67 m at 60 Hz) */
#define PLAYER_RETREAT_JUMP_SPEED 4.0f /* m/s launched toward the stick, and the top speed until landing; higher = travels farther */
/* ---- Player: wall hang -------------------------------------------------- */
#define PLAYER_WALL_HANG_ANGLE_DEG 45.0f /* degrees off head-on that still grabs a hangable wall; higher = grabs from shallower angles */
#define PLAYER_WALL_HANG_DURATION 0.5f /* s clinging before letting go and falling normally; higher = longer linger */
#define PLAYER_WALL_SLIDE_ACCEL 3.0f /* m/s^2 the cling slides down the wall; lower = stickier */
#define PLAYER_WALL_SLIDE_MAX_SPEED 2.0f /* m/s fastest slide down the wall while clinging */
#define PLAYER_WALL_JUMP_EARLY_TIME 0.1f /* s into the hang that A still gives the high (second-jump-like) wall jump; later = normal-jump-like */
/* ---- Physics ----------------------------------------------------------- */
#define GRAVITY 40.0f /* m/s^2; stronger than real 9.8 on purpose, real gravity feels floaty */
#define TERMINAL_VELOCITY 50.0f /* m/s max fall speed; lower = long falls feel more controlled */
/* ---- Player: size (used by render, and later by collision) ------------- */
#define PLAYER_HALF_WIDTH 0.4f /* m; half the box's width/depth */
#define PLAYER_HEIGHT 1.6f /* m; box height (body.pos is the player's FEET) */
/* ---- Camera ------------------------------------------------------------ */
#define CAMERA_DISTANCE 10.0f /* m from target; higher = see more, player looks smaller */
#define CAMERA_TARGET_HEIGHT 1.0f /* m above player's feet the camera looks at */
#define CAMERA_PITCH_DEFAULT 0.35f /* rad above horizontal at start */
#define CAMERA_PITCH_MIN 0.05f /* rad; lowest the camera can swing (just above the ground) */
#define CAMERA_PITCH_MAX 1.20f /* rad; highest the camera can swing (near top-down) */
#define CAMERA_YAW_SPEED 2.5f /* rad/s orbit at full right-stick tilt; higher = faster spin */
#define CAMERA_PITCH_SPEED 1.125f /* rad/s tilt at full right-stick tilt; lower = gentler up/down look */
#define CAMERA_FOLLOW_RATE 8.0f /* 1/s; how fast the distance catches up when running toward/away; lower = more lag */
#define CAMERA_ZONE_INSET 0.05f /* window fraction between resting zone and running bound; higher = tighter zone */
#define CAMERA_ZONE_TOP 0.50f /* resting zone's top edge (0 = bottom, 1 = top); lower = more view ahead of the player */
#define CAMERA_SETTLE_RATE 3.0f /* 1/s; re-framing after stopping outside the zone; lower = lazier, more cinematic */
#define CAMERA_RECENTER_RATE 6.0f /* 1/s; how fast recenter swings behind the player and centers them */
#define CAMERA_MIN_HEIGHT 0.5f /* m; lowest the eye may sit above the player's feet (keeps it out of the floor) */
#define CAMERA_LEAD_RATE 1.0f /* 1/s; sideways runs push the player to the trailing thirds line; higher = faster lead */
#define CAMERA_SWING_OFFSET 0.52f /* rad (~30 deg) off directly-behind that sideways runs swing toward; 0 = fully behind */
#define CAMERA_SWING_SPEED 0.5f /* rad/s swing rate on a fully sideways run; lower = slower, subtler swing */
#define CAMERA_AUTO_PITCH_DELAY 2.0f /* s hands-off before the camera tilts to CAMERA_AUTO_PITCH_DEG on its own */
#define CAMERA_AUTO_PITCH_DEG 15.0f /* degrees above horizontal the camera prefers to look down at the player */
#define CAMERA_AUTO_PITCH_SPEED 0.054f /* rad/s top tilt speed toward that angle; lower = slower, subtler tilt */
#define CAMERA_AUTO_PITCH_ACCEL 0.045f /* rad/s^2 ease in/out of the tilt; lower = softer start and stop */
#define CAMERA_FOV_DEG 60.0f /* vertical field of view, degrees; higher = wider, faster-feeling view */
#define CAMERA_NEAR 0.1f /* m; near clip plane */
#define CAMERA_FAR 500.0f /* m; far clip plane (must reach past the world edge) */
/* ---- World ------------------------------------------------------------- */
#define WORLD_HALF_EXTENT 100.0f /* m; the ground is a square of 2x this per side */
#define GRID_SPACING 1.0f /* m between grid lines; the grid is how you read speed */
#define GRID_MAJOR_EVERY 10 /* every Nth line drawn brighter, for reading distances */
#define WORLD_SEED 20260924u /* platform layout seed; change for a different (repeatable) level */
#define CLIFF_COURSE_SEED 20260930u /* cliff course layout seed (level.c); change for a different (repeatable) climb */
#define WORLD_PLATFORM_COUNT 40 /* platforms scattered around spawn; more = busier level */
#define WORLD_PLATFORM_AREA 25.0f /* m from spawn (x and z) platforms can land; smaller = denser */
#endif /* CONFIG_H */
|