DEV Community

Cover image for Game Programming Fundamentals
Fatih Küçükkarakurt
Fatih Küçükkarakurt

Posted on • Updated on

Game Programming Fundamentals

If you are looking for an answer to the question of How to Develop a Game, let's think together. First of all, we are not going to talk about the need to learn a software language or game engines to program games. In fact, the game industry is a field that includes many different industries such as mathematics, art, psychology and even cinema. In other words, it is never enough to master game engines and learn a software language. So what do we need to know? Let's see together.

Game Mechanics

One of the biggest reasons why games reach huge audiences today is Game Mechanics. In order to better understand the game mechanics, we have to think of a system. There are various sub-parts that this system controls. To understand this better, you can examine the diagram below.

Game Mechanics


As you can see in the diagram above, the system takes on the following tasks:

  • Runs the load and save part to load the files.
  • It then enables the intro animation to run using the audio and graphic parts.
  • During the use of the game interface, user inputs ensure that the graphics and sound parts work in harmony.
  • Finally, it ensures that the graphics, sound, user input, artificial intelligence and network parts work in harmony in the game.


The Resource describes the necessary files for the game located on the hard disk.

  • These files contain configuration files that describe the configuration in which the game will run by default.
  • If available, it contains the video file for the intro that will be played when the game first starts.
  • Contains files where the user gets information about the game before the game.
  • It contains the files containing the graphics, music and chapter information in the game.

Game Model

  • It is the state of the game graphics, music and text files loaded into memory from the resource in memory.
  • Image files are stored in memory or in the texture memory of the video card.
  • Section, score, etc. information is kept in variables and data structures.

Upload and Save

This part is the particle that takes the graphics, music and other information from the source and puts it into the memory (game model) and undertakes the process of saving it back to the source in case of new score situations or when the game is recorded.

Upload: Configuration files, Chapter Files, Image Files, Music and Sound Files, 3D Model Files, Video Files, Help Files.

Save: Score files and other documents to be saved during the game


This is the most important and hardest part of the game in my opinion. Because it is impossible to have a game without visuals. This part is responsible for painting the screen.

  • Playing the Video
  • Displaying the Game Interface
  • Viewing Score, Help and Configuration Information
  • Displaying the Game's Own Graphics

User Inputs

A game without interaction would be like a movie. User Interaction is definitely one of the sine qua non of game mechanics that connects users to the game. The system is in constant interaction with the user. Keyboard, mouse etc. this is where we're going to use the equipment.

  • Using the Game Interface
  • Reviewing Help Files
  • Reviewing Score Files
  • Configuring (System and Game Related)
  • Controlling the user's character in the game

Sound and Music

If you want to understand the importance of sound and music, please turn off the sound while playing games. You will notice that the value of the game drops when there is no sound. We can say that the value of the sound is as valuable as the graphics of the game.

  • Music playing in the background
  • Sound effects for collisions and movements

Artificial intelligence (AI)

Let's consider the intelligence level of the enemies in the game. The more humanoid they look, the more intelligent the behavior and the more fun the game will be. It doesn't just have to be the enemy. In an open world game, citizens passing by look at their wristwatches, wipe the sweat on their foreheads in sunny weather, give way to you, even argue with you, attack you when you treat animals badly, etc. All of them can go into the subject of artificial intelligence.

Network Listening and Sending

This part is the part that allows the game to be played by more than one person. In this part, the parties send information to the game server and the information received by listening to the server is updated in the game.

Establishing the Session: The players who will participate in the game agree on which protocol and on which port they will communicate at first.

Packet Delivery: The moves made in the game are sent to the server in packets. Then the server distributes it to all parties after making the necessary change.

Package Pickup: Simultaneously, the parties are aware of the changes made by listening to the server and reflect this to the game.


Computer game lovers always want better graphics, music, physics and better artificial intelligence. For all this to happen, one of two conditions must be met.

  • software optimization should be done, new algorithms should be found,
  • appropriate equipment should be used and the processing speed should be increased.

Today, new algorithms and code optimization progress much slower than the speed at which hardware develops. Now, instead of new algorithms, the software, focuses on issues such as reusability, code openness, code security (encapsulation). The hardware is trying to increase the processor speed and memory capacity as much as possible for these new requests.

