Before diving into any game engine we should start with talking about game development. Game development itself is an interdisciplinary area which involves programming, graphic design, sound design, story telling, marketing and user experience.
A perfect mix of them and balanced presentation of those disciplines gives us a good game.
Unfortunately, a brief introduction to game development will only cover programming side of those different disciplines.
Introduction to Game Development
I want to keep this article as simple as i can. I am not going to talk about complex rendering algorithms and their C++ implementations, and 1000 lines introductory code for drawing triangles in Vulkan. (Yes, we can do it later)
Simply, game development is looping / updated a lot of resources inside of a loop. As you may remember, target FPS count is around 60 for most of the games. We have 16.6 ms to render each frame to catch up with 60 FPS.
What is a Game Loop
A game loop is core of every game. Let me show a psuedo code for a simple game loop.
while (gameIsRunning):
pollInput()
update()
render()
endWhile
Everything we have in game happens inside this loop. As mentioned, we only have 16.6 ms to iterate on this loop. (A short time to do a lot of things)
What Happens in The Loop
Engine (what runs the loop) receives user input and updates variables (according to the rules / codes). Then engine iterates over the game objects in the game loop and updates all object in the game. Position, speed, rotation, animation frame, everything is calculated according to these changes.
In the render method, engines render renderable object to screen.
After loop completes game quits.
My Code is Compiling
16.6 Ms is a very short time. That is why game engines are usually written in compiled languages like C/C++/Rust etc. Also, this is the reason of we are using shaders (a code which runs on graphics card instead of CPU), multiple cores on GPU can handle small calculations with higher parallelism than CPU.
Of course Java can be also used to develop high performant code, so you can pick the language you are going to use according to your previous experience.
Objects, Object, Objects
When we are talking about game development we need to talk about some types of objects used in game development.
Take particles for instance, shiny, reflecting, moving objects, and a lot of them is being spawned and managed simultaneously. Each particle and particle spawner are being updated in the update call. Particle system should be designed very performant.
Or collision objects, on each frame collusion with other objects are being re-calculated.
As you can see, games are designed with OOP paradigm, in a very performant way.
Godot Engine is also developed with C++ and OOP.

Comments
Post a Comment