Skip to content

Commit 4c2c67f

Browse files
committed
Tweak bird rotation
1 parent 9592a44 commit 4c2c67f

File tree

1 file changed

+14
-7
lines changed

1 file changed

+14
-7
lines changed

src/bird.c

Lines changed: 14 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -46,10 +46,11 @@
4646
#define BIRD_SINE_DAMPEN ((float) 0.02)
4747

4848
/* Rotation */
49-
#define BIRD_ROTATION_UP_DEG ((float) (50.0 * M_PI / 180.0))
50-
#define BIRD_ROTATION_UP_MS 80
49+
#define BIRD_ROTATION_UP_DEG ((float) (20.0 * M_PI / 180.0))
50+
#define BIRD_ROTATION_UP_MS 100
5151
#define BIRD_ROTATION_DOWN_DEG ((float) (-90.0 * M_PI / 180.0))
52-
#define BIRD_ROTATION_DOWN_MS 800
52+
#define BIRD_ROTATION_DOWN_MS 600
53+
#define BIRD_ROTATION_HOLD_MS 300
5354

5455
/* Bird implementation */
5556

@@ -245,16 +246,22 @@ static void bird_tick_rotation(bird_t *bird)
245246
const uint64_t now_ticks = get_ticks();
246247
const uint64_t elapsed_ms = (now_ticks - bird->flap_ticks) / TICKS_PER_MS;
247248

248-
if (elapsed_ms < BIRD_ROTATION_UP_MS)
249+
if (elapsed_ms < BIRD_ROTATION_UP_MS && bird->rotation < BIRD_ROTATION_UP_DEG)
249250
{
250-
/* Phase 1: Rotating up */
251+
/* Phase 1: Rotating up (skip if already at up position) */
251252
float t = (float)elapsed_ms / BIRD_ROTATION_UP_MS;
252253
bird->rotation = t * BIRD_ROTATION_UP_DEG;
253254
}
255+
else if (elapsed_ms < BIRD_ROTATION_UP_MS + BIRD_ROTATION_HOLD_MS && bird->state != BIRD_STATE_DYING)
256+
{
257+
/* Phase 2: Hold at up position (skip when dying) */
258+
bird->rotation = BIRD_ROTATION_UP_DEG;
259+
}
254260
else
255261
{
256-
/* Phase 2: Rotating down (twice as fast when dying) */
257-
uint64_t fall_elapsed = elapsed_ms - BIRD_ROTATION_UP_MS;
262+
/* Phase 3: Rotating down */
263+
uint64_t hold_time = (bird->state == BIRD_STATE_DYING) ? 0 : BIRD_ROTATION_HOLD_MS;
264+
uint64_t fall_elapsed = elapsed_ms - BIRD_ROTATION_UP_MS - hold_time;
258265
float t = (float)fall_elapsed / BIRD_ROTATION_DOWN_MS;
259266
if (t > 1.0f) t = 1.0f;
260267
bird->rotation = BIRD_ROTATION_UP_DEG + t * (BIRD_ROTATION_DOWN_DEG - BIRD_ROTATION_UP_DEG);

0 commit comments

Comments
 (0)