News for hackers. Stuff that matters.
Re:How to make Flappy Bird with C++ by kiriin on Thursday August 25, 2022 @10:17AM (#32594015)
>std::shared_ptr<sf::RenderWindow> window; >std::shared_ptr<sf::Sprite> background, bird, pipeBottom, pipeTop;

None of that should be shared_ptr, in fact they shouldn't be pointers at all.

>auto flappy = std::make_shared<FlappyBird>(); >flappy->run();

That would work just fine as a global in main.cpp

FlappyBird flappy;

Re:How to make Flappy Bird with C++ by ncmncm on Thursday August 25, 2022 @02:00PM (#32597514)
Or, better, as an anonymous expression in main():

  FlappyBird().run();
Re:How to make Flappy Bird with C++ by a_t48 on Thursday August 25, 2022 @10:22AM (#32594083)
Disagree - it's very reasonable for resources to be shared.
Re:How to make Flappy Bird with C++ by Shorel on Thursday August 25, 2022 @03:08PM (#32598495)
This is C++.

You should not pay the performance hit for features you don't need in a particular program.

In fact: It is reasonable for C++ programs to NOT use all language features.

Re:How to make Flappy Bird with C++ by a_t48 on Thursday August 25, 2022 @06:34PM (#32600814)
I'm not disagreeing with you.
Re:How to make Flappy Bird with C++ by ncmncm on Thursday August 25, 2022 @02:04PM (#32597574)
In most cases, not. Where there is a legitimate reason to share, share. Without, it is just sloppiness.
Re:How to make Flappy Bird with C++ by a_t48 on Thursday August 25, 2022 @02:21PM (#32597829)
In the context of a game engine, I mean. You may be sharing a model or texture between multiple entities, and want to know when it’s no longer in use.
Re:How to make Flappy Bird with C++ by ncmncm on Thursday August 25, 2022 @03:04PM (#32598445)
Even there, something higher up the stack probably knows too, and is in a better position to choose a good time to dispose of it.
Re:How to make Flappy Bird with C++ by a_t48 on Thursday August 25, 2022 @06:33PM (#32600810)
Possibly! It really depends on how you've architected things. I said it's "reasonable" not that it's the one true way of implementing it.
Re:How to make Flappy Bird with C++ by ncmncm on Thursday August 25, 2022 @07:29PM (#32601375)
I think we really are all in agreement here.