Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 13 additions & 2 deletions src/game.zig
Original file line number Diff line number Diff line change
Expand Up @@ -512,8 +512,19 @@ fn drawGameplay(self: Game) void {

nvg.save();
defer nvg.restore();
const s = self.width / world_width;
nvg.translate(0, self.height - s * world_height);
var s = self.width / world_width;

// the y location where the camera starts scaling to follow the banana
const banana_threshold_y: f32 = 100;
var translate_x: f32 = 0;
if (self.banana_flying and self.banana_y < banana_threshold_y) {
const past_threshold = banana_threshold_y - self.banana_y;
const scale_ratio = 1 + (past_threshold / world_height);
s = s / scale_ratio;
translate_x = (self.width - s * world_width) / 2;
}

nvg.translate(translate_x, self.height - s * world_height);
nvg.scale(s, s);
const screenshake = @sin(self.screenshake_frequency * @intToFloat(f32, self.frame)) * self.screenshake_amplitude;
nvg.translate(screenshake, 0);
Expand Down