In this section, we can talk about many different hardware such as the following:

  • graphics cards,
  • processor,
  • motherboard,
  • sound cards,
  • monitors, speaker and new input devices etc…

Programming Language

Programming language is a computer language that offers the opportunity to develop commands and software in a certain standard form. Thanks to programming languages, it is possible to control what kind of output a computer can give in which situation. In short, computers and humans can communicate efficiently thanks to programming languages.

Since our topic is game development, we will focus on this subject. Depending on what you want to do and create, you can develop games with all programming languages. There will be those who insist you learn C++. This is absolutely not true. You can make great games with JavaScript, C#, Python or even C. A choice-based adventure game that only works on the console screen can be great. But if you want to make games that are more professional and reach more people, please keep reading.


Since C++ is a high-level language that will teach you the basics of object-oriented programming, it's a good idea to learn it. It is also the language used to create console and Windows games. Also, it uses OpenGL or a similar framework (If you continue reading the guide, I will give a detailed explanation about OpenGL).

C++ is a fast compiling programming language. You also get a lot of say in memory management. It has extensive libraries useful for designing and powering complex graphics. There's a lot of literature for you to improve on, because it's been the programmer's language of choice for decades, and you'll find online communities ready and willing to answer your questions.

It would be a lie if we said that C++ is easy to learn. It is difficult to learn compared to other programming languages. But it can be useful not only because C++ games are easy to distribute on various platforms, but also because if you know C++ you can quickly learn C# and other object-oriented languages. Both C++ and C# are only two of the most actively used programming languages today.

To sum it up, learning C++ is a good choice if you want to create games from scratch.


The benefit of C# lies in the XNA framework. This is a set of tools and workspaces by Microsoft that are particularly suitable for games on Xbox or Windows platforms.

If you compare C++ and C#, you might consider this example. C++ is like a manual transmission car. C# is like an automatic transmission car. Let's consider the Unity game engine. If you use the Unity game engine, you have to code the scripts in C#. However, the core of this game engine is C++ code.

The platform you target, the game you want to make, the game engine you will use, etc. factors will affect the language you choose. But yes learning C# would be a great idea.


Game programmers often use Java because Java supports multithreading and sockets. Multithreading uses less memory and makes the most of available CPU without blocking the user while intensive processes are running in the background. Sockets help in the creation of multiplayer games. Also, Java runs in a virtual machine so the game is easier to deploy.

Also, if you want to develop applications and games for Android platforms, Java would be a great option.


Making games for browsers is very different from making games for consoles. If you need 3D graphics or complex graphics and a content management system, you will also need SVG or WebGL.

Flash animation using the programming language ActionScript was common for browser games in the past, but Flash is finished.

A WebGL-enabled Java engine such as PlayCanvas, developed at MIT, allows users to simultaneously work in the game with an online browser and publish to multiple platforms.

Moreover, there are great game engines that you can use JavaScript. To give an example of these, we can definitely say PhaserJS.


What is API? It stands for Application Programming Interface. They are libraries that help us perform specific tasks with a number of functions they provide.

The APIs we will use in our games will be libraries that allow us to take advantage of them by providing an interface to the graphics and sound hardware. For example OpenGL, GLUT, GLU DirectX (Direct3D, DirectDraw, DirectShow, DirectInput, DirectPlayer, DirectSound, DirectMusic), Java2D, Java3D, JavaMusic, JavaNET, JavaMedia, FMOD, etc…

I think it will be very useful to learn the OpenGL library. So let's talk a little bit about OpenGL.


OpenGL resides on graphics hardware and provides an interface to that hardware. This interface contains 250 different instruction sets. 200 of them are in the OpenGL core and the other 50 are in the OpenGL Utility Library. You can develop 3D interactive applications thanks to the OpenGL graphics API.

OpenGL is a platform independent API. It has been designed as an interface that performs a command flow that is run consecutively. In order to ensure this quality, it does not include commands such as windowing tasks and obtaining user input, but instead benefits from the windowing and input services provided by the platform it uses to OpenGL. Likewise, it does not contain commands for creating high-level 3D objects. But with the commands it provides, it can create an automobile, plane or molecule surface. To create the desired models of this type with OpenGL, we make use of the points, lines and polygons in the small toolkit we call the geometric primitive.

