-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
13 changed files
with
93 additions
and
16 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
#include "scenemanager.hpp" | ||
#include "point.hpp" | ||
|
||
using namespace framework; | ||
|
||
using json = nlohmann::json; | ||
|
||
scenemanager::scenemanager(const std::shared_ptr<graphics::pixmappool> pixmappool) | ||
: _pixmappool(pixmappool) {} | ||
|
||
void scenemanager::load(const std::string_view name) { | ||
const auto buffer = storage::io::read(fmt::format("scenes/{}.json", name)); | ||
const auto j = json::parse(buffer); | ||
_background = _pixmappool->get(j["background"].template get<std::string_view>()); | ||
_size = {j.at("width").get<int32_t>(), j.at("height").get<int32_t>()}; | ||
} | ||
|
||
void scenemanager::update(double_t delta) noexcept { | ||
UNUSED(delta); | ||
} | ||
|
||
void scenemanager::draw() noexcept { | ||
if (!_background) { | ||
return; | ||
} | ||
|
||
static geometry::point point{0, 0}; | ||
_background->draw({point, _size}, {point, _size}); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
#pragma once | ||
|
||
#include "common.hpp" | ||
#include "pixmap.hpp" | ||
#include "pixmappool.hpp" | ||
#include "rect.hpp" | ||
|
||
namespace framework { | ||
class scenemanager { | ||
public: | ||
scenemanager(const std::shared_ptr<graphics::pixmappool> pixmappool); | ||
|
||
void load(const std::string_view name); | ||
|
||
void update(double_t delta) noexcept; | ||
|
||
void draw() noexcept; | ||
|
||
private: | ||
std::shared_ptr<graphics::pixmappool> _pixmappool; | ||
std::shared_ptr<graphics::pixmap> _background; | ||
geometry::size _size; | ||
}; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters