- Home /
How does a game engine work and how can you use that to make one?
I was wondering how I can take how a game engine works (which I have some knowledge of) and was wondering how I can take that and its algorithms and equations or something to develop a simple physics or rendering engine to build my knowledge on how they got there. I know this stuff might be hard to wrap my brain around but I really like learning this stuff so anything will be great!
Answer by zactanpeterson · Nov 20, 2019 at 02:26 AM
Professionally made game engines like Unity are made with large teams over a long time. The most basic part that is in every game engine is the game loop that runs constantly, it keeps track of time between frames and limits frame rate if needed. In the game loop, you would add on stuff to be updated every frame and all the other calculations of physics and rendering. Of course, an engine like Unity has a lot of bells and whistles, and a whole UI that makes using it easier, but that's mostly just for commercial use. All you really need is a game loop with physics and/or rendering, then make other classes and methods to create stuff to put on the screen. You'd also want input handling too. Making game engines is not an easy task and unless you've got a very strong knowledge of Object-Oriented Programming(OOP), I wouldn't worry about making one.
OOP is not a requirement to create a game engine. However most you said is spot on. Creating an engine is much more about knowing the operating system you build the engine for, knowing how to use a graphics interface (OpenGL / DirectX / WebGL / ...). Of course you should know about shaders, how to compile and load them in your graphics API, how geometry is rendered, ... You should have a solid understanding of matrices, homogeneous coordinates and perspective projection in general.
Creating a rudimentary physics engine from scratch is still a lot of work. This of course requires a solid understanding about physics and the mathematics behind it. Though whatever you come up with most likely will not even come close to the performance and feature set of PhysX which Unity uses.
Creating an audio interface is also not that trivial. Again you have to know how to utilize an Audio API (OpenAL / DirectSound / XAudio2 / WebAudioAPI). Also you should know how audio works in general and what PC$$anonymous$$ samples represent.
Even I already mentioned "maths" before I'd like to stress that you should not only have a great understanding of linear algebra and calculus but also how to implement a certain mathematical concept with a computer.
Apart from the fundamental building blocks of an engine (graphics, physics, input, audio) there are alot of management tasks which need to be solved. This includes memory management, material management, rendering passes, spatial object management, ....
Of course if you just want to create a certain game from scratch you don't need a full blown game engine. Though many things mentioned still apply. Actually many "old games" like Quake 1 /2 or Halflife 1 do not really use a general purpose / dedicated engine. They are essentially just games created from scratch. The "engine" is essentially just the basic functionality of the game. The complete Quake3 source code has been released under the GPL license. Be careful when using such a released project as "inspiration" for your own since already small portions of code could be considered a derivative work and would force you under the GPL as well.
In short I would say: If you have to ask how to create a game engine, you are far from being ready to create one ^^.
Ok so there is a loop that runs constantly updating the game and then there are some graphics and audio interfaces that help also. I am wondering though about the graphical interfaces do they handle the actual game graphics, the engines UI graphics, the design graphics or all? Also, do you just need Visual Studios or any other compiler and a graphical interface and an audio API?
Thank you guys so much so far I have actually learned a lot!!! I am amazed at how helpful its already been thanks!
Your answer
Follow this Question
Related Questions
Distribute terrain in zones 3 Answers
hollow objects, hollow mesh? 1 Answer
Some Ideas please? 1 Answer
Multiple Cars not working 1 Answer