module main let max(x, y: f64) = if x >= y { x } else { y } let min(x, y: f64) = if x <= y { x } else { y } let clamp(x, low, high: f64) = max(low, min(x, high)) // Vertical distances use screen-height world units. // One world unit is always equal to the screen height. let gravity: f64 = -4.0 let flap_height: f64 = 0.135 let terminal_velocity: f64 = -2.5 let bird_size: f64 = 0.08 let bird_x: f64 = 0.35 // These values are world units, not proportions of screen width. let pipe_width: f64 = 0.12 let pipe_gap_size: f64 = 0.265 let pipe_spacing: f64 = 0.475 let pipe_speed: f64 = 0.30 let double_pipe_speed_multiplier: f64 = 2.5 let double_pipe_points_multiplier: u32 = 2 let pipe_buffer_size = comptime 32 let background_scroll_speed: f64 = 0.1 let base_scroll_speed: f64 = 1.3333 let base_height_fraction: f64 = 0.20 let restart_grace_period: f64 = 0.2 let Pipe = type struct { // Horizontal position in screen-height world units. x: f64, // Vertical gap centre, where 0.0 is the bottom and 1.0 is the top. gap_y: f64, // Whether the bird has already received a point for this pipe. passed: bool, } let GameState = type struct { bird_y: f64, bird_velocity_y: f64, pipes: [pipe_buffer_size]Pipe, delta_time: f64, background_scroll: f64, base_scroll: f64, started: bool, paused: bool, lost: bool, time_since_loss: f64, show_collision_boxes: bool, double_pipe_speed: bool, points: u32, }