Sorry your browser is not supported!

You are using an outdated browser that does not support modern web technologies, in order to use this site please update to a new browser.

Browsers supported include Chrome, FireFox, Safari, Opera, Internet Explorer 10+ or Microsoft Edge.

AppGameKit Classic Chat / Trying to create pseudo-random numbers!

Author
Message
basicFanatic
7
Years of Service
User Offline
Joined: 7th Jun 2017
Location:
Posted: 13th Apr 2021 13:22 Edited at: 13th Apr 2021 14:17
Edit: I should have had a question mark in the headline, since this is a question. Sorry!

I want to give a flock of sprite birds some randomness to their movement, so they don't end up at the same spot. But I want each birds randomness to be predictable, so that I can set rndSeed = LevelNumber and then the randomness will behave the same way each time the player restarts the level.

I think the function here does most of the stuff the way it's supposed to, but I cant figure out how to randomize the seed. Does anyone here have experience with this?

Kevin Picone
22
Years of Service
User Offline
Joined: 27th Aug 2002
Location: Australia
Posted: 13th Apr 2021 15:24

I guess you could do that, but is there any reason why you couldn't just cache a bunch of random() values and uses those ? - What i mean is set the internal seed to your level constant then generate a block/array of random data, then have your game logic pull from the table.

PlayBASIC To HTML5/WEB - Convert PlayBASIC To Machine Code
basicFanatic
7
Years of Service
User Offline
Joined: 7th Jun 2017
Location:
Posted: 13th Apr 2021 22:07 Edited at: 13th Apr 2021 22:27
Yeah, that could work! Didn't consider that.

Edit: 10000 random values generated. That was fun!

Login to post a reply

Server time is: 2024-11-24 04:17:50
Your offset time is: 2024-11-24 04:17:50