The Daily Click ::. Forums ::. Klik Coding Help ::. Variable Speed Algorythms?
 

Post Reply  Post Oekaki 
 

Posted By Message

infinitum3d



Registered
  03/03/2012 22:18:24
Points
  66
22nd March, 2012 at 22/03/2012 01:12:41 -

I have 10 invaders. I want them to advance in ever increasing speed. I have the speed set to;
20/(numberRemaining)+1

So the first one travels at a speed of 20/10 +1 =3
The second at 20/9 +1 = 3
20/8 +1 = 3
20/7 +1 =4
etc, etc up to
20/1 +1 = 21.

What do you think? How would -you- write your calculation. This works, and its fun, but I'd love to hear other ideas.

Thanks!

 
n/a

Sumo148

Super amazing fantastic user

Registered
  26/01/2009
Points
  530

360 OwnerThe Cake is a LieVIP MemberPokemon Ball!I am an April FoolI donated an open source projectSanta Hat
22nd March, 2012 at 22/03/2012 01:49:02 -

There's many different ways to do this. It could be linear so that the speed increases using a set slope(like yours), or you could possibly use an exponential function. If it was exponential it would get progressively difficult really quickly, you know? Like Y=X^2...

Honestly if it were me I'd try using an exponential equation. Maybe if you had a harder difficulty it could use exponential equations to determine the speed. It's all about how difficult you want it to be. You would of course have to tweak that equation. I doubt X^2 would work for you

 
n/a

infinitum3d



Registered
  03/03/2012 22:18:24
Points
  66
22nd March, 2012 at 22/03/2012 13:45:05 -

Yeah, LOL . X^2 speeds it up way too fast, way too quickly.

I was also thinking about using the Timer in the equation. Something like Speed = Timer/(numberRemaining) + 1.
(Assuming it rounds up)

At 4 secs, speed = 4/10 + 1 = 2
At 8 secs, speed = 8/9 + 1 = 2
12/8 + 1 = 2
16/7 + 1 = 3
20/6 + 1 = 4
24/5 + 1 = 6
28/4 + 1 = 8
32/3 + 1 = 12
36/2 + 1 = 19
40/1 + 1 = 41

A speed of 2 or 3 seems awful slow, but for a first level it might be fine. I could always add in a levelNumber multiplier, as in Speed equals timerValue divided by numberRemaining (plus 1 to prevent division by zero) times the levelValue

Speed = (tmrVal/numRemain +1) * Lvl

But then at 40 seconds it would be a speed of 82. Thats OK, but by 3rd level it would be 123 and by 4th level it would be 164. Too fast.

There's always the old reliable "every 5 seconds increase the speed by whatever (i.e. 5)", which gives us a speed of 5 at five seconds, 10 at ten seconds, and 40 at forty seconds, but that's boring. It needs to be something more interesting, more dynamic, flexible, consistent, and most importantly, fun.

Maybe I could increase it by percentages every five seconds? Or even have it go up and down randomly throughout the level, so one invader has a speed of 20, the next has 50, the next has 25, etc... Just pull out Random numbers for the speed. Or even use [Random(10)+1] as a multiplier... Hmmm... Lots to think about.

Thanks Sumo!

Anyone else have ideas?

Edited by infinitum3d

 
n/a

s-m-r

Slow-Motion Riot

Registered
  04/06/2006
Points
  1078

Candle
22nd March, 2012 at 22/03/2012 16:31:58 -

You may want to keep the gradual linear speed increment, but also modify that on the player's performance.

For example, if their accuracy is high, or they've not taken any damage in a wave, then increase the speed modifier by a certain amount. Likewise, if they seem to be having difficulty and are taking a lot of damage or several missed shots, then perhaps modify it by the certain amount *-1.

Use a counter's current value so that a negative number can result, and this most likely becomes easier. Set the minimum value to like -10, and the maximum value to 10; the player's actions trigger a flag, and when the flag is tripped then the value is modified and the flag is reset.

Increase point values with this variable as well, so that there's an incentive to maintain accuracy and health.

 
n/a

infinitum3d



Registered
  03/03/2012 22:18:24
Points
  66
23rd March, 2012 at 23/03/2012 12:32:51 -


Originally Posted by s-m-r
You may want to keep the gradual linear speed increment, but also modify that on the player's performance.

For example, if their accuracy is high, or they've not taken any damage in a wave, then increase the speed modifier by a certain amount. Likewise, if they seem to be having difficulty and are taking a lot of damage or several missed shots, then perhaps modify it by the certain amount *-1.

Use a counter's current value so that a negative number can result, and this most likely becomes easier. Set the minimum value to like -10, and the maximum value to 10; the player's actions trigger a flag, and when the flag is tripped then the value is modified and the flag is reset.

Increase point values with this variable as well, so that there's an incentive to maintain accuracy and health.



Thanks s-m-r! That gives me a lot to work with.

 
n/a
   

Post Reply



 



Advertisement

Worth A Click