3 edited tags
| link
2 Resolved unnecessary negation in title. Code-formatted bits that are code.
source | link

How to notdo I correctly use a singletonsingletons in C++ game engine programming?

I know singletons are bad, my old game engine used a singleton 'Game' object that handles everything from holding all data to the actual game loop. Now I'm making a new one.

The problem is, to draw something in SFML you use window.draw(sprite)window.draw(sprite) where window is an sf::RenderWindowsf::RenderWindow. There are 2 options I see here:

  1. Make a singleton Game object which every entity in the game retrieves (what I used before)
  2. Make this the constructor for entities: Entity(x, y, window, view, ...etc)Entity(x, y, window, view, ...etc) (this is just ridiculous and annoying)

What would be the proper way to do this while keeping an Entity's constructor to just x and y?

EDIT: I could try and keep track of everything I make in the main game loop, and just manually draw their sprite in the game loop, but that too seems messy, and I also want absolute full control over an entire draw function for the entity.

How to not use a singleton in C++ game engine programming?

I know singletons are bad, my old game engine used a singleton 'Game' object that handles everything from holding all data to the actual game loop. Now I'm making a new one.

The problem is, to draw something in SFML you use window.draw(sprite) where window is an sf::RenderWindow. There are 2 options I see here:

  1. Make a singleton Game object which every entity in the game retrieves (what I used before)
  2. Make this the constructor for entities: Entity(x, y, window, view, ...etc) (this is just ridiculous and annoying)

What would be the proper way to do this while keeping an Entity's constructor to just x and y?

EDIT: I could try and keep track of everything I make in the main game loop, and just manually draw their sprite in the game loop, but that too seems messy, and I also want absolute full control over an entire draw function for the entity.

How do I correctly use singletons in C++ engine programming?

I know singletons are bad, my old game engine used a singleton 'Game' object that handles everything from holding all data to the actual game loop. Now I'm making a new one.

The problem is, to draw something in SFML you use window.draw(sprite) where window is an sf::RenderWindow. There are 2 options I see here:

  1. Make a singleton Game object which every entity in the game retrieves (what I used before)
  2. Make this the constructor for entities: Entity(x, y, window, view, ...etc) (this is just ridiculous and annoying)

What would be the proper way to do this while keeping an Entity's constructor to just x and y?

I could try and keep track of everything I make in the main game loop, and just manually draw their sprite in the game loop, but that too seems messy, and I also want absolute full control over an entire draw function for the entity.

    Tweeted twitter.com/StackGameDev/status/672692955958915072
1
source | link

How to not use a singleton in C++ game engine programming?

I know singletons are bad, my old game engine used a singleton 'Game' object that handles everything from holding all data to the actual game loop. Now I'm making a new one.

The problem is, to draw something in SFML you use window.draw(sprite) where window is an sf::RenderWindow. There are 2 options I see here:

  1. Make a singleton Game object which every entity in the game retrieves (what I used before)
  2. Make this the constructor for entities: Entity(x, y, window, view, ...etc) (this is just ridiculous and annoying)

What would be the proper way to do this while keeping an Entity's constructor to just x and y?

EDIT: I could try and keep track of everything I make in the main game loop, and just manually draw their sprite in the game loop, but that too seems messy, and I also want absolute full control over an entire draw function for the entity.