effieciency or advantages over delta time or ticks?

For questions about using Classic.

Post » Tue Jan 25, 2011 11:41 pm

Hello friends, I am making a platform game with the run mechanics similar to a Castlevania or Kirby game... that is, you are walking, and then you let go of the walk button, and then press it again to run. After initially releasing the walking button, you only have a short time to press it again to start running, otherwise you just keep walking.

I have successfully done this, and achieved what I want without using the "wait" object, or delta time (the reason being I don't fully understand them). What I did instead was I set a private variable to a number (once the required conditions for running were true) and then subtracted from it every tick until it goes back to zero.

My question for the community is-- is this a bad way to do this? I think ticks are based on framerate, and so the ability to run within the game might be affected based on the frame-rate itself... if that was the case could I just set the framerate to a constant 60 perhaps? Or should I rework it based off of milliseconds and whatnot...?

Here is a cap for interested eyes...

http://dl.dropbox.com/u/19590484/cityscape.cap
B
5
S
1
G
2
Posts: 99
Reputation: 1,575

Post » Wed Jan 26, 2011 12:49 am

[quote="aldo":1fx0pjai]What I did instead was I set a private variable to a number (once the required conditions for running were true) and then subtracted from it every tick until it goes back to zero.
[/quote:1fx0pjai]

This is what I'm doing quite a lot as well. But...

[quote="aldo":1fx0pjai]My question for the community is-- is this a bad way to do this? I think ticks are based on framerate, and so the ability to run within the game might be affected based on the frame-rate itself... if that was the case could I just set the framerate to a constant 60 perhaps? Or should I rework it based off of milliseconds and whatnot...?[/quote:1fx0pjai]

...yes, you really should use Timedelta here. So instead of simply subtracting a certain value every tick (you don't need to add an always event btw for it to run every tick), you substract value*Timedelta, as described in the wiki. Otherwise the game will definitely run differently depending on refresh rate.
B
21
S
6
G
10
Posts: 1,024
Reputation: 7,445

Post » Thu Jan 27, 2011 2:11 am

I had a feeling I would have to learn how delta time works. Thank you for the wiki link!
B
5
S
1
G
2
Posts: 99
Reputation: 1,575

Post » Thu Jan 27, 2011 6:40 am

Not everyone might be running at the same framerate; even if you lock it at 60 FPS, some people with crappy computers may actually get half that amount. In that case their mileage may vary.

TimeDelta ensures that a moving object makes the same distance within same time on all computers.
B
62
S
21
G
12
Posts: 1,910
Reputation: 13,155

Post » Thu Jan 27, 2011 6:44 am

For more on time delta you might also want to have a look at Verve!, I made it completely time based with comments to every event.
Image
B
23
S
8
G
10
Posts: 1,820
Reputation: 8,242

Post » Thu Jan 27, 2011 4:50 pm

Just keep in mind that delta time has it's limitations too... if the player's computer suffers a loss of framerate, then your object will be moving more space per tick than normal. If the framerate drops too low, a fast moving object might skip past an object it is supposed to collide with!

For the most part this isn't a problem unless you're trying to collide very small or skinny objects that are moving fast. Just something to keep in mind when you're doing your collision events.

I'm not saying it's a trade-off though... you should ALWAYS use delta time for any time-based operations like movement. But if you need pixel-perfect collision with small, fast objects you'll probably have to code some custom collision checking routines.
Moderator
B
5
S
2
G
6
Posts: 4,348
Reputation: 10,971


Return to Help & Support using Construct Classic

Who is online

Users browsing this forum: No registered users and 4 guests