Skip to content

Commit

Permalink
Now using schedule_update (not-fl3/miniquad#437)
Browse files Browse the repository at this point in the history
But some debuging needed because it works not as expected (Because mouse or finger movements now not redraw)
  • Loading branch information
Your Name committed Jun 3, 2024
1 parent f207cb7 commit d07efa5
Show file tree
Hide file tree
Showing 3 changed files with 52 additions and 13 deletions.
16 changes: 9 additions & 7 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 5 additions & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -8,4 +8,8 @@ label = "MACROQUAD TIC-TAC-TOE"
min_sdk_version = 26

[dependencies]
macroquad = { git = "https://github.com/birhburh/macroquad.git", branch = "less_fps" }
macroquad = { version = "0.4.7" }

[patch.crates-io]
# miniquad = { path = "../miniquad"}
miniquad = { git = "https://github.com/not-fl3/miniquad.git" }
43 changes: 38 additions & 5 deletions src/main.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,38 @@
use macroquad::prelude::*;
use macroquad::request_redraw;

fn window_conf() -> Conf {
Conf {
window_title: "TicTacToe".to_owned(),
platform: miniquad::conf::Platform {
blocking_event_loop: true,
// apple_gfx_api: miniquad::conf::AppleGfxApi::Metal,
..Default::default()
},
..Default::default()
}
}

// #[macroquad::main(window_conf)]
// async fn main() {
// let mut timer_frames = 0;
// let mut frame = 0;
// macroquad::miniquad::window::schedule_update();
// loop {
// info!("Frame updated: {}", frame);
// frame += 1;
// clear_background(LIGHTGRAY);
// if macroquad::ui::root_ui().button(None, "Test") {
// info!("Button pressed");
// timer_frames = 50;
// }
// if timer_frames != 0 {
// timer_frames -= 1;
// draw_rectangle(0.0, 100.0, timer_frames as f32 * 20.0, 60.0, GREEN);
// macroquad::miniquad::window::schedule_update();
// }
// next_frame().await
// }
// }

const SQUARES: i16 = 3;

Expand Down Expand Up @@ -87,7 +120,7 @@ fn check_end(fields: &Vec<Option<Field>>) -> bool {
false
}

#[macroquad::main("TicTacToe")]
#[macroquad::main(window_conf)]
async fn main() {
let mut fields = vec![None; (SQUARES * SQUARES) as usize];
let mut game_over = false;
Expand Down Expand Up @@ -178,13 +211,13 @@ async fn main() {
left -= 1;
if left <= 0 {
game_over = true;
request_redraw();
macroquad::miniquad::window::schedule_update();
}
}
prev = None;
if check_end(&fields) {
game_over = true;
request_redraw();
macroquad::miniquad::window::schedule_update();
}
}

Expand Down Expand Up @@ -276,7 +309,7 @@ async fn main() {
}
x_move = true;
left = SQUARES * SQUARES;
request_redraw();
macroquad::miniquad::window::schedule_update();
}
}

Expand Down

0 comments on commit d07efa5

Please sign in to comment.