Skip to content

Commit 7b8dc42

Browse files
committed
Fix searching for game resources
1 parent fd9914f commit 7b8dc42

File tree

14 files changed

+58
-12
lines changed

14 files changed

+58
-12
lines changed

configured_files/config.hpp.in

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
namespace my_awesome_game::cmake {
77
static constexpr std::string_view project_name = "@PROJECT_NAME@";
88
static constexpr std::string_view project_version = "@PROJECT_VERSION@";
9+
static constexpr std::string_view source_dir = "@CMAKE_SOURCE_DIR@";
910
static constexpr int project_version_major { @PROJECT_VERSION_MAJOR@ };
1011
static constexpr int project_version_minor { @PROJECT_VERSION_MINOR@ };
1112
static constexpr int project_version_patch { @PROJECT_VERSION_PATCH@ };
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.

src/game.cpp

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -5,9 +5,9 @@
55

66
namespace lefticus::awesome_game {
77

8-
Game_Map make_map()
8+
Game_Map make_map(const std::vector<std::filesystem::path> &search_directories)
99
{
10-
auto map = load_tiled_map("/home/jason/my_awesome_game/resources/tiled/tiles/Map.tmj");
10+
auto map = load_tiled_map("awesome_game/tiled/tiles/Map.tmj", search_directories);
1111

1212
map.locations.at(Point{ 4, 5 }).can_enter// NOLINT magic numbers
1313
= [](const Game &, Point, Direction) { return true; };
@@ -26,9 +26,9 @@ Game_Map make_map()
2626
return map;
2727
}
2828

29-
Game_Map make_store()
29+
Game_Map make_store(const std::vector<std::filesystem::path> &search_directories)
3030
{
31-
auto map = load_tiled_map("/home/jason/my_awesome_game/resources/tiled/tiles/Store.tmj");
31+
auto map = load_tiled_map("awesome_game/tiled/tiles/Store.tmj", search_directories);
3232

3333
map.locations.at(Point{ 7, 6 }).enter_action// NOLINT magic numbers
3434
= [](Game &game, Point, Direction) {
@@ -52,11 +52,11 @@ Game_Map make_store()
5252
return map;
5353
}
5454

55-
Game make_game()
55+
Game make_game(const std::vector<std::filesystem::path> &search_directories)
5656
{
5757
Game retval{};
58-
retval.maps.emplace("main", make_map());
59-
retval.maps.emplace("store", make_store());
58+
retval.maps.emplace("main", make_map(search_directories));
59+
retval.maps.emplace("store", make_store(search_directories));
6060
retval.current_map = "main";
6161
retval.tile_size = Size{ 8, 8 };// NOLINT Magic Number
6262

src/game.hpp

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,14 @@
11
#ifndef AWESOME_GAME_GAME_HPP
22
#define AWESOME_GAME_GAME_HPP
33

4+
#include <vector>
5+
#include <filesystem>
6+
47
namespace lefticus::awesome_game {
58

69
struct Game;
710

8-
Game make_game();
11+
Game make_game(const std::vector<std::filesystem::path> &search_directories);
912

1013
}// namespace lefticus::awesome_game
1114

0 commit comments

Comments
 (0)