Results 1 to 10 of 20

Thread: Procedural world generation - ground and traps seems to not generating.

Threaded View

Previous Post Previous Post   Next Post Next Post
  1. #11
    Quote Originally Posted by Darkhog View Post
    Can you point me to such algorithm?
    This should do the thing:
    Code:
    function Random2(const seed, offset: cardinal): double; overload;
    var oldSeed: cardinal;
    begin
      oldSeed:=randseed; // Save old seed
      randseed:=seed+offset; // Shouldn't need to check high(cardinal) ranges.
      // Overflowing should still do the math perfectly.
      result:=random();
      randseed:=oldSeed; // Restore it afterwards,
      // So that use of normal Random() outside of this function is not interrupted.
    end;
    
    function Random2(const n: cardinal; const seed, offset: cardinal): cardinal; overload;
    begin
      result:=trunc(Random2(seed, offset)*n);
    end;
    Edited second Random2() result type.
    Last edited by User137; 07-06-2013 at 07:56 PM.

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •