diff --git a/include/GameInternal.h b/include/GameInternal.h index 3850b43..2f99092 100644 --- a/include/GameInternal.h +++ b/include/GameInternal.h @@ -12,10 +12,10 @@ #include "Entity.h" #include "RenderManager.h" #include "ConfigLoader.h" +#include "PickupManager.h" typedef std::function gamefunction; -class AssetManager; class CollisionHandler; class TextureManager; class SoundManager; @@ -41,7 +41,7 @@ public: /* static */ SDL_Renderer* renderer = nullptr; /* static */ SDL_Event event; /* static */ CollisionHandler* collisionHandler; - /* static */ AssetManager* assets; + /* static */ PickupManager* pickupManager; /* static */ TextureManager* textureManager; /* static */ SoundManager* soundManager; diff --git a/include/PowerupComponent.h b/include/PickupComponent.h similarity index 71% rename from include/PowerupComponent.h rename to include/PickupComponent.h index 7229283..bab061d 100644 --- a/include/PowerupComponent.h +++ b/include/PickupComponent.h @@ -3,15 +3,15 @@ #include #include "Component.h" -class PowerupComponent : public Component +class PickupComponent : public Component { public: /** * @brief Construct a new Powerup Component object * @param func The function to be called when the powerup is picked up */ - PowerupComponent(std::function func); - ~PowerupComponent() {}; + PickupComponent(std::function func); + ~PickupComponent() {}; void update(uint_fast16_t diffTime) override; diff --git a/include/AssetManager.h b/include/PickupManager.h similarity index 67% rename from include/AssetManager.h rename to include/PickupManager.h index 402e6b9..c73af76 100644 --- a/include/AssetManager.h +++ b/include/PickupManager.h @@ -11,25 +11,16 @@ class Vector2D; class Manager; -enum class PowerupType -{ - HEART, - WALKINGSPEED, - SHOOTINGSPEED -}; - -class AssetManager +class PickupManager { public: - AssetManager(Manager* manager); - ~AssetManager(); + PickupManager(Manager* manager); + ~PickupManager(); void createPowerup(Vector2D pos, std::function pickupFunc, Textures texture); Vector2D calculateSpawnPosition(); - PowerupType calculateType(); - private: diff --git a/src/GameInternal.cpp b/src/GameInternal.cpp index 77becb6..992abeb 100644 --- a/src/GameInternal.cpp +++ b/src/GameInternal.cpp @@ -1,7 +1,6 @@ #include "GameInternal.h" #include "CollisionHandler.h" -#include "AssetManager.h" #include "RenderManager.h" #include #include "SDL3/SDL_init.h" @@ -39,10 +38,10 @@ SDL_AppResult GameInternal::init() json finalConfig = config->getFinalConfig(); - GameInternal::assets = new AssetManager(&manager); + GameInternal::pickupManager = new PickupManager(&manager); GameInternal::textureManager = new TextureManager(&manager); GameInternal::soundManager = new SoundManager(); - GameInternal::collisionHandler = new CollisionHandler(manager); // why does this use a referrence, but AssetManager a pointer? + GameInternal::collisionHandler = new CollisionHandler(manager); //why no pointer? int flags = 0; if (finalConfig.at("fullscreen")) diff --git a/src/PowerupComponent.cpp b/src/PickupComponent.cpp similarity index 76% rename from src/PowerupComponent.cpp rename to src/PickupComponent.cpp index 4db3f95..0c6a452 100644 --- a/src/PowerupComponent.cpp +++ b/src/PickupComponent.cpp @@ -1,4 +1,4 @@ -#include "PowerupComponent.h" +#include "PickupComponent.h" #include "GameInternal.h" #include "CollisionHandler.h" #include "Entity.h" @@ -7,12 +7,12 @@ #include "Constants.h" #include -PowerupComponent::PowerupComponent(std::function func) +PickupComponent::PickupComponent(std::function func) { this->pickupFunc = func; } -void PowerupComponent::update(uint_fast16_t diffTime) +void PickupComponent::update(uint_fast16_t diffTime) { Entity* player; if ((player = this->entity->getManager().getGame()->collisionHandler->getAnyIntersection( diff --git a/src/AssetManager.cpp b/src/PickupManager.cpp similarity index 76% rename from src/AssetManager.cpp rename to src/PickupManager.cpp index c4ae91d..21fe1ff 100644 --- a/src/AssetManager.cpp +++ b/src/PickupManager.cpp @@ -1,4 +1,4 @@ -#include "AssetManager.h" +#include "PickupManager.h" #include "TextureManager.h" #include "SoundManager.h" @@ -12,17 +12,17 @@ #include "Constants.h" #include "Entity.h" #include "Vector2D.h" -#include "PowerupComponent.h" +#include "PickupComponent.h" #include #include #include "Textures.h" -AssetManager::AssetManager(Manager* manager) : man(manager) {} +PickupManager::PickupManager(Manager* manager) : man(manager) {} -AssetManager::~AssetManager() {} +PickupManager::~PickupManager() {} -void AssetManager::createPowerup(Vector2D pos, std::function pickupFunc, Textures texture) { +void PickupManager::createPowerup(Vector2D pos, std::function pickupFunc, Textures texture) { auto& powerups(man->addEntity()); powerups.addComponent(pos.x, pos.y, 32, 32, 1); //32x32 is standard size for objects @@ -35,11 +35,11 @@ void AssetManager::createPowerup(Vector2D pos, std::function pic } powerups.addComponent("powerup", 0.6f); - powerups.addComponent(pickupFunc); + powerups.addComponent(pickupFunc); powerups.addGroup((size_t)Entity::GroupLabel::POWERUPS); } -Vector2D AssetManager::calculateSpawnPosition() +Vector2D PickupManager::calculateSpawnPosition() { Vector2D spawnPos = Vector2D(-1, -1); bool conflict = false; @@ -62,10 +62,4 @@ Vector2D AssetManager::calculateSpawnPosition() spawnPos = Vector2D(spawnRect.x, spawnRect.y); } return spawnPos; -} - -PowerupType AssetManager::calculateType() -{ - PowerupType type = PowerupType(rand() % 3); - return type; } \ No newline at end of file diff --git a/src/SoundManager.cpp b/src/SoundManager.cpp index 80c5567..df683c2 100644 --- a/src/SoundManager.cpp +++ b/src/SoundManager.cpp @@ -6,7 +6,6 @@ #include #include "GameInternal.h" -#include "AssetManager.h" /* Mix_Music* SoundManager::loadMusic(const char* fileName)