NSMBW-Decomp
A decompilation of New Super Mario Bros. Wii
Loading...
Searching...
No Matches
ef_random.h
1#ifndef NW4R_EF_RANDOM_H
2#define NW4R_EF_RANDOM_H
3#include <nw4r/types_nw4r.h>
4
5namespace nw4r {
6namespace ef {
7
8class Random {
9private:
10 ulong mSeed; // at 0x0
11
12public:
13 void Srand(ulong seed) {
14 mSeed = seed;
15 }
16
17 int Rand() {
18 MixRandomSeed();
19 return static_cast<int>(mSeed >> 16);
20 }
21
22 f32 RandFloat() {
23 MixRandomSeed();
24 return static_cast<f32>(mSeed >> 16) / 0x10000;
25 }
26
27private:
28 void MixRandomSeed() {
29 mSeed = mSeed * 0x343FD + 0x269EC3;
30 }
31};
32
33} // namespace ef
34} // namespace nw4r
35
36#endif