Advertisement
JademusSreg

Galaxy RNG: PRand

Jul 9th, 2011
141
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 0.64 KB | None | 0 0
  1. //
  2. // The PRand script provides explicitly pseudo-random functions, intended to be used
  3. // in procedural generation.
  4. //
  5. //================================================================================
  6. // Functions
  7. int RNG_SEED_X = 1;
  8. int RNG_SEED_Y = 1;
  9. int RNG() {
  10.     RNG_SEED_X = 36969 * (RNG_SEED_X & 65535) + (RNG_SEED_X >> 16);
  11.     RNG_SEED_Y = 18000 * (RNG_SEED_Y & 65535) + (RNG_SEED_Y >> 16);
  12.     return (RNG_SEED_X << 16) + (RNG_SEED_Y & 65535);
  13. }
  14. int PRandInt (int min, int max) {
  15.     return AbsI(ModI(RNG(), max - min) + min);
  16. }
  17. fixed PRandFixed (fixed min, fixed max) {
  18.     return AbsF(ModF(RNG(), max - min) + min);
  19. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement