Scrolling Game Development Kit Forum
SGDK Version 2 => Help, Errors, FAQ => Topic started by: dutch_619 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...
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
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.
-
*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.
-
Do you know there is a built-in random number function in SGDK2? It's called RandomNumber, or something like that.
-
Doh! So there is....
-
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.
-
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.