How does the whole process really work?

Hi! I'm currently on lesson 8 of this C++ tutorial series:

I was very curious, as my dream job is being a game engineer/developer for Riotgames or possibly something else, how do games really work?
Is it a bunch of linkings? Where lines of C++ stating your viewpoint of the world, and when one key is pushed, C++ allows the screen to be turned, and where the graphics and code are synced up to make a game?
Is it a game of if's and if else's in the code, whereas the player does this or that, this or that happens?
It's hard to get a grasp on this...

Also, I would like to know how SMFL works. I was told it allows you to draw up those things, where you literally just upload a picture to the code? Or animations? Confused...
how do games really work?

This is a very broad question so it's hard to give a direct answer.

Let's take a very simple example of the classic game of Pong. You have 3 key parts... 2 paddles and the ball. The idea is you want the user(s) to be able to move the paddles, and you want the ball to bounce off of them.

So how do you do that?

First you need to understand some fundamental concepts of drawing, and updating logic. Often times (for simplicity), these two things are done side by side, and the logic runs one step every frame. So in that case, a game that runs at 60 fps would have 60 logic updates per second... one logic update right before each time the screen is rendered.

So what is a logic update? Well it where you change the game world ever so slightly to simulate the passing of time. Objects get moved, collisions are checked, etc. In the Pong game, you'd have to do the following every logic update:

1) See if the player(s) want to move the paddle. If they do, move the paddle a tiny bit.
2) Move the ball.
3) Check to see if the ball connected (collided) with any paddle. If it did, change direction.

Once you move the paddles and the ball, you can draw another scene. This scene will draw the paddles and balls in their new position, giving the illusion that they're moving.

Do that several thousand times in a loop, and you have a game.

Larger games are obviously more complicated... but that basic idea is the same.

where you literally just upload a picture to the code?

No you don't do that. The picture is stored in a file on the harddrive. Your code would open the file and load that picture into memory where it can be drawn.

Or animations?

SFML does not animate things for you. You would be responsible for animating them yourself. Animation can be done by moving a graphic and/or by changing which graphic is drawn.... gradually over time.


Best way to learn is to just do it. Get SFML, look at some of the tutorials, and start making a simple game.
Topic archived. No new replies allowed.