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

Author Topic: SFML Game Development -- A book on SFML  (Read 284013 times)

0 Members and 6 Guests are viewing this topic.

Nexus

  • SFML Team
  • Hero Member
  • *****
  • Posts: 6287
  • Thor Developer
    • View Profile
    • Bromeon
Re: SFML Game Development -- A book on SFML
« Reply #105 on: August 01, 2013, 12:57:24 am »
The possible performance advantage of std::unordered_map comes at a cost, most notably memory. Additionally, hash maps require an operator== and a hash function, of which especially the latter isn't necessarily available. Keep in mind that the Identifier template parameter is not constrained to enums.

Since ResourceHolder::get() is only called a few times at initialization, the access time is irrelevant in relation to other parts of the application. On the other hand, we don't waste memory for an advantage that we can't exploit.
Zloxx II: action platformer
Thor Library: particle systems, animations, dot products, ...
SFML Game Development:

trilavia

  • Newbie
  • *
  • Posts: 28
    • View Profile
Re: SFML Game Development -- A book on SFML
« Reply #106 on: August 06, 2013, 11:04:33 am »
Could you explain me why SceneNode and Entity were split in two classes?

Is it like SceneNode is for drawing & collisions while Entity is for the rest of logic? Why it's not just one class? Collisions seem to be logic part and not drawing part...
« Last Edit: August 06, 2013, 11:06:25 am by trilavia »

Grimshaw

  • Hero Member
  • *****
  • Posts: 631
  • Nephilim SDK
    • View Profile
Re: SFML Game Development -- A book on SFML
« Reply #107 on: August 06, 2013, 11:26:48 am »
SceneNodes are just generic nodes in the tree, to imply we can have any kind of derived node types for any kind of thing in our game world.

From that, we built Entity as a base class for all our entity types. Entity's behavior could be made in the SceneNode class, but we did it this way instead to leave SceneNode as generic as possible.

So, basically, Entity has attributes like health and velocity which are common to all our entity types, while those attributes don't need to exist in other SceneNode types.

Hope it's clear :))

xerwin

  • Newbie
  • *
  • Posts: 3
    • View Profile
Re: SFML Game Development -- A book on SFML
« Reply #108 on: August 24, 2013, 08:54:23 pm »
I just finished chapter 3 and for some reason, when I try to run the game, the background isn't drawn.

I compared my code to github code they are exactly the same, apart from variable names. Did anyone else had this problem?

I don't have much experience with game programming, but I suspect it has something to do with mSceneLayers not being iterated over and drawn, but don't hold me on that.

Nexus

  • SFML Team
  • Hero Member
  • *****
  • Posts: 6287
  • Thor Developer
    • View Profile
    • Bromeon
Re: SFML Game Development -- A book on SFML
« Reply #109 on: August 24, 2013, 09:20:11 pm »
I compared my code to github code they are exactly the same, apart from variable names.
Does it work if you try the GitHub code directly?

Which compiler and operating system do you use?
« Last Edit: August 24, 2013, 09:23:01 pm by Nexus »
Zloxx II: action platformer
Thor Library: particle systems, animations, dot products, ...
SFML Game Development:

xerwin

  • Newbie
  • *
  • Posts: 3
    • View Profile
Re: SFML Game Development -- A book on SFML
« Reply #110 on: August 24, 2013, 11:06:29 pm »
Does it work if you try the GitHub code directly?

Which compiler and operating system do you use?

I found where the problem was, although I have no idea that this could cause this. In the SpriteNode class, there is an drawCurrent() method declared as this:

virtual void drawCurrent(sf::RenderTarget& target, sf::RenderStates states) const;

but I had it like this:

virtual void drawCurrent(sf::RenderTarget& target, sf::RenderStates& states) const;

I passed the second argument as reference. I deleted the & and now it works properly.

Nexus

  • SFML Team
  • Hero Member
  • *****
  • Posts: 6287
  • Thor Developer
    • View Profile
    • Bromeon
Re: SFML Game Development -- A book on SFML
« Reply #111 on: August 24, 2013, 11:18:52 pm »
The signature must match the virtual member function of the base class exactly in order to override it.

Otherwise, you define a new, different function in the derived class. So, the base class version will be called.
Zloxx II: action platformer
Thor Library: particle systems, animations, dot products, ...
SFML Game Development:

Jove

  • Full Member
  • ***
  • Posts: 114
    • View Profile
    • http://www.jestofevekites.com/
Re: SFML Game Development -- A book on SFML
« Reply #112 on: August 28, 2013, 11:12:42 pm »
I've been moving stuff around the screen since I started with SFML 1.6, but the section on Vector Algebra stuck in my mind.

I've been moving objects like that, of course, but...Today it has solved for me (in one line of code), a tricky problem that made me 'nerdgasm' at how easy the solution actually was.

Thus far that alone is worth buying the book for. [read as: waking up a math dunce]
{much better code}

FRex

  • Hero Member
  • *****
  • Posts: 1848
  • Back to C++ gamedev with SFML in May 2023
    • View Profile
    • Email
Re: SFML Game Development -- A book on SFML
« Reply #113 on: August 28, 2013, 11:21:18 pm »
May you paste this line here? I'm curious about it now. ;D
Back to C++ gamedev with SFML in May 2023

Order

  • Newbie
  • *
  • Posts: 8
    • View Profile
Re: SFML Game Development -- A book on SFML
« Reply #114 on: August 30, 2013, 11:52:30 pm »
Well done on getting that book out. I've been messing about with SFML for a few years now and just started reading the eBook. Great stuff and thanks for all your support for the community!

jabza

  • Newbie
  • *
  • Posts: 22
    • View Profile
Re: SFML Game Development -- A book on SFML
« Reply #115 on: September 01, 2013, 07:21:26 pm »
Just bought the book and I'm about half way through. It flows extremely well and has been a great read so far. It's filled many gaps in my game dev knowledge and refined what I thought I already knew. Exactly the kind of book I've been looking for.

Thank you to all the authors!  :)

AdventWolf

  • Jr. Member
  • **
  • Posts: 54
    • View Profile
Re: SFML Game Development -- A book on SFML
« Reply #116 on: September 03, 2013, 04:35:34 am »
Just bought the book, I am excited to see what I can learn from it. Always amazed by the support SFML has.

TeaBag

  • Newbie
  • *
  • Posts: 5
    • View Profile
Re: SFML Game Development -- A book on SFML
« Reply #117 on: September 05, 2013, 07:01:03 pm »
Is there another way to get source files, because http://www.packtpub.com/support/12705 doesn't seem to work - the email is not in my mailbox.


Grimshaw

  • Hero Member
  • *****
  • Posts: 631
  • Nephilim SDK
    • View Profile
Re: SFML Game Development -- A book on SFML
« Reply #118 on: September 05, 2013, 07:31:12 pm »

TeaBag

  • Newbie
  • *
  • Posts: 5
    • View Profile
Re: SFML Game Development -- A book on SFML
« Reply #119 on: September 05, 2013, 08:22:14 pm »
https://github.com/SFML/SFML-Game-Development-Book

Those should be fine :D
Heh, just found that one a few minutes after posting here... :D Thanks anyway.

 

anything