Gamestudio Links
Zorro Links
Newest Posts
MT5 bridge not working on MT5 v. 5 build 4160
by EternallyCurious. 04/25/24 20:49
Data from CSV not parsed correctly
by EternallyCurious. 04/25/24 10:20
Trading Journey
by howardR. 04/24/24 20:04
M1 Oversampling
by Petra. 04/24/24 10:34
Zorro FIX plugin - Experimental
by flink. 04/21/24 07:12
Scripts not found
by juergen_wue. 04/20/24 18:51
zorro 64bit command line support
by 7th_zorro. 04/20/24 10:06
StartWeek not working as it should
by jcl. 04/20/24 08:38
AUM Magazine
Latest Screens
The Bible Game
A psychological thriller game
SHADOW (2014)
DEAD TASTE
Who's Online Now
1 registered members (AndrewAMD), 827 guests, and 6 spiders.
Key: Admin, Global Mod, Mod
Newest Members
Mega_Rod, EternallyCurious, howardR, 11honza11, ccorrea
19048 Registered Users
Previous Thread
Next Thread
Print Thread
Rate Thread
Page 1 of 2 1 2
time_step question #456128
11/11/15 15:26
11/11/15 15:26
Joined: Nov 2009
Posts: 201
Logitek Offline OP
Member
Logitek  Offline OP
Member

Joined: Nov 2009
Posts: 201
Hi, I have a question about time_step


I wanna know if my thoughts are correct:

For example: I wanna move a model in a direction. It is not important in which direction. It is only an example.

while(1)
{
model.x += 1;
//At 60 FPS it would move 60 quants in one second.
wait(1);
}

BUT now I wanna do that with time_step in the same speed.

while(1)
{
model.x += time_step * 3.75;
wait(1);
}



My question is: Is 3.75 the correct value to get the same speed? It is without c_move, but that is not the question.

I have found this in the manual:

The duration of the last frame cycle in ticks, i.e. sixteenths of a second. A speed multiplied by time_step gives the distance to be covered per frame. On a frame rate of 16 fps both variables have a value of 1.

So I thought: 1 / 16 * 60frames = 3.75
And also 60/16 = 3.75

Is there a professional who knows if this is correct?



Second question. What if I wanna wait 4 frames with wait(4) at 60 fps. But now with time_step? So that it would be only 2 frames at 30 fps? Because 30 fps is only the half of 60. So wait(4) would take the double time as at 60 fps.


Last edited by Logitek; 11/11/15 16:26.
Re: time_step question [Re: Logitek] #456132
11/11/15 16:39
11/11/15 16:39
Joined: Sep 2003
Posts: 6,861
Kiel (Germany)
Superku Offline
Senior Expert
Superku  Offline
Senior Expert

Joined: Sep 2003
Posts: 6,861
Kiel (Germany)
Originally Posted By: Logitek
My question is: Is 3.75 the correct value to get the same speed? It is without c_move, but that is not the question.

Then I don't really understand the question/ issue. Why would c_move be any different?


To your other question: Just get completely rid off the way of thinking with frame rate dependent stuff. It's only getting you in trouble and it's not helping. Don't even try to compare problems with framerate dependent solutions.
You know that the engine works in ticks, like 16 ticks equal one second. Then

my.skill1 = 16;
while(my.skill1 > 0)
{
my.skill1 -= time_step;
wait(1);
}

is going to take approximately 1 second. With stuff like that I pretty much do all my code, like

my.skill2 += time_step;
if(my.skill2 > 2)
{
my.skill2 -= 2;
effect(...); // <--- now 8 particles get spawned every second, framerate independent
}


"Falls das Resultat nicht einfach nur dermassen gut aussieht, sollten Sie nochmal von vorn anfangen..." - Manual

Check out my new game: Pogostuck: Rage With Your Friends
Re: time_step question [Re: Superku] #456133
11/11/15 16:50
11/11/15 16:50
Joined: Nov 2009
Posts: 201
Logitek Offline OP
Member
Logitek  Offline OP
Member

Joined: Nov 2009
Posts: 201
Hey, great. Thank you for that!

Re: time_step question [Re: Superku] #456134
11/11/15 16:53
11/11/15 16:53
Joined: Nov 2009
Posts: 201
Logitek Offline OP
Member
Logitek  Offline OP
Member

Joined: Nov 2009
Posts: 201
Originally Posted By: Superku

my.skill1 = 16;
while(my.skill1 > 0)
{
my.skill1 -= time_step;
wait(1);
}

is going to take approximately 1 second. With stuff like that


One more question: wait(-1); is working the same way I think??
Of course, only if it is a second.

Re: time_step question [Re: Logitek] #456137
11/11/15 17:53
11/11/15 17:53
Joined: Sep 2003
Posts: 6,861
Kiel (Germany)
Superku Offline
Senior Expert
Superku  Offline
Senior Expert

