r/cpp_questions • • 6d ago

OPEN Learning to write video games from scratch

Hello everyone! This year I took a course on game development programming. I learnt alot of cpp basics, and eventually went on to write:

  • a couple classes from the Standard Templated Library
  • some trees and sorting algorithms
  • matrix and vector types for a raylib game (math as well)
  • a small raylib game with tanks
  • some enemy ai stuff such as pathfinding algorithims, a state machine & a behavior tree

eventually the course went into more Unreal Engine territory and I feel that as a C++ dev, it leaves alot to be desired. There's heeps I need to learn, and I want to also break it down to the basics before I go and write some more complex and large programs, but my end goal is write games basically from scratch, with the use of maybe some libraries at the very best. I do not enjoy or like the smell of game engines, since I do not know what is really happening underneath. I am trying to create a curriculum for myself for this coming year, of things to study on my own. Some ideas for what I want to do this year are: (in no particular order)

  • eventually create a 3D rendering engine (and understand the maths that makes it all work)
  • eventually write a minecraft clone (for learning purposes)
  • make some sort of RPG based heavily on this new game coming out on steam UNDERKEEP
  • and eventually.. become a C++ wise guy and make sellable games from scratch

does anyone have any suggestions, books, tutorials/guides, things to try and write, or communities to join, any suggestions at all? Thankyou!

9 Upvotes

9 comments sorted by

6

u/wilerpaler 6d ago

I'm on the same boat as you right now.

the other comments are right, there is a difference between making a game first or an engine first and then a game using that engine second.

however, and in my humble and not very experienced opinion based on that I did try to do what OP is trying to do.

You don't want to write the same code over and over again for every new game that you are making from scratch.

what I did was make a very minimal engine I called it mini-engine. it does very simple things like rendering 2d sprits, basic event handling and a bunch of the most basic stuff i don't want to rewrite for every new game I make. it keeps the flexibility of making a game from scratch but not too much that you have to rewrite a bunch of systems everytime. it grows with which ever game I'm making at the time.

I highly recommend SDL3 library over raylib as it allows to do more than just basic stuff.

Lazy foo's tutorial for SDL3 is still the best tutorial you'd find on SDL, the SDL3 tutorial is complete but just the basic stuff as he said he will import the SDL2 tutorials to the SDL3 tutorial.

you should read the SDL2 tutorial as its fully finished and complete AND it has at the end of each chapter the SDL3 equivalent code written by the creator of SDL himself.

try to make only 2D game/mini-engine first because the logic is same but the latter is just linear algebra. so getting good at 2D will make the transition to 3D much easier (based on my limited experience)

I'm following this path by lazy foo https://lazyfoo.net/articles/article01/index.php

I already made few games following it, and I can see the bigger picture when making a game. it all coming together.

if you making your own sprites(like I am), I recommend  inkscape for vector art and aseprite for pixel art.

( I know you can use pre built sprites at the beginning but its also a great learning experience imo)

if you serious about art than http://drawabox.com/ is that way.

don't use AI because( and in my heavy experience) it's terrible for trying to learn from it.

if anyone is more experienced than me, than please correct me if I was wrong with this.

1

u/Better_Drop8910 6d ago

wow cool, SDL3 seems very cool. funny article, thankyou for the reply

4

u/FineCarpa 6d ago

This goes onto the age old question.

Do you want to make a game or a game engine?

If it's the latter then I would start learning OpenGL and/or SDL3. I like some of The Cherno's videos too.

2

u/Better_Drop8910 6d ago

from what I understand, the answer would be that I want to make a game/s.
the closest I can imagine getting to an engine is some sort of 3D level editing software if I ever reach the stage where I want to make a 3D adventure game (think zelda) and still don't want to move to a commercial game engine

4

u/Twitchery_Snap 6d ago

You know how many people it takes to build a game engine? How many decade people put into that project? Manage scope is key for a project like this

1

u/Qwsdxcbjking 6d ago

Making your own game engine doesn't mean you have to make unity or unreal. It's not super difficult to make a very simple, bare bones engine by yourself in less than a month of hobbyist time. It obviously won't be feature rich at all, but you can build that up over time with each game as you learn what features you actually use often.

1

u/Discordbothost 6d ago

Since you've already got a raylib tank game, use it to make a tiny level editor. Start with a tile grid you can paint, then save it and load it in the game. That gets you practice with the part you actually want to build, and the first version can stay 2D.

0

u/Better_Drop8910 6d ago

I did do this, so far I have a level editor that allows me to draw and rotate sprites, it packs them into a .txt using bitwise. very fun to make

it wasnt beautiful but yeah, all because I was too impatient to figure out Tiled's .json export.
I will definitely be doing more editor'ey stuff like this, at least while I am making 2D games.

1

u/Hkiggity 6d ago edited 6d ago

I’ve been making games on sdl3. If you have heard of it. It’s pretty bare bones and it’s up to you how bare bones you want to be with graphics. You can use their renderer first then use ur own once you can make one. It also supports all major graphics APIs and sld3 recently created their own API. I plan on learning vulkan later. But for now I’ve been using sdl3 abstractions. I haven’t used raylib but instead of just loading a texture. In sdl3 you load it into cpu then gpu, then delete the copy in ram and use one in vram. Its still abstracted but its a nice level below raylib. Plus you can change this later to do everything urself (e.g make ur own buffers, manually move memory) that’s why I wanna use vulkan later.

It’s a great library if you just want something from scratch but not write sys calls. It’s a multimedia library. As well. So can play what u make on windows, Mac or Linux. I have a similar path/ goals as you