board started :DDD

This commit is contained in:
LinlyBoi
2023-05-06 10:45:51 +03:00
parent 36ab67bfff
commit cbf08728f4
2 changed files with 21 additions and 0 deletions

BIN
resouces/board.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 8.9 KiB

View File

@@ -1,15 +1,36 @@
use raylib::prelude::*; use raylib::prelude::*;
const NROW: i32 = 6;
const NCOL: i32 = 7;
fn main() { fn main() {
let (mut rl, thread) = raylib::init().size(640, 480).title("Hello, World").build(); let (mut rl, thread) = raylib::init().size(640, 480).title("Hello, World").build();
let _rust_orange = Color::new(222, 165, 132, 255); let _rust_orange = Color::new(222, 165, 132, 255);
let _ray_white = Color::new(255, 255, 255, 255); let _ray_white = Color::new(255, 255, 255, 255);
let board_image = Image::load_image("resouces/board.png").expect("WHAT DA HAILLL");
let _ = rl
.load_texture(&thread, "resouces/board.png")
.expect("couldn't load texture :(");
let board_texture = rl
.load_texture_from_image(&thread, &board_image)
.expect("WHAT DA HAILL");
println!(
"width: {} \n height: {}.",
board_texture.width, board_texture.height
);
let square_widf = board_texture.width / NROW;
let square_heif = board_texture.height / NCOL;
let square_wewant = (square_widf * NROW / 2, square_heif * 3 / 2);
let square_center = square_widf / 2;
rl.set_target_fps(60); rl.set_target_fps(60);
while !rl.window_should_close() { while !rl.window_should_close() {
let pressed_key = rl.get_key_pressed(); let pressed_key = rl.get_key_pressed();
let mut d = rl.begin_drawing(&thread); let mut d = rl.begin_drawing(&thread);
d.clear_background(Color::WHITE); d.clear_background(Color::WHITE);
//d.draw_circle_gradient(240, 240, 100 as f32, Color::ORANGE, Color::RED);
d.draw_circle(square_wewant.0, square_wewant.1, 55.0, Color::YELLOW);
d.draw_texture(&board_texture, 0, 0, Color::VIOLET);
if let Some(pressed_key) = pressed_key { if let Some(pressed_key) = pressed_key {
// Certain keyboards may have keys raylib does not expect. Uncomment this line if so. // Certain keyboards may have keys raylib does not expect. Uncomment this line if so.
// let pressed_key: u32 = unsafe { std::mem::transmute(pressed_key) }; // let pressed_key: u32 = unsafe { std::mem::transmute(pressed_key) };