From 1cd604e1f0c48e6f3d72ccd23d91fef0ba77ac35 Mon Sep 17 00:00:00 2001 From: ineslelin Date: Tue, 5 Nov 2024 20:52:24 +0100 Subject: [PATCH] rework calculateType() --- include/AssetManager.h | 2 +- src/AssetManager.cpp | 9 +++++---- 2 files changed, 6 insertions(+), 5 deletions(-) diff --git a/include/AssetManager.h b/include/AssetManager.h index 1d3c97a..1a92c76 100644 --- a/include/AssetManager.h +++ b/include/AssetManager.h @@ -28,7 +28,7 @@ public: void createPowerup(Vector2D pos, std::function pickupFunc, std::string texturePath); Vector2D calculateSpawnPosition(); - PowerupType calculateType(); + template T calculateType(int amount); //texture management void addTexture(std::string id, const char* path); diff --git a/src/AssetManager.cpp b/src/AssetManager.cpp index 25ce8ad..809ccd7 100644 --- a/src/AssetManager.cpp +++ b/src/AssetManager.cpp @@ -98,8 +98,9 @@ Vector2D AssetManager::calculateSpawnPosition() return spawnPos; } -PowerupType AssetManager::calculateType() +template +T AssetManager::calculateType(int amount) { - PowerupType type = PowerupType(rand() % 3); - return type; -} \ No newline at end of file + T type = T(rand() % amount); + return type; +}