Jump to content
  • Advertisement
  • entries
    48
  • comments
    57
  • views
    43639

Controlled Randomness

r1ckparker

920 views

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.

 



0 Comments


Recommended Comments

There are no comments to display.

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

GameDev.net is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

Sign me up!