Can someone tell me why this random does not work
SaveDave
Member Posts: 140
firstly, i have set up a quick test...
i would like it if someone could look at it and tell me why the heck its not working!
ive checked everything again and again!
do i need to send the file to whoever can help or cann i upload it here at all?
thanks
i would like it if someone could look at it and tell me why the heck its not working!
ive checked everything again and again!
do i need to send the file to whoever can help or cann i upload it here at all?
thanks
Comments
you can publish your game to the GS website and allow to download/share..
also,
check out tshirtbooth's random image demo..
http://gamesalad.com/game/play/26735
download project then rename it from .game to .zip and open.
i'm finding a lot of uses for the way he uses randomizing in that demo.
Storm
here is the file.... if someone could download and tell me why this does not work, i would call you GS god from now onward!!!
http://gamesalad.com/game/play/92236
the idea is to have a random set of three colour blocks appearing from the right every 2 seconds
explanation:
inside a closed mathematical system, nothing is random (i.e. a computer cpu -- this isn't entirely true considering heat and RF radiation, but i digress)
so what computer scientists and mathematicians do is they create pseudo-random number generators. These fancy algorithms take a seed value, an initial value, and then based on that value generate a seemingly random sequence of numbers. The "problem and/or feature" you are experiancing is that when GS runs it always uses the same seed value. Therefor the random number never changes.
All other programming languages give you a way to set your own seed value, or use a seed value outside of the closed system, like the system clock for example. If you used the number of seconds since jan 1, 1970 that seed number will always be different. That's exactly what most computer languages do. They have a function like math.randseed(value) that you call before calling math.random() In fact, Lua, the language GS uses supports that feature so it's a mystery why the devs don't expose it to us.
Anyhow, there are perfectly good reasons why you would want to always use the same seed value to create the exact same sequence of "random" events.
Other times you may want a truely random effect, in that case you would seed with the system clock or some other value that is outside of the engine itself.
So knowing that the only way to get truly random numbers in GS is to intercept some "noise" from the real world we have a few options:
1. Measure the tilt of the accelerometer and call the random function
2. Measure the time before the player hits start
3. Measure the x/y position the player touches the screen
What I do, is on the title screen i start spewing particles in a random direction and at a random velocity.
The sequence of particles will be always exactly the same, but it will not matter, because the "noise" we are capturing is the number of milliseconds since the game started until the player hits start.
You don't have to do anything special other than just spew random particles because by the very act of spewing particles you will be calling the random() function a non-deterministic number of times before the player hits start. Every time the player hits start it will have called random() a different number of times, therefor in your game the sequence of random numbers always starts at a different position, thus a different outcome can be expected in the game engine itself.
This tip has been brought to you by the fine folks at ORBZ. A Florida based braintrust consisting of me, and my wild dog and wilder girlfriend.
so simple!!
Orbz or should i now say GS god!
thank you!