1use std::sync::atomic::{AtomicBool, Ordering};
2
3use crate::math::Math;
4use crate::system::System;
5
6pub const DEFAULT_FPS: u32 = 30;
7
8static IS_INITIALIZED: AtomicBool = AtomicBool::new(false);
9
10
11pub struct Pyqie {
12 pub(crate) system: System,
14 pub frame_count: u32,
15
16 pub(crate) math: Math,
18}
19
20pub fn init(
21 fps: Option<u32>
22) -> Pyqie {
23 assert!(
24 !IS_INITIALIZED.swap(true, Ordering::Relaxed),
25 "Pyqie already initialized"
26 );
27
28 let fps = fps.unwrap_or(DEFAULT_FPS);
30
31 let system = System::new(fps);
33 let frame_count = 0;
34 let math = Math::new();
36
37 let pyqie = Pyqie {
38 system,
39 frame_count,
40 math,
41 };
42 pyqie
43}