I don't Understand SFML?

closed account (j1CpDjzh)
I just started learning it, so obviously it's going to take me a little bit before I know it like the back of my hand, but I'm having trouble learning it.

I'm the type of person who likes to do a lot of functions, rather than having it all happen in the main loop, but with SFML it seems that everything has to be done in the main loop. I mean, I understand what the syntax means, but I just don't get how to put it all together and make a game out of it. Is there any advice that you can give to help me figure it out? Thank you so much in advanced.

(P/S: I'm working on a text-adventure-like game with a friend - he's doing the writing, and art. I'm doing the programming. So it's not anything too difficult, I'm just not entirely familiar with how SFML works.)
It only makes logical sense that "everything" is in the main loop. Otherwise the program would just run for one iteration, and abruptly end. To help organize your code, I would suggest doing it like how Laurent does it in SFML's Game Development Book code: https://github.com/LaurentGomila/SFML-Game-Development-Book/tree/master/01_Intro

They break it so that the main loop calls functions like "handleInput" "update" "render" instead of doing everything in the main function's loop. See the game.cpp file in Source
Last edited on
closed account (j1CpDjzh)
Ahh, thank you for the link. I didn't even think about using different files, until I saw that. It's a very clever way of doing things, and it all makes sense.
Topic archived. No new replies allowed.