niko 0.1.8

the niko wasm game engine
Documentation
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
use js_sys::Math;

#[allow(unused_unsafe)]
pub fn random() -> f64 {
    unsafe {
        Math::random()
    }
}

#[allow(unused_unsafe)]
pub fn random_range_i32(from: i32, to: i32) -> i32 {
    let factor = unsafe { Math::random() };

    let range = to - from;
    let number = factor * (range as f64);

    from + (number as i32)
}