mygame 0.1.3

Best game. legit.
use raylib::ffi::{GetKeyPressed, GetMousePosition, IsKeyDown, IsKeyPressed, IsMouseButtonDown, IsMouseButtonPressed};
use raylib::prelude::*;
use rand;
use rand::prelude::SliceRandom;
use rand::rngs::ThreadRng;


struct Data {
    x: i32,
    y: i32,
    color: Color,
    size: u32
}

fn main() {
    let instructions = "1 = Draw (New Color), 2 = Erase, 3 = Change Background, 0 = Clear";
    let text_size = 24;

    let mut game = init()
        .size(640 * 2, 480 * 2)
        .title("Coloring Game")
        .build();

    let mut rl = game.0;
    let mut thread = game.1;

    // Colors
    let colors: Vec<Color> = vec!(Color::BLACK,
                                  Color::BLUE,
                                  Color::RED,
                                  Color::GREEN,
                                  Color::ORANGE,
                                  Color::YELLOW,
                                  Color::LIME,
                                  Color::PURPLE,
                                  Color::MAGENTA,
                                  Color::PINK,
                                  Color::BROWN,
                                  Color::GOLD,
                                  Color::BEIGE,
                                  Color::SKYBLUE,
                                  Color::RAYWHITE,
                                  Color::GRAY,
                                  Color::VIOLET,
                                  Color::MAROON);

    let mut drawing: Vec<Data> = vec![];
    let mut rng = rand::thread_rng();

    // Coloring Variables
    let mut color = colors.choose(&mut rng).expect("fail").to_owned();
    let mut background: Color = Color::WHITE;
    let mut size: u32 = 25;

    while !rl.window_should_close() {
        // Draw Handle
        let mut draw = rl.begin_drawing(&thread);

        // Mouse position
        let mouse_pos = draw.get_mouse_position();

        // Background
        draw.clear_background(background);

        // Drawing
        for v in &drawing {
            draw.draw_circle(v.x, v.y, v.size as f32, v.color);
        }

        // Size modifying
        if draw.is_key_pressed(KeyboardKey::KEY_MINUS) {
            size -= 1;
        }

        if draw.is_key_pressed(KeyboardKey::KEY_EQUAL) {
            size += 1;
        }

        // Unsafe code - Functions
        unsafe {
            if IsKeyPressed(KeyboardKey::KEY_ONE as i32) {
                color = colors.choose(&mut rng).expect("fail").to_owned();
            }

            if IsKeyPressed(KeyboardKey::KEY_TWO as i32) {
                color = background;
            }

            if IsKeyPressed(KeyboardKey::KEY_ZERO as i32) {
                drawing.clear();
            }

            if IsKeyPressed(KeyboardKey::KEY_THREE as i32) {
                background = colors.choose(&mut rng).expect("fail").to_owned();
            }
        }

        // Unsafe code - Draw
        unsafe {
            if IsMouseButtonDown(0) {
                let data = Data {x: mouse_pos.x as i32, y: mouse_pos.y as i32, color, size };

                drawing.insert(drawing.len(), data);
            }
        }

        // cursor and instructions
        if background == Color::BLACK {
            draw.draw_text(instructions, 0, 0, text_size, Color::WHITE);
        }
        else {
            draw.draw_text(instructions, 0, 0, text_size, Color::BLACK);
        }
        draw.draw_circle(mouse_pos.x as i32, mouse_pos.y as i32, size as f32, color);




        // i make best game^2
    }
}