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

Author Topic: Questions on the SFML game development book  (Read 1043 times)

0 Members and 1 Guest are viewing this topic.

devilswin

  • Newbie
  • *
  • Posts: 38
    • View Profile
    • Email
Questions on the SFML game development book
« on: January 05, 2015, 08:37:38 pm »
Hello,
I was wondering if anyone could answer any of the following questions that i have about the content in the SFML game development book up until the tiling section in chapter 3:
  • What is the purpose of having SpriteNode class when it basically has the same source code as all other classes?
  • Why does it seem like there is numerous unnecessary explicits and virtual functions that could be avoided?
  • It may have been explained in the book, why is there numerous "Holder" classes that do what appears to be the same thing?
« Last Edit: January 05, 2015, 08:40:25 pm by devilswin »

eXpl0it3r

  • SFML Team
  • Hero Member
  • *****
  • Posts: 10998
    • View Profile
    • development blog
    • Email
Re: Questions on the SFML game development book
« Reply #1 on: January 05, 2015, 10:51:41 pm »
What is the purpose of having SpriteNode class when it basically has the same source code as all other classes?
As far as I can tell the class is used to draw some simple sprites at a fixed location. What else would you want to use?

Why does it seem like there is numerous unnecessary explicits and virtual functions that could be avoided?
explicit keywords are used for clean code/good code design, since instantiating classes implicitly will often lead to hard to understand code.
Virtual functions are part of the polymorphic entity system. How would you "avoid" them?

It may have been explained in the book, why is there numerous "Holder" classes that do what appears to be the same thing?
Because you have to manage different resources. The simplest approach is to instantiate a class for each resource. Other design are possible, but it would complicate the code too much and distract from teaching the concepts to the reader.
Official FAQ: https://www.sfml-dev.org/faq.php
Official Discord Server: https://discord.gg/nr4X7Fh
——————————————————————
Dev Blog: https://duerrenberger.dev/blog/

 

anything