Joined: Sep 2003
Posts: 6,861
Kiel (Germany)
I suggest you don't use wait with a negative argument, it's error prone.
For example when you place wait(-x) at game start the delay will be rather random, depending on loading times or other stuff. It doesn't work with other stuff such as time_factor or maybe freeze_mode (not sure), and in general I find using it a bad practice.
Instead keep it with that manual time_step approach.


"Falls das Resultat nicht einfach nur dermassen gut aussieht, sollten Sie nochmal von vorn anfangen..." - Manual

Check out my new game: Pogostuck: Rage With Your Friends
Re: time_step question [Re: Superku] #456140
11/11/15 20:20
11/11/15 20:20
Joined: Jan 2006
Posts: 968
EpsiloN Offline
User
EpsiloN  Offline
User

Joined: Jan 2006
Posts: 968
time_step is the duration of the last frame (that is, how much the computer needed to display the last frame) in !ticks!, or 16-ths of a second, meaning, if time_step is equal to 1, the last frame took 1/16 of a second to display on the screen.

It isn't explained well in the manual...

So,
at 60 fps, time_step is roughly equal to 0.267 ticks.
If you want to move your entity with 60 quants per second at 60 fps, you have to do this:
Code:
my.x += (60 / 16) * time_step;


which means:
Code:
my.x += 3.75 * 0.267; // or ~1 quant...every frame...60 quants for 60 frames


!This is frame independent in theory!
At 30 fps, moving 60 quants per second the calculation becomes:
Code:
my.x += (60 / 16) * time_step;


Or
Code:
my.x += 3.75 * 0.533; // or ~2 quants every frame, 60 quants for 30 frames



I hope this sheds some light on that matter laugh

In theory , 16 / time_step should give you the FPS (meaning "wait(16/time_step)" should wait 1 sec.), but I've had my problems the last time I tried it, but it could have been some other piece of code in my game (its around 20k lines, so its hard to notice...)

Re: time_step question [Re: EpsiloN] #456144
11/12/15 07:45
11/12/15 07:45
Joined: Nov 2009
Posts: 201
Logitek Offline OP
Member
Logitek  Offline OP
Member

Joined: Nov 2009
Posts: 201
Thank you for the informations.

Re: time_step question [Re: Logitek] #456148
11/12/15 11:12
11/12/15 11:12
Joined: Nov 2009
Posts: 201
Logitek Offline OP
Member
Logitek  Offline OP
Member

Joined: Nov 2009
Posts: 201
Why I was asking all that questions?

Before I was not really interested in how time_step is working. It was working and that was enough for me.

Until I tried the spider script from the old aums:

spider_speed.x = 8 * time_step;
spider_speed.y = 0;
spider_speed.z = 0;
spider_speed *= time_step; // *


The interesting thing is, that the spider would have the double speed with 30 fps than with 60 fps.

And I know it is the 4th line *

But I don't understand why. It is working fine if I delete this line and change the speed. But I ask myself why this line is included in the script.



Now I have also a question about waiting some frames. Not for particles, only for a break of 4 frames.

For example I wanna wait(4); at 60 fps.

But only wait(2); with 30 fps.

What would be the best solution for that?
Something like wait(3.75 * time_step *4)? Because time_step * 3.75 would be 1.

Sorry for the stupid questions. I only wanna understand the complete process.

Last edited by Logitek; 11/12/15 11:16.
Re: time_step question [Re: Logitek] #456150
11/12/15 13:30
11/12/15 13:30
Joined: Sep 2003
Posts: 6,861
Kiel (Germany)
Superku Offline
Senior Expert
Superku  Offline
Senior Expert

Joined: Sep 2003
Posts: 6,861
Kiel (Germany)
The 4th line is just a bad mistake, nothing else. Maybe the code was using a var with the same name first instead of a Vector.

I already told you how to "wait" frame rate independent, which is why I don't get your new question.


"Falls das Resultat nicht einfach nur dermassen gut aussieht, sollten Sie nochmal von vorn anfangen..." - Manual

Check out my new game: Pogostuck: Rage With Your Friends
Re: time_step question [Re: Superku] #456155
11/12/15 13:49
11/12/15 13:49
Joined: Nov 2009
Posts: 201
Logitek Offline OP
Member
Logitek  Offline OP
Member

Joined: Nov 2009
Posts: 201
Hello.

Okay I understand, thank you for your help.

Page 1 of 2 1 2

Moderated by  HeelX, Lukas, rayp, Rei_Ayanami, Superku, Tobias, TWO, VeT 

Gamestudio download | chip programmers | Zorro platform | shop | Data Protection Policy

oP group Germany GmbH | Birkenstr. 25-27 | 63549 Ronneburg / Germany | info (at) opgroup.de

Powered by UBB.threads™ PHP Forum Software 7.7.1