SFML community forums

Help => General => Topic started by: mjtilbrook1 on November 19, 2016, 05:26:28 am

Title: Learning sfml and have a question
Post by: mjtilbrook1 on November 19, 2016, 05:26:28 am
Im currently learning SFML and im reading SFML Game Development and within the book it shows that i should run the game in a game class which has the methods
 public:
   Game();
   void Run();
   
private:
   void ProcessEvents();
   void Update();
   void Render();


now im also watching youtube tutorials and the tutorials are showing just having it all run in the main function,

which should i be doing?

thanks
Title: Re: Learning sfml and have a question
Post by: grumpaladin on November 19, 2016, 07:07:15 am
Im currently learning SFML and im reading SFML Game Development and within the book it shows that i should run the game in a game class which has the methods
 public:
   Game();
   void Run();
   
private:
   void ProcessEvents();
   void Update();
   void Render();


now im also watching youtube tutorials and the tutorials are showing just having it all run in the main function,

which should i be doing?

thanks

It would be good practice (especially for bigger projects) to have your code placed in a Game class like that. Cleaner, more reusable code that is easier to debug is always preferable to a giant function somewhere. Breaking the code down into clean units = good practice, for all kinds of development not just game development.
Title: Re: Learning sfml and have a question
Post by: iocpu on November 19, 2016, 11:36:11 am
May I ask which YouTube tutorial are you watching? One thing to remember about programming tutorials in general is that they would often present a "quick and dirty" way to implement something because their goal is to explain the concept and not to dwell on the details (or good OOP practice for that matter).
Title: Re: Learning sfml and have a question
Post by: mjtilbrook1 on November 19, 2016, 05:29:17 pm
Im watching this

https://www.youtube.com/watch?v=blOBd49Io00&index=4&list=PLHJE4y54mpC5j_x90UkuoMZOdmmL9-_rg

thats just one of the videos in a series

if there is anything you reccomend me watching please let me know anything will help me
Title: Re: Learning sfml and have a question
Post by: iocpu on November 19, 2016, 07:59:55 pm
Can't really recommend any videos, as I personally prefer books. There are, however, lists of videos on things like C++ (https://github.com/fffaraz/awesome-cpp#videos) and Game Development (https://github.com/ellisonleao/magictools#general-game-development) (and much more) on GitHub. Perhaps you'll find something useful there?

As for SFML, I guess the official book would be a good start. In case you want to dig deeper into game development, I recommend this (https://www.amazon.com/Game-Coding-Complete-Fourth-McShaffry/dp/1133776574/ref=sr_1_1?ie=UTF8&qid=1479581859&sr=8-1&keywords=game+code+complete) and this (http://gameprogrammingpatterns.com/contents.html) book too.