| 123456789101112131415161718192021222324252627282930313233343536373839404142 |
- //
- // world.cxx
- // danmaku
- //
- // Created by Sam Jaffe on 5/27/19.
- // Copyright © 2019 Sam Jaffe. All rights reserved.
- //
- #include "danmaku/world.hpp"
- #include <json/json.h>
- #include "danmaku/level.hpp"
- #include "danmaku/player.hpp"
- #include "danmaku/serial.hpp"
- #include "game/util/env.hpp"
- using namespace danmaku;
- Json::Value player_json(std::string const & player_file) {
- return engine::read_file(env::resource_file("scripts/player/" + player_file));
- }
- std::shared_ptr<level>
- level_from_path(Json::Value const & json, std::string const & path,
- std::shared_ptr<engine::game_dispatch> game) {
- Json::Value level_json =
- engine::read_file(path + "/" + json["path"].asString() + "/level.json");
- return std::make_shared<level>(json["name"].asString(), level_json, game);
- }
- world::world(std::string const & player_file, std::string const & path,
- Json::Value const & json,
- std::shared_ptr<engine::game_dispatch> game)
- : engine::scene("world", game),
- player_(to_player(player_json(player_file), graphics_manager())),
- levels_(to_vector(json["levels"], level_from_path, path, game)) {}
- world::~world() {}
- // to_vector(Json::Value const &, ...)
- #include "danmaku/serial.tpp"
|