Skip to main content

flake/
lib.rs

1//! # Flake
2//!
3//! `flake` is a game/application framework inspired by macroquad, built on WGPU. Made to create
4//! games and apps very easily.
5//!
6//! ## Getting Started
7//!
8//! In your `main.rs`, write the following:
9//! 
10//! ```
11//! use flake::prelude::*;
12//! 
13//! #[flake]
14//! async fn main() {
15//!     loop {
16//!         draw_circle(mouse_position().0, mouse_position().1, 50.0, RED);
17//!         draw_text("Hello from Flake!", 10.0, 10.0, 16.0, None, WHITE);
18//! 
19//!         end_frame!()
20//!     }
21//! }
22//! ```
23
24use crate::app::App;
25use crate::prelude::{clear_background, Color};
26pub use flake_macros::main as flake;
27
28mod app;
29mod camera;
30mod draw_state;
31pub mod prelude;
32mod input;
33mod model;
34mod state;
35mod global;
36mod misc;
37mod runtime;
38
39pub type FlakeResult = anyhow::Result<()>;
40
41pub fn run_async(fut: impl Future<Output = ()> + 'static) -> FlakeResult {
42    App::run(fut)?;
43    Ok(())
44}
45
46pub fn run_with_bg(color: Color, fut: impl Future<Output = ()> + 'static) -> FlakeResult {
47    clear_background(color);
48    run_async(fut)
49}
50
51#[macro_export]
52macro_rules! end_frame {
53    () => {next_frame().await};
54}