🎉 Celebrating 25 Years of GameDev.net! 🎉

Not many can claim 25 years on the Internet! Join us in celebrating this milestone. Learn more about our history, and thank you for being a part of our community!

Controlled Randomness

posted in r1ckparker's Journal for project Psy
Published April 21, 2019
Advertisement

You probably want a bit of randomness in your game, for example when enemies shoot a bullet or how long an explosion lasts.  However sometimes you want it to be the same every game, so the player will know that an enemy will enter the stage and always shoot a bullet.  You want some randomness, but consistent randomness so it is the same every time.

"When replaying levels, enemies always appear in the same location and follow the same behavioral patterns"

One way to do this is to have an array and load this with pre-calculated random numbers.  When your game needs a number, call the next one off the stack and loop back to the top when you have run out.

One cool thing you can do with this is save a replay.  If you capture the player's inputs each tick, then in theory everything in the game should play out the same way.  You could use this for demo mode or as a save feature.

 

Next Entry Perfect Circle
0 likes 0 comments

Comments

Nobody has left a comment. You can be the first!
You must log in to join the conversation.
Don't have a GameDev.net account? Sign up!
Advertisement
Advertisement