Welcome, Guest. Please login or register. Did you miss your activation email?

Author Topic: Learning sfml and have a question  (Read 2139 times)

0 Members and 1 Guest are viewing this topic.

mjtilbrook1

  • Newbie
  • *
  • Posts: 5
    • View Profile
    • Email
Learning sfml and have a question
« 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

grumpaladin

  • Newbie
  • *
  • Posts: 7
    • View Profile
Re: Learning sfml and have a question
« Reply #1 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.

iocpu

  • Newbie
  • *
  • Posts: 10
    • View Profile
Re: Learning sfml and have a question
« Reply #2 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).

mjtilbrook1

  • Newbie
  • *
  • Posts: 5
    • View Profile
    • Email
Re: Learning sfml and have a question
« Reply #3 on: November 19, 2016, 05:29:17 pm »
Im watching this



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

iocpu

  • Newbie
  • *
  • Posts: 10
    • View Profile
Re: Learning sfml and have a question
« Reply #4 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++ and 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 and this book too.

 

anything