Skip to main content

Indie game storeFree gamesFun gamesHorror games
Game developmentAssetsComics
SalesBundles
Jobs
TagsGame Engines
(+2)

Enjoying the app, very accessible. However, the time delta lesson is messing me up a little. We have been doing the rotate function in the previous lesson without it and now I'm being told that you have to multiply it by delta otherwise the code isn't consistent. I am able to continue and apply what is taught, but I don't fully understand yet why that is.

(4 edits) (+7)

The delta lessons explains it pretty decently in my opinion, but I'll try to sum it up more:

They first teach you how to rotate stuff in the most basic way possible, just so you know what rotate() does and so on.

And afterwards, they explain you how to *properly* rotate things. it's how you should do it 99.9% of the time, they just didn't do it straight off to teach you the basics first.

As the lesson mentions, not multiplying something by delta will make it rotate (or move, etc) as fast as your computer can handle. And you usually do not want a video game character's movement speed to be attached to computer specs - it just makes no sense except for advanced scenarios like trying to perform a simulation as quickly as possible and skip to the end.

And then they explain you that multiplying things by delta (or you could also run the function at a fixed time interval without multiplying by delta, which also works but is visually less smooth) is how you'll almost always want to do things like mentioned.

If you want real life examples of this, Evoland 1 breaks on high refresh rate monitors because of this (the game can't be beaten! the final boss becomes too fast to be killed), Forager runs faster on higher refresh rates/FPS (you can kinda speedrun the game as if the forager guy was on crack, to me it was funnier but a little chaotic), and Fallout games are known to break at uncapped FPS, IIRC even in multiplayer where some players would run faster than others because they had uncapped their FPS, working almost like a cheat. Unless you want your game to end up like these games (it isn't pretty), you'll want to be smart and remember to multiply every single relevant thing by delta time difference so things are time-based not beef-based :P

(Eck, even in Terraria, when holding your mouse button, it grabs/crafts one item per frame instead of something like 10 per second fixed, so it's very easy to accidentally craft too many things on good computers.)