DEV Community

Cover image for Game Programming Fundamentals

Game Programming Fundamentals

Fatih Küçükkarakurt on January 23, 2022

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 n...
Collapse
 
eliferd profile image
eliferd

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

Collapse
 
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.

Collapse
 
eliferd profile image
eliferd

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.

Collapse
 
gustavohd18 profile image
Gustavo Duarte

Great article.

Collapse
 
andrewbaisden profile image
Andrew Baisden

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

Collapse
 
pandademic profile image
Pandademic

Nice job!

Collapse
 
rubns77874892 profile image
Rubén S

Nice article here!

Collapse
 
dukemagus profile image
Duke

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).

Collapse
 
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) {
    window.alert(UTF8ToString(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.

Collapse
 
mycheema profile image
MyCheema • Edited

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

Collapse
 
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.

Collapse
 
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.

Collapse
 
yendenikhil profile image
Nik

Amazing article! Kudos.

Collapse
 
phandungtri profile image
Phan Dũng Trí

Informative article! Thank you!