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

Author Topic: Game structure help  (Read 6115 times)

0 Members and 1 Guest are viewing this topic.

Jesper Juhl

  • Hero Member
  • *****
  • Posts: 1405
    • View Profile
    • Email
Re: Game structure help
« Reply #15 on: May 10, 2014, 08:46:30 pm »
Remember that when you push_back() an object into a vector, the vector gets a *copy* of the object. It does not contain a reference to the original object but a completely distinct copy.

Canvas

  • Full Member
  • ***
  • Posts: 107
    • View Profile
Re: Game structure help
« Reply #16 on: May 10, 2014, 08:48:55 pm »
Ixrec that would seem to the answer :D]

Basically my renderservice will gather the objects that need to be drawn and then draw their sprite. Damn this is a long topic for a really simple and basic answer

dwarfman78

  • Full Member
  • ***
  • Posts: 228
  • I'm bietzsche, Nietzsche !
    • MSN Messenger - cd4c@hotmail.com
    • View Profile
    • Email
Re: Game structure help
« Reply #17 on: May 11, 2014, 07:45:38 am »
Basically my renderservice will gather the objects that need to be drawn and then draw their sprite. Damn this is a long topic for a really simple and basic answer

By looking at your class diagram (which looks quite good to me), i wonder why don't you store your vector of game related objects into the "LevelState" class, then your "RenderService" class will access this vector by reference, iterating over each element, and getting the sprite to be drawn from it ?

This operation that consists of copying the sprites stored in your game related objects seems over complicated to me. I strongly advise that you forget about it.

Linking what i say to your former code from the previous post, i think you should store "DisplayObject" class instances (or ptr/smart ptr to them)  into a vector, and not "Sprite", then iterate over this vector of "DisplayObject" and finally get the sprite from it when you call "RenderWindow::draw".

« Last Edit: May 11, 2014, 07:47:32 am by dwarfman78 »
@dwarfman78
github.com/dwarfman78