I get different results with the same execution of code

Get help using Construct 2

Post » Sun Feb 22, 2015 1:26 pm

I am running into problems getting an exact same outcome when I run the same version of the same .xcap.

As an example Here is a simple concept which shows this:

some event that rotates a simple box sprite by 1 degree every tick.
wait X seconds then stop the rotation.

result: the box will be at different degrees of rotation when i run the game each time (usually very close together varying by 1 or 2 degrees and averaging where you would expect it end to at 60fps)

So my question is if the game should be designed to run at 60fps why is X seconds not showing a rotation result of 60*X degrees every single time?

I read about delta time and tried to run the game using that. I found that the delta time varies just as much as using X seconds and is not consistent also since delta time varies from tick to tick (averaging out to be 1 second/60). delta time seems especially strange on the first few ticks of the execution of a game which really throws it off.

So my question is this:

Can i somehow make events that wait X frames rather than X seconds? and is that how the code should be, essentially making the wait command useless for someone looking to control exact "wait" times which result in the same rotation of a box every time I run the game?

Why does the wait command exist at all if this is true? (perhaps most games don't care if the box is 1 degree off?)

Perhaps I have just missed something which will explain all of this to me but if I haven't does Scirra plan on implementing a "Wait X Frames" event condition? I would find this condition very useful in almost every event in every game i am working on and would be glad if it was added.

As a work around I made a global variable "Rotate120Frames" and add 1 to it every tick. I put the event condition "Every Tick" and "Rotate120Frames<=120" which is basically a "wait 120 frames" event condition. This works and i get the same rotation every time. it seems a bit tedious as i will need a variable for each wait x frames in my game which will add up fast and get messy.

Anyways thanks for any insight you can offer thank you.
B
4
Posts: 17
Reputation: 234

Return to How do I....?

Who is online

Users browsing this forum: No registered users and 6 guests