Author Topic: Random Seed  (Read 3163 times)

dutch_619

  • Regular
  • **
  • Posts: 90
    • View Profile
    • Email
Random Seed
« on: 2008-11-29, 10:58:25 PM »
I was trying to think of a way to vary the attacks in a pseudo-random fashion. The method I use now is to have a counter linked to the frame-rate and using it to give me a more or less random number. This seems to be sorta clunky though. I could add a module that uses the seed random function in C# I suppose. Does anyone have a better idea for this? I think a random number generator may be worth doing in its own right.

Let see... this should give a random number...
Code: [Select]
Random randNum = new Random();
randNum.Next(1, 10); // No larger than 10, no smaller than 1



and this would use the seed from the frame-rate linked counter
Code: [Select]
get
      {
         return counter.m_nValue;
      }
      setRandom randNum = new Random(counter.m_nValue);
randNum.Next();


Additionally I was wondering how to play a brief opening video and have it play once and then go to the menu map. At present I have it open in the menu map and it plays the video once based and increments an on/off counter in order to avoid the opening clip every time the game drops back to the menu level (i.e when esc is pressed or a game is saved)
The trouble with this is, there is a brief lag playing the clip when the game opens and the the menu screen is shown for a moment before the clip plays. Ideally, the clip would be in its own map and would play all the way through, then dump the user to the menu screen.


dutch_619

  • Regular
  • **
  • Posts: 90
    • View Profile
    • Email
Re: Random Seed
« Reply #1 on: 2008-11-30, 02:45:34 PM »
*Update*

I have a nice little random number generating c# module now. Nice and simple too. I didn't use the seed function as it was honestly unnecessary.

durnurd

  • Lead Lemming
  • Expert
  • Fanatic
  • *****
  • Posts: 1234
  • Games completed so far: 0
    • MSN Messenger - durnurd@hotmail.com
    • View Profile
    • Find My Ed
Re: Random Seed
« Reply #2 on: 2008-11-30, 05:18:34 PM »
Do you know there is a built-in random number function in SGDK2?  It's called RandomNumber, or something like that.
Edward Dassmesser

dutch_619

  • Regular
  • **
  • Posts: 90
    • View Profile
    • Email
Re: Random Seed
« Reply #3 on: 2008-11-30, 05:48:02 PM »
Doh! So there is....

bluemonkmn

  • SGDK Author
  • Administrator
  • Fanatic
  • *****
  • Posts: 2761
    • ICQ Messenger - 2678251
    • MSN Messenger - BlueMonkMN@gmail.com
    • View Profile
    • http://sgdk2.sf.net/
    • Email
Re: Random Seed
« Reply #4 on: 2008-12-01, 07:34:55 AM »
For the video, you could do just as you suggest -- put the video on its own map... it probably wouldn't even need to have any layers -- except that layers are the only place you can put rules, so maybe you would need one very small layer.

dutch_619

  • Regular
  • **
  • Posts: 90
    • View Profile
    • Email
Re: Random Seed
« Reply #5 on: 2008-12-01, 04:26:10 PM »
Exactly what I did. I have a map with a more or less empty layer that has a rule to call a timer built off of the framerate limiter to go to the next map.