Controlling the application speed, How?

Blitz3D Forums/Blitz3D Programming/Controlling the application speed, How?

Mortiis(Posted 2009) [#1]
I want to have the control of the application speed in real time. Like slowing things down and getting it faster. For example, bullet time effects or the speed variable in Stronghold.

Do I have to add another speed global to everything or is there a simpler way like controlling the tween value for frame tweening.

Thanks.


Matty(Posted 2009) [#2]
If you are using deltatime for your timing code it is very easy. Slap another ' * speedfactor#' variable on the end of your delta lines.

So for instance:

translateentity myentity,velx*delta*speedfactor,vely*delta*speedfactor,velz*delta*speedfactor

etc


Mortiis(Posted 2009) [#3]
No I'm using render tweening from Mark's Castle code. I hate to add a speed variable to every single line in my code. Makes it look ugly and unreadable. Anything else?


Warner(Posted 2009) [#4]
In this code archive entry, I used a method that I found on the net.
It counts how many ticks are passed since the previous frame, and updates the gameplay accordingly. I think that it is done a little different than the castle demo.
http://www.blitzmax.com/codearcs/codearcs.php?code=2374


Mortiis(Posted 2009) [#5]
Hmm I doubt if your technique is suitable for 3D.

C'mon guys is that all? There has to be a way. I've seen someone did with with Tokamak 5 years ago, but I'm not using any physics in my project. So I'm looking for another way. Thanks.


Guy Fawkes(Posted 2009) [#6]
try the castle demo. it has fps which can be controlled =)

~DarkShadowWing~


Mortiis(Posted 2009) [#7]
Did you read my post? I said I'm using the tweening from Castle demo. If you take a detailed look to it's tweening method, you will see you can't change the fps in realtime in that.


Kryzon(Posted 2009) [#8]
And you really shouldn't. It's not related to the amount of updating you do per frame, so tampering with the frame limiting algorithm won't get precisely what you want.

I complement what Matty said. You need to define a "Speed#" variable that'll multiply all your velocities (camera movement, character movement, rotations, etc.) but then apply that same Speed# variable in the UpdateWorld(anim_speed#) function, as it'll sync the animations properly with your velocities. Initially it should be set to 1.0, and it shouldn't get to be exactly 0 (or else your world will freeze).
It makes the code more complex? well, if you want it to be pretty, don't use it =/

There's a cost to everything. Besides, game related, you gotta worry about the results, not really the means to do them (unless of course they compromise other [more important] results).


Mortiis(Posted 2009) [#9]
Allright I see. Was just curious to see, there is sometimes a very simple way yet you cannot think of it and other coders do. Just took my chance. Thanks for your help.


Kryzon(Posted 2009) [#10]
There probably is a better\different way to do it. But those were my two cents about it :D
I'm sure if someone thinks of something, he'll say it here.


Warner(Posted 2009) [#11]
Why wouldn't this technique work for 3d ?



Mortiis(Posted 2009) [#12]
Why wouldn't this technique work for 3d ?


Because I want to be able to change the game speed dynamically by player input.


Buggy(Posted 2009) [#13]
You can't change the game speed when using the tweening method from the castle demo? Actually, you can, and it's quite easy. Just make FPS a global variable instead of a constant.

Then, when you want it to be in slow-mo, make FPS whatever you want (10, 5, etc.), and make sure you adjust period so that period = 1000/FPS. Then when you want to go back to regular speed, just reset FPS and period and you're good to go.


Mortiis(Posted 2009) [#14]
wow that's what I'm talking about! Thanks a ton Buggy, you are the man!


Guy Fawkes(Posted 2009) [#15]
i TOLD u it was the castle demo, mortis. =)

~DarkShadowWing~