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