Use unique_ptr to manage SDL pointers
This commit is contained in:
parent
5c3e0e3a86
commit
4277f4c818
8 changed files with 128 additions and 129 deletions
|
|
@ -8,6 +8,7 @@ export module game.game;
|
|||
import core.engine;
|
||||
import core.renderer;
|
||||
import game.sprite;
|
||||
import resources.texture;
|
||||
|
||||
export namespace game
|
||||
{
|
||||
|
|
@ -25,11 +26,9 @@ export namespace game
|
|||
: engine_(engine)
|
||||
{}
|
||||
|
||||
// No copy operations
|
||||
// No copy or move operations because we have a reference to the engine
|
||||
Game(const Game&) = delete;
|
||||
Game& operator=(const Game&) = delete;
|
||||
|
||||
// No move operations - TODO?
|
||||
Game(Game&&) = delete;
|
||||
Game& operator=(Game&&) = delete;
|
||||
|
||||
|
|
@ -37,7 +36,12 @@ export namespace game
|
|||
|
||||
void initialize()
|
||||
{
|
||||
sprite_ = std::make_unique<Sprite>(engine_.get_renderer(), "assets/neocat.png", 100, 100);
|
||||
auto texture = resources::Texture::load_from_file(
|
||||
engine_.get_renderer().get_sdl_renderer(),
|
||||
"assets/neocat.png"
|
||||
);
|
||||
|
||||
sprite_ = std::make_unique<Sprite>(std::move(texture), 100, 100);
|
||||
}
|
||||
|
||||
// Handles an SDL event. Returns true if the event has been handled.
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue