diff --git a/CMakeLists.txt b/CMakeLists.txt index 7e1e177..e883a38 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -98,7 +98,7 @@ add_executable(${PROJECT_NAME} src/horzcollisionbar.cpp src/platform.cpp src/vectormath.cpp - src/platformsystem.cpp + src/platformspawner.cpp src/movers/moverworld.cpp src/line.cpp src/collider.cpp diff --git a/src/gameplaysceneclassic.cpp b/src/gameplaysceneclassic.cpp index 54fd89a..5281773 100644 --- a/src/gameplaysceneclassic.cpp +++ b/src/gameplaysceneclassic.cpp @@ -27,7 +27,7 @@ #include "moverworld.hpp" #include "tiledwallpaper.hpp" #include "texture.hpp" -#include "platformsystem.hpp" +#include "platformspawner.hpp" #include "CloonelJumpConfig.h" #include #include @@ -81,7 +81,7 @@ namespace cloonel { std::unique_ptr moverLeftRight(new MoverLeftRight(1.5f, 5.0f, 40.0f)); std::unique_ptr moverWorld(new MoverWorld(halfRefHeight)); std::unique_ptr wallpaper(new TiledWallpaper("resources/graphics/background_tile.png", SDLObject())); - std::unique_ptr platforms(new PlatformSystem("resources/graphics/platform.png", SDLObject(), this, halfRefHeight * 0.9f)); + std::unique_ptr platforms(new PlatformSpawner("resources/graphics/platform.png", SDLObject(), this, halfRefHeight * 0.9f)); player->Prepare(); platforms->Prepare(); @@ -128,7 +128,7 @@ namespace cloonel { GameplayScene::Destroy(); //Destroy in reverse creation order - m_platforms = std::move(std::unique_ptr(nullptr)); + m_platforms = std::move(std::unique_ptr(nullptr)); m_wallpaper = std::move(std::unique_ptr(nullptr)); m_moverWorld = std::move(std::unique_ptr(nullptr)); m_moverLeftRight = std::move(std::unique_ptr(nullptr)); diff --git a/src/gameplaysceneclassic.hpp b/src/gameplaysceneclassic.hpp index 686779c..796e2ba 100644 --- a/src/gameplaysceneclassic.hpp +++ b/src/gameplaysceneclassic.hpp @@ -31,7 +31,7 @@ namespace cloonel { class MoverWorld; class TiledWallpaper; class Texture; - class PlatformSystem; + class PlatformSpawner; class GameplaySceneClassic : public GameplayScene { public: @@ -49,7 +49,7 @@ namespace cloonel { std::unique_ptr m_moverLeftRight; std::unique_ptr m_moverWorld; std::unique_ptr m_wallpaper; - std::unique_ptr m_platforms; + std::unique_ptr m_platforms; }; } //namespace cloonel diff --git a/src/platformsystem.cpp b/src/platformspawner.cpp similarity index 87% rename from src/platformsystem.cpp rename to src/platformspawner.cpp index 576ce42..f4da94e 100644 --- a/src/platformsystem.cpp +++ b/src/platformspawner.cpp @@ -17,7 +17,7 @@ along with CloonelJump. If not, see . */ -#include "platformsystem.hpp" +#include "platformspawner.hpp" #include "platform.hpp" #include "CloonelJumpConfig.h" #include "texture.hpp" @@ -61,7 +61,7 @@ namespace cloonel { } } //unnamed namespace - struct PlatformSystem::LocalData : public boost::noncopyable { + struct PlatformSpawner::LocalData : public boost::noncopyable { LocalData ( const char* parTexturePath, SDLMain* parSDLMain, GameplayScene* parScene, float parMaxDistance ); ~LocalData ( void ) noexcept = default; @@ -74,7 +74,7 @@ namespace cloonel { ///-------------------------------------------------------------------------- ///-------------------------------------------------------------------------- - PlatformSystem::LocalData::LocalData (const char* parTexturePath, SDLMain* parSDLMain, GameplayScene* parScene, float parMaxDistance) : + PlatformSpawner::LocalData::LocalData (const char* parTexturePath, SDLMain* parSDLMain, GameplayScene* parScene, float parMaxDistance) : platforms(parSDLMain), texture(parTexturePath, parSDLMain, false), scene(parScene), @@ -84,7 +84,7 @@ namespace cloonel { ///-------------------------------------------------------------------------- ///-------------------------------------------------------------------------- - PlatformSystem::PlatformSystem (const char* parTexturePath, SDLMain* parSDLMain, GameplayScene* parScene, float parMaxDistance) : + PlatformSpawner::PlatformSpawner (const char* parTexturePath, SDLMain* parSDLMain, GameplayScene* parScene, float parMaxDistance) : Placeable(float2(0.0f)), m_localdata(new LocalData(parTexturePath, parSDLMain, parScene, parMaxDistance)), m_targetAverage(parMaxDistance / 5.25f) //TODO: change this value to make up for the difficulty @@ -93,13 +93,13 @@ namespace cloonel { ///-------------------------------------------------------------------------- ///-------------------------------------------------------------------------- - PlatformSystem::~PlatformSystem() noexcept { + PlatformSpawner::~PlatformSpawner() noexcept { Destroy(); } ///-------------------------------------------------------------------------- ///-------------------------------------------------------------------------- - void PlatformSystem::SpawnPlatforms() { + void PlatformSpawner::SpawnPlatforms() { const float2 platfWH(static_cast(g_platfWidth), static_cast(g_platfHeight)); size_t freePlatforms = m_localdata->platforms.CountFreePlatforms(); @@ -122,7 +122,7 @@ namespace cloonel { ///-------------------------------------------------------------------------- ///-------------------------------------------------------------------------- - void PlatformSystem::Prepare() { + void PlatformSpawner::Prepare() { m_localdata->texture.Reload(); //Spawn the initial platforms @@ -132,7 +132,7 @@ namespace cloonel { ///-------------------------------------------------------------------------- ///-------------------------------------------------------------------------- - void PlatformSystem::Destroy() noexcept { + void PlatformSpawner::Destroy() noexcept { m_localdata->texture.Destroy(); for (const auto& unregPair : m_localdata->registeredTo) { unregPair.second->UnregisterBarSet(unregPair.first, &m_localdata->platforms); @@ -144,31 +144,31 @@ namespace cloonel { ///-------------------------------------------------------------------------- ///-------------------------------------------------------------------------- - void PlatformSystem::BeginMovement() { + void PlatformSpawner::BeginMovement() { m_localdata->platforms.SendBeginMovement(); } ///-------------------------------------------------------------------------- ///-------------------------------------------------------------------------- - void PlatformSystem::AddOffset (const float2& parOffset) noexcept { + void PlatformSpawner::AddOffset (const float2& parOffset) noexcept { m_localdata->platforms.SendAddOffset(parOffset); } ///-------------------------------------------------------------------------- ///-------------------------------------------------------------------------- - void PlatformSystem::SetAbsolutePosition (const float2&) noexcept { + void PlatformSpawner::SetAbsolutePosition (const float2&) noexcept { assert(false); } ///-------------------------------------------------------------------------- ///-------------------------------------------------------------------------- - void PlatformSystem::RegisterForCollision (Collider& parCollider, Collider::GroupIDType parGroupID) { + void PlatformSpawner::RegisterForCollision (Collider& parCollider, Collider::GroupIDType parGroupID) { parCollider.RegisterBarSet(parGroupID, &m_localdata->platforms); } ///-------------------------------------------------------------------------- ///-------------------------------------------------------------------------- - const DrawableSet* PlatformSystem::GetDrawableSet() const { + const DrawableSet* PlatformSpawner::GetDrawableSet() const { return &m_localdata->platforms; } } //namespace cloonel diff --git a/src/platformsystem.hpp b/src/platformspawner.hpp similarity index 77% rename from src/platformsystem.hpp rename to src/platformspawner.hpp index 6e5e620..9252094 100644 --- a/src/platformsystem.hpp +++ b/src/platformspawner.hpp @@ -29,14 +29,14 @@ namespace cloonel { class GameplayScene; class DrawableSet; - class PlatformSystem : public Placeable { + class PlatformSpawner : public Placeable { public: - PlatformSystem ( void ) = delete; - PlatformSystem ( const char* parTexturePath, SDLMain* parSDLMain, GameplayScene* parScene, float parMaxDistance ); - PlatformSystem ( const PlatformSystem& ) = delete; - PlatformSystem ( PlatformSystem&& parOther ) = delete; - virtual ~PlatformSystem ( void ) noexcept; - PlatformSystem& operator= ( const PlatformSystem& ) = delete; + PlatformSpawner ( void ) = delete; + PlatformSpawner ( const char* parTexturePath, SDLMain* parSDLMain, GameplayScene* parScene, float parMaxDistance ); + PlatformSpawner ( const PlatformSpawner& ) = delete; + PlatformSpawner ( PlatformSpawner&& parOther ) = delete; + virtual ~PlatformSpawner ( void ) noexcept; + PlatformSpawner& operator= ( const PlatformSpawner& ) = delete; void Prepare ( void ); void Destroy ( void ) noexcept;