diff --git a/src/main.cpp b/src/main.cpp index 4a0a4fc..46d3c3e 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -1,30 +1,30 @@ -import app; +import rutile.app; #define SDL_MAIN_USE_CALLBACKS #include SDL_AppResult SDL_AppInit(void** appstate, const int /*argc*/, char** /*argv*/) { - auto* app = new App; + auto* app = new rutile::App; *appstate = app; return static_cast(app->initialize()); } SDL_AppResult SDL_AppEvent(void* appstate, SDL_Event* event) { - auto* app = static_cast(appstate); + auto* app = static_cast(appstate); return static_cast(app->handle_event(event)); } SDL_AppResult SDL_AppIterate(void* appstate) { - auto* app = static_cast(appstate); + auto* app = static_cast(appstate); return static_cast(app->iterate()); } void SDL_AppQuit(void* appstate, const SDL_AppResult /*result*/) { - const auto* app = static_cast(appstate); + const auto* app = static_cast(appstate); app->shutdown(); delete app; } diff --git a/src/app.cppm b/src/rutile/app.cppm similarity index 89% rename from src/app.cppm rename to src/rutile/app.cppm index 7b59948..df7ab6a 100644 --- a/src/app.cppm +++ b/src/rutile/app.cppm @@ -4,19 +4,19 @@ module; #include #include -export module app; +export module rutile.app; -import config; -import core.engine; -import game.game; +import rutile.config; +import rutile.core.engine; +import rutile.game.game; import wrappers.sdl; -export +export namespace rutile { class App { - std::unique_ptr engine_{nullptr}; - std::unique_ptr game_{nullptr}; + std::unique_ptr engine_{nullptr}; + std::unique_ptr game_{nullptr}; public: App() = default; @@ -37,8 +37,8 @@ export sdl::Init(sdl::InitFlags::Video | sdl::InitFlags::Events); // Create engine (includes window and renderer) and game state - engine_ = core::Engine::create(); - game_ = game::Game::create(*engine_); + engine_ = Engine::create(); + game_ = Game::create(*engine_); } catch (const std::runtime_error& e) { std::cerr << "Unhandled exception during initialization: " << e.what() << '\n'; diff --git a/src/config.cppm b/src/rutile/config.cppm similarity index 93% rename from src/config.cppm rename to src/rutile/config.cppm index 0ed9a38..b5dd5ce 100644 --- a/src/config.cppm +++ b/src/rutile/config.cppm @@ -8,9 +8,9 @@ module; #define DEBUG_BOOL true #endif -export module config; +export module rutile.config; -export namespace config +export namespace rutile::config { constexpr auto debug = DEBUG_BOOL; diff --git a/src/core/drawing/sprite.cppm b/src/rutile/core/drawing/sprite.cppm similarity index 96% rename from src/core/drawing/sprite.cppm rename to src/rutile/core/drawing/sprite.cppm index 31224cd..6835962 100644 --- a/src/core/drawing/sprite.cppm +++ b/src/rutile/core/drawing/sprite.cppm @@ -4,12 +4,12 @@ module; #include #include -export module core.drawing.sprite; +export module rutile.core.drawing.sprite; -import core.render_server; +import rutile.core.render_server; import wrappers.sdl; -export namespace core +export namespace rutile { class Sprite { diff --git a/src/core/drawing/tile_map.cppm b/src/rutile/core/drawing/tile_map.cppm similarity index 96% rename from src/core/drawing/tile_map.cppm rename to src/rutile/core/drawing/tile_map.cppm index 31bfbfa..2fa9111 100644 --- a/src/core/drawing/tile_map.cppm +++ b/src/rutile/core/drawing/tile_map.cppm @@ -4,13 +4,13 @@ module; #include #include -export module core.drawing.tile_map; +export module rutile.core.drawing.tile_map; -import core.drawing.tile_set; -import core.render_server; +import rutile.core.drawing.tile_set; +import rutile.core.render_server; import wrappers.sdl; -export namespace core +export namespace rutile { // Restrict map size to 16 bit per dimension, so that width*height still fits within size_t using MapCoord = uint16_t; diff --git a/src/core/drawing/tile_set.cppm b/src/rutile/core/drawing/tile_set.cppm similarity index 96% rename from src/core/drawing/tile_set.cppm rename to src/rutile/core/drawing/tile_set.cppm index 39ba81d..6fcbec5 100644 --- a/src/core/drawing/tile_set.cppm +++ b/src/rutile/core/drawing/tile_set.cppm @@ -5,12 +5,12 @@ module; #include #include -export module core.drawing.tile_set; +export module rutile.core.drawing.tile_set; -import core.render_server; +import rutile.core.render_server; import wrappers.sdl; -export namespace core +export namespace rutile { using TileSetID = unsigned int; using TileID = unsigned int; diff --git a/src/core/engine.cppm b/src/rutile/core/engine.cppm similarity index 95% rename from src/core/engine.cppm rename to src/rutile/core/engine.cppm index d9bd5ad..de1f8ad 100644 --- a/src/core/engine.cppm +++ b/src/rutile/core/engine.cppm @@ -3,13 +3,13 @@ module; #include #include -export module core.engine; +export module rutile.core.engine; -import config; -import core.render_server; +import rutile.config; +import rutile.core.render_server; import wrappers.sdl; -export namespace core +export namespace rutile { class Engine { diff --git a/src/core/render_server.cppm b/src/rutile/core/render_server.cppm similarity index 94% rename from src/core/render_server.cppm rename to src/rutile/core/render_server.cppm index bcb4c9f..2420d3a 100644 --- a/src/core/render_server.cppm +++ b/src/rutile/core/render_server.cppm @@ -3,13 +3,13 @@ module; #include #include -export module core.render_server; +export module rutile.core.render_server; -import core.resource_manager; -import core.texture_loader; +import rutile.core.resource_manager; +import rutile.core.texture_loader; import wrappers.sdl; -export namespace core +export namespace rutile { using TextureID = unsigned int; using TextureManager = ResourceManager; diff --git a/src/core/resource_manager.cppm b/src/rutile/core/resource_manager.cppm similarity index 98% rename from src/core/resource_manager.cppm rename to src/rutile/core/resource_manager.cppm index 2e947f5..dddac0d 100644 --- a/src/core/resource_manager.cppm +++ b/src/rutile/core/resource_manager.cppm @@ -6,9 +6,9 @@ module; #include #include -export module core.resource_manager; +export module rutile.core.resource_manager; -export namespace core +export namespace rutile { template concept IsResourceLoader = requires(ResourceLoaderType loader, const std::string& name) diff --git a/src/core/texture_loader.cppm b/src/rutile/core/texture_loader.cppm similarity index 88% rename from src/core/texture_loader.cppm rename to src/rutile/core/texture_loader.cppm index 32548c4..04c5a83 100644 --- a/src/core/texture_loader.cppm +++ b/src/rutile/core/texture_loader.cppm @@ -2,13 +2,13 @@ module; #include -export module core.texture_loader; +export module rutile.core.texture_loader; -import core.resource_manager; +import rutile.core.resource_manager; import wrappers.sdl; import wrappers.sdl_image; -export namespace core +export namespace rutile { class TextureLoader { diff --git a/src/game/game.cppm b/src/rutile/game/game.cppm similarity index 84% rename from src/game/game.cppm rename to src/rutile/game/game.cppm index a18cc6f..e788c34 100644 --- a/src/game/game.cppm +++ b/src/rutile/game/game.cppm @@ -5,17 +5,17 @@ module; #include #include -export module game.game; +export module rutile.game.game; -import core.drawing.sprite; -import core.drawing.tile_map; -import core.drawing.tile_set; -import core.engine; -import core.render_server; +import rutile.core.drawing.sprite; +import rutile.core.drawing.tile_map; +import rutile.core.drawing.tile_set; +import rutile.core.engine; +import rutile.core.render_server; import wrappers.sdl; import wrappers.sdl_image; -export namespace game +export namespace rutile { class Game { @@ -23,21 +23,21 @@ export namespace game static bool instantiated_; // Reference to the engine - core::Engine& engine_; + Engine& engine_; // Sprites for testing - core::Sprite player_sprite_; - std::vector sprites_; + Sprite player_sprite_; + std::vector sprites_; // Tile set and tile map (TODO: tile set should be moved to resource manager in engine) - core::TileSet tile_set_; - core::TileMap tile_map_; + TileSet tile_set_; + TileMap tile_map_; // Private constructor - explicit Game(core::Engine& engine) + explicit Game(Engine& engine) : engine_(engine), player_sprite_{ - core::Sprite::create_from_texture( + Sprite::create_from_texture( engine_.get_render_server(), "assets/sprites/neocat_64.png", std::nullopt, @@ -46,7 +46,7 @@ export namespace game ) }, tile_set_{ - core::TileSet::create_from_texture( + TileSet::create_from_texture( engine_.get_render_server(), "assets/tilesets/terrain.png", 32, @@ -86,7 +86,7 @@ export namespace game instantiated_ = false; } - static std::unique_ptr create(core::Engine& engine) + static std::unique_ptr create(Engine& engine) { // Prevent the class from being instantiated multiple times assert(!instantiated_); @@ -105,7 +105,7 @@ export namespace game if (event->type == sdl::EventType::MouseButtonUp) { sprites_.push_back( - core::Sprite::create_from_texture( + Sprite::create_from_texture( engine_.get_render_server(), "assets/sprites/neofox_64.png", std::nullopt, @@ -132,7 +132,7 @@ export namespace game tile_map_.draw(render_server, tile_set_); // Render sprites - for (const core::Sprite& sprite : sprites_) { + for (const Sprite& sprite : sprites_) { sprite.draw(render_server); } player_sprite_.draw(render_server); diff --git a/src/wrappers/sdl/rect.cppm b/src/wrappers/sdl/rect.cppm index a42648a..dbe8c10 100644 --- a/src/wrappers/sdl/rect.cppm +++ b/src/wrappers/sdl/rect.cppm @@ -19,7 +19,7 @@ export namespace sdl * Wrapper around SDL_RectEmptyFloat(). * @return True if the floating point rectangle takes no space. */ - constexpr bool is_empty() const + bool is_empty() const { return SDL_RectEmptyFloat(this); } @@ -34,7 +34,7 @@ export namespace sdl * Wrapper around SDL_RectEmpty(). * @return True if the rectangle takes no space. */ - constexpr bool is_empty() const + bool is_empty() const { return SDL_RectEmpty(this); }