pyqie/
pyqie.rs

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    // System
13    pub(crate) system: System,
14    pub frame_count: u32,
15
16    // Math
17    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    // Default parameters
29    let fps = fps.unwrap_or(DEFAULT_FPS);
30
31    // System
32    let system = System::new(fps);
33    let frame_count = 0;
34    // Math
35    let math = Math::new();
36
37    let pyqie = Pyqie {
38        system,
39        frame_count,
40        math,
41    };
42    pyqie
43}