My Journey into Gamedev: Delta Time

My Journey into Gamedev: Delta Time

ยท

4 min read

So, I decided to make a Game!

How? Well, I used to Godot. I had been interested in Game Development since I was 13. I never finished making a game completely, but I learned a lot of things back then. I had used Unity, Construct 2D, and of course, Scratch. All of the times that I had started with Game Development, it got too complex for me due to the Physics, and so I left it be :\

What changed?

Well, as I grew older, I was taught more complex topics in Physics. This period was also marked by a growth in my problem-solving mindset. I had completed many other projects in Python and Javascript, and I was ready to get back in Game Development, this time, in Godot. I had taken a special liking to Godot, which I will explain in the next section

Why Godot?

I chose Godot because it is FAST. That's by far the most important reason. I always like things to be at my fingertips, so whenever I have an interesting idea, I can get straight to executing it. This is done surprisingly well by Godot. It takes ~20 seconds to get into the main editor. No sluggish splash screens!

It has no installer either, you just download the zipped version, extract, and you're good to go! Side note: If you want support for C#, you need to install the Mono SDK (Not exactly sure what it is, let me know in the comments), a link to which is provided on the Godot downloads page.

There are plenty of other reasons, such as being open-source, but I won't list those reasons here. There are other sites that explain in-depth why Godot is an epic Software.


The start of it all!

I started my journey by watching a tutorial by Garbaj. His guide gave me a basic idea of a character controller script, complete with movement, jumping, and gravity. After that, I set out to implement double jump, which was pretty simple too. Just check if my double jump variable is not 0, and if it isn't then jump and reduce the variable by 1. So it starts out with an initial value of 2, and then when it is 0, you can't jump unless you touch the ground again.

I was pretty pumped! It was fun to be able to do something without needing to look something up :P Well, soon after that I hit a roadblock. Delta time.

Delta Time :0

It took me a whole night to properly figure out what delta time is, but this article helped me understand delta time well.

Simply put, it makes it so that a unit (say meter) per FRAME, is converted to that unit per SECOND. In a game, code is run EVERY FRAME, a term which you might have heard if you've played games. So if you're running it at 60 frames per second, that means the code will run 60 times in just ONE second. So to make a unit uniform and INDEPENDENT of framerate, you use delta-time.

To convert, just multiply the unit by delta (provided by your game engine) and it will now be per second instead of per frame. It does this by calculating delta-time relative to the frames per second. so when it is run every frame, it will equal the amount you wanted in a second. I know I do a bad job of explaining it here, but a simple trick to remember what it does is that when you multiply anything by delta time, it is now changed to that thing per FRAME to that thing per SECOND. Understanding this helped me a lot later on.

What if you want it to run per 0.1 second? Now you can easily just do (value * delta)/0.1


Well, Thanks for reading!

I know, this was a much shorter one, but I will be updating this series regularly, with more short content, so stay tuned for that! I might also start Dev Logging on my Youtube Channel, so keep an eye out for that ๐Ÿ‘€