Register    Login    Forum    Search    FAQ

 Page 1 of 1 [ 4 posts ]

#### Can't seem to figure out how the snek speed up in T17 HW

 Print view Previous topic | Next topic

#### Can't seem to figure out how the snek speed up in T17 HW

Author Message
 Posted: October 8th, 2017, 8:11 am

Joined: August 12th, 2017, 3:17 am
Posts: 8
Location: Pakistan
So chili used this code to make the snek gradually speed up.

Code:
snekMovePeriod = std::max( snekMovePeriod - dt * snekSpeedupFactor,snekMovePeriodMin )

But this code isn't making any sense to me and I don't even know what is making it difficult.
I think what is making me annoyed is I can't seem to figure out how long will the snek need to reach its maximum speed and how much speed will snek increase every frame.

P.S. I know its only math but I can fiqured this shit out.

P.S.S Thanks chili For Making these awesome tutorials. They have helped me greatly toward taking tangible steps for creating a open world RPG game.

 Posted: October 8th, 2017, 8:26 am

Joined: August 12th, 2017, 3:17 am
Posts: 8
Location: Pakistan
Code:
snekMovePeriod - dt * snekSpeedupFactor

I fucked around the code and I understood that if we only subtract the snekSpeedupFactor from snekMovePeriod than the snek will reach its maximum speed in only under 1 sec but I can't figure out:
how does multiplying the frameTimer(dt) limit the time snek need to reach its maximum speed?

 Posted: October 8th, 2017, 10:17 am

Joined: January 19th, 2017, 10:28 pm
Posts: 497
Location: Idiot from northern Europe
dt is how much time each frame takes.

If you didn't multiply by dt and instead just adjusted snekSpeedUpFactor until you think it looks good, then the speed will be different on different computers depending on their framerate.

say your framerate is 60fps. then dt = 1/60.
say speedupfactor is 10. You're now subtracting 10 * (1/60) from moveperiod every frame. This means that in one second you have subtracted 10 from moveperiod

if instead, your computer runs at 120fps. then dt = 1/120.
You'll be subtracting 10 * (1/120) every frame and once again you'll have subtracted a total of 10 after 1 second

_________________
I just like to thumb my nose at millionaires.
If I was rolled I'd bust them heads up.

 Posted: October 8th, 2017, 11:08 am

Joined: August 12th, 2017, 3:17 am
Posts: 8
Location: Pakistan
I knew why it was used It just became jumbled in my brain
Thanks for clearing it up!

Display posts from previous:  Sort by

 Page 1 of 1 [ 4 posts ]

 You cannot post new topics in this forumYou cannot reply to topics in this forumYou cannot edit your posts in this forumYou cannot delete your posts in this forumYou cannot post attachments in this forum

 Search for: