use my_raylib::{colors, Vector2};

fn main() {
    let screen = Vector2 { x: 800.0, y: 600.0 };
    let ball_radius: f32 = 100.0;
    let mut pos = Vector2 {
        x: screen.x / 2.0,
        y: screen.y / 2.0,
    };
    let mut velocity = Vector2 { x: 200.0, y: 200.0 };

    my_raylib::init_window(screen.x as u32, screen.y as u32, "Bouncing ball");
    my_raylib::set_target_fps(60);

    while !my_raylib::window_should_close() {
        my_raylib::begin_drawing();
        my_raylib::clear_background(colors::BLACK);

        let dt = my_raylib::get_frame_time();
        velocity.y += dt * 1000.0;

        let x = pos.x + velocity.x * dt;
        if x - ball_radius < 0.0 || x + ball_radius >= screen.x {
            velocity.x *= -1.0;
        } else {
            pos.x = x;
        }

        let y = pos.y + velocity.y * dt;
        if y - ball_radius < 0.0 || y + ball_radius >= screen.y {
            velocity.y *= -1.0;
        } else {
            pos.y = y;
        }

        my_raylib::draw_circle_v(pos, ball_radius, colors::RED);
        my_raylib::end_drawing();
    }
}
