comparison src/util/prng.rs @ 687:ac092b70c39a

Fix PRNG not to panic, pass it to Enemy, and initialise it with time in eclrenderer.
author Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
date Sat, 17 Aug 2019 13:49:31 +0200
parents 1520b559cacc
children
comparison
equal deleted inserted replaced
686:aefe5b5f481e 687:ac092b70c39a
16 16
17 /// Generates a pseudo-random u16. 17 /// Generates a pseudo-random u16.
18 /// 18 ///
19 /// RE’d from 102h.exe@0x41e780 19 /// RE’d from 102h.exe@0x41e780
20 pub fn get_u16(&mut self) -> u16 { 20 pub fn get_u16(&mut self) -> u16 {
21 let x = (self.seed ^ 0x9630) - 0x6553; 21 let x = (self.seed ^ 0x9630).wrapping_sub(0x6553);
22 self.seed = (((x & 0xc000) >> 14) | (x << 2)) & 0xffff; 22 self.seed = ((x & 0xc000) >> 14) | (x << 2);
23 self.seed 23 self.seed
24 } 24 }
25 25
26 /// Combines two u16 into a single u32. 26 /// Combines two u16 into a single u32.
27 /// 27 ///