static void update_camera(void) { const xvec2 halfscreen = xvec2_set(REFERENCE_WIDTH / 2, REFERENCE_HEIGHT / 2); thing_t *dude = &game.things[game.dude_id]; xvec2 *dudepos = &dude->position; camera.target.y = dudepos->y; if (camera.target.y == 0.f) { xvec2 drama_target = xvec2_set(camera.target.x, REFERENCE_HEIGHT * -0.28f); float drama_mix = 1.f - (fmaxf(dudepos->x + 16.f, 0.f) / 48.f); camera.target = xvec2_mix(camera.target, drama_target, drama_mix); } camera.target.y = fminf(BUILDING_HEIGHT + 16 - halfscreen.y, camera.target.y); float mix_rate = (dude->type < dude_dive ? 0.01 : 0.3); camera.current = xvec2_mix(camera.current, camera.target, mix_rate); camera.offset = xvec2_set(camera.current.x - halfscreen.x, camera.current.y - halfscreen.y); LOG_TRACE("Camera: %f %f (moving to %f %f) (offset %f %f)", camera.current.x, camera.current.y, camera.target.x, camera.target.y, camera.offset.x, camera.offset.y); }
static void ground_dude(thing_t *dudep) { dudep->position = xvec2_set(dudep->position.x - 16, BUILDING_HEIGHT - 8); dudep->velocity = xvec2_all(0.f); dudep->type = gibs; dudep->current_frame = 0; dudep->gravitated = false; dudep->solid = true; game.ended_at_ticks = game.active_ticks; game.over = true; // Fade to white. Push after a second, not yet. view_fade_out((SDL_Color) { 255, 255, 255, 255 }); for (size_t i = 0; i < MAX_THINGS; ++i) { thing_t *tp = &game.things[i]; if (! tp->type) continue; if (tp->attached_to == game.dude_id) tp->attached_to = 0; } }