Of course, the creation of a better graphics system can be built on top of OpenGL's core structures. OpenGL Utility Library (GLU) has many high-level modeling features, Quadratic surfaces, NURBS curve and surface rendering.

What are the Operations Performed During Rendering?

In the following 4 stages, you can briefly see what processes are happening during the rendering process.

  • Creating shapes and geometric objects with mathematical expressions (OpenGL has tools to create primitive objects such as point, line, polygon, image, bitmap)
  • Arrangement of objects in three-dimensional plane and adjustment of perspective
  • Calculating the color values of the objects, applying them to the screen by taking into account the light and texture values
  • The conversion of the definitions and color values of all object values to pixel values, briefly the realization of the rasterization event.

A Simple OpenGL Code Example

Doing so many options and complex operations with the OpenGL graphics system can make OpenGL complex. But basically, the structure of a program made with OpenGL is very simple. What you're doing is actually defining certain states and putting a control mechanism about which objects OpenGL should render and how it should render.

You can actually think of OpenGL as a Real Time Rendering Software. Before introducing this programming construct, let's try to grasp some terms.

       initializeAwindowPlease( );
             glClearColor(0.0, 0.0, 0.0, 0.0);
             glColor3f(1.0, 1.0, 1.0);
             glOrtho(0.0, 1.0, 0.0, 1.0, -1.0, 1.0)
                    glVertex3f(0.25, 0.25, 0.0)
                    glVertex3f(0.75, 0.25, 0.0)
                    glVertex3f(0.75, 0.75, 0.0)
                    glVertex3f(0.25, 0.75, 0.0)
             glEnd( );
             glFlush( )
             UpdateTheWindowAndCheckForEvents( );
Enter fullscreen mode Exit fullscreen mode


First of all, thank you very much to those who have come this far. Our conclusion from this article should be:

Game development is not just about learning programming languages and game engines.

You have to master a lot of technology. Among the technologies we did not mention are programs such as Adobe Premier, Adobe After Effects, 3D Studio Max, Lightwave, Maya and Poser. Learning and mastering each of these is only possible with experience.

That's why we talked about hardware and OpenGL. Love your computer and keyboard rather than focusing on one thing. The best and only rule of thumb to master game development is this:

Be curious, read a lot and try without fear.

Top comments (16)

eliferd profile image

Nice article here!
It's been forever since I'm trying to learn OpenGL. But whatever tutorial I'm following, I'm still struggling with it. Even though this lib is a war machine lol

fkkarakurt profile image
Fatih Küçükkarakurt

The biggest mistake made is to give up halfway through, you know. I am pleased to hear that. It is important to enjoy this work and not be afraid of the iceberg. I hope everything goes well for you.

eliferd profile image

I'm not giving up, but I'm still struggling to understand some functions names and what they do. Such as "glOrtho". Of course when the name is very explicit I'm fine. 🙂👍

Thread Thread
fkkarakurt profile image
Fatih Küçükkarakurt • Edited

There is nothing that cannot be solved with hard work. If there is any problem, you can ask me.

gustavohd18 profile image
Gustavo Duarte

Great article.

andrewbaisden profile image
Andrew Baisden

I am obsessed with games so this article was fun to read.

pandademic profile image

Nice job!

rubns77874892 profile image
Rubén S

Nice article here!

dukemagus profile image

Good stuff.
Small correction, though: Unity doesn't accept javascript anymore. It was purged together with boo and unityscript some years ago. Now all the scripts are either C# or their built in visual scripting (bolt).

fkkarakurt profile image
Fatih Küçükkarakurt

What I mean here is being able to interact with the WebGL Browser script. When creating content for the web, you may need to communicate with other elements on your web page. Or you may want to implement functionality using Web APIs that Unity does not currently expose by default. Either way, you need to interface directly with the browser's JavaScript engine.

For this we can call JavaScript functions from Unity scripts.

mergeInto(LibraryManager.library, {

  Hello: function() {
    window.alert("Hello, world!");

  HelloString: function (str) {

  PrintFloatArray: function (array, size) {
    for(var i = 0; i < size; i++)
    console.log(HEAPF32[(array >> 2) + i]);

  AddNumbers: function (x, y) {
    return x + y;

  StringReturnValueFunction: function () {
    var returnStr = "bla";
    var bufferSize = lengthBytesUTF8(returnStr) + 1;
    var buffer = _malloc(bufferSize);
    stringToUTF8(returnStr, buffer, bufferSize);
    return buffer;

  BindWebGLTexture: function (texture) {
    GLctx.bindTexture(GLctx.TEXTURE_2D, GL.textures[texture]);

Enter fullscreen mode Exit fullscreen mode

The recommended way to use browser JavaScript in your project is to add your JavaScript resources to your project and then call these functions directly from your script code. To do this, place JavaScript encoded files using the .jslib extension under a "Plugins" subfolder in your Assets folder. The plugin file should look like the one above.

Then you can call them with your C# script.

In conclusion, you are right. There is no longer active support for JavaScript. I agree with you. But if we look at the WebGL side, we can use Unity and JavaScript together. I'll edit the sentence in the article anyway.

Thank you.

mycheema profile image
MyCheema • Edited

Amazing article Can you please suggest me best learning course for Gaming.... Site

fkkarakurt profile image
Fatih Küçükkarakurt

Choose a language you are confident in and make your first game. But really do. Even trying to do it will teach you more than dozens of courses. Let's say you are trying to do a simple tetris. You will have learned to draw random shapes on the screen, to direct them, to destroy the shapes in the same order and to learn the logic of the leaderboard. Then you can change these shapes, change their colors and rules to create your own advanced tetris game.

Any tutorial you can find will work. If you want to get involved with Unity, Brackeys will do the trick.

However, it is important not to depend too much on tutorials and courses. After a while, you start to write code by heart and not be able to develop anything. This is not a good thing. So open your editor and really fight with your keyboard. You may only know about if and for loops. Does not matter. Just try.

After you've actually done a finished tetris, you can make a side-scrolling platform game, respectively. You can learn to scroll on the screen and work in larger areas. As you know, Super Mario Bros. was a great example of this. If you can clone it, you can be sure that you will gain a whole new dimension. Music, artificial intelligence monsters, changing maps and animations... Even Mario alone teaches a lot. After that, you can try making PacMan. Pacman is a really difficult game. Don't be fooled by how old and simple it looks. It is one of the projects where you can learn the paths of artificial intelligence, raytracing system and graphical interfaces to follow.

One of the monsters follows you, the other follows the food, another tries to cross your path, and the last one wanders in a certain area. It would be nice to watch the tutorial while doing all these. However, I recommend doing this once or twice. There are many great developers on StackOverFlow where you can find the answer to your question. Just try. You don't even need a game engine.

Developers made games that run on the command screen, even using bash alone. Check out the repos on GitHub. And never stop wondering.

Here are some resources I recommend for you:

I wish you success on this long and fun road that requires patience.

bgalvao profile image
Bernardo • Edited

I want to code a game, just for fun. I've picked Godot just because. The problem now is that I have no game concept to get started with - and I want to do something that is only slightly original.

Thread Thread
fkkarakurt profile image
Fatih Küçükkarakurt

This is a great decision, I wish you the best of luck. Godot is a great game engine, moreover, I love working with C++ and Godot's open source structure is very entertaining and helpful with its great communities.

After you find your game idea, I suggest you think about Game Design in detail. For this, you can browse GDD (Game Design Document) templates on Google.

Preparing a GDD will help you a lot during the development process and will allow you to collect your ideas in one file. This inevitably increases your development speed quite.

I can't say anything about game ideas because I don't know your industry. But watching too many movies, daydreaming, reading books and playing a lot of games will definitely give you an idea. I know these are things that are said all the time, but they are definitely very useful.

Dream a lot. This is a process that requires a lot of patience.

Also, thanks for reading the article. I wish you success.

yendenikhil profile image

Amazing article! Kudos.

phandungtri profile image
Phan Dũng Trí

Informative article! Thank you!