I am trying to change a variable.
I want the variable to get smaller, preferably logrhythmically (sp?) as the score increases.
Here's the deal. I have a sprite that needs to move from one side of the screen to the other.
Glide (VARIABLE SPEED) secs to x, y.
Since my variable is the length of time it takes to cross the screen, as the variable gets smaller, the sprite will cross faster.
What I currently have is:
pick random [.5 * (score + 5)/(score + 2)] to [.6 * (score + 5)/(score + 1)]
This works pretty well, but it doesn't start out high enough (about 2.4), and it quickly drops to about .6 seconds. I like the .6 at the end, but I'd like it to start at about 5 and drop to .6 over a period of about 20 iterations.
here's the current math examples.
Score 0 (starting) 1.25 to 3
Score 1 1 to 1.8
Score 2 .675 to 1.4
Score 3 .8 to 1.2
Score 4 .75 to 1.08
Score 5 .71 to .996
Score 6, well, you get the general idea.
Any suggestions for a better equation?
Here's the link!
Thanks!
Last edited by infinitum3d (2010-05-25 19:49:10)
Offline
Here's an equation that might do what you want:
speed= starting speed * ratio^score
For the speed to go down as the score goes up, the ratio must be less than 1.
Say you want the speed variable to start out at 16 and you want it to be cut in half every time the score goes up by one. The equation would be:
speed= 16 * .5^score
Of course, you can't make a script that looks like that because Scratch doesn't have exponents. Using a handy-dandy log trick, you get this, which works the same way:
To randomize it, you could try something like this:
Does that help? Does it do what you want?
Last edited by scmb1 (2010-05-25 19:30:12)
Offline
That looks great! I'll test it out!!!!
Link to Project!
Offline