mirror of
https://github.com/Nimac0/SDL_Minigame
synced 2026-01-12 23:33:41 +00:00
Compare commits
No commits in common. "29743d11b0b8ab366bf4e11670393f6ab008a8b6" and "a49753e39af117b7c21d17088e89f8a9936fb36f" have entirely different histories.
29743d11b0
...
a49753e39a
@ -27,14 +27,8 @@ public:
|
|||||||
void createProjectile(Vector2D pos, Vector2D velocity, int scale, int range, int speed, const char* texturePath, Entity* owner);
|
void createProjectile(Vector2D pos, Vector2D velocity, int scale, int range, int speed, const char* texturePath, Entity* owner);
|
||||||
void createPowerup(Vector2D pos, std::function<void (Entity*)> pickupFunc, std::string texturePath);
|
void createPowerup(Vector2D pos, std::function<void (Entity*)> pickupFunc, std::string texturePath);
|
||||||
|
|
||||||
/*!
|
Vector2D calculateSpawnPosition(int width, int height);
|
||||||
* \brief Calculates a random spawn position for an object within a given area
|
template <typename T> T calculateType(int amount);
|
||||||
* \param size The size (collision box) of the object
|
|
||||||
* \param spawnArea The area within which a spawn position will be calculated
|
|
||||||
* \returns Spawn Coordinates for the object
|
|
||||||
*/
|
|
||||||
Vector2D calculateSpawnPosition(Vector2D size, Vector2D spawnArea);
|
|
||||||
template <typename T> [[deprecated]] T calculateRandomType(int amount);
|
|
||||||
|
|
||||||
//texture management
|
//texture management
|
||||||
void addTexture(std::string id, const char* path);
|
void addTexture(std::string id, const char* path);
|
||||||
|
|||||||
@ -74,19 +74,17 @@ void AssetManager::createPowerup(Vector2D pos, std::function<void (Entity*)> pic
|
|||||||
powerups.addGroup((size_t)Entity::GroupLabel::POWERUPS);
|
powerups.addGroup((size_t)Entity::GroupLabel::POWERUPS);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Vector2D AssetManager::calculateSpawnPosition(int width, int height)
|
||||||
Vector2D AssetManager::calculateSpawnPosition(Vector2D size, Vector2D spawnArea)
|
|
||||||
{
|
{
|
||||||
Vector2D spawnPos = Vector2D(-1, -1);
|
Vector2D spawnPos = Vector2D(-1, -1);
|
||||||
|
|
||||||
for(int i = 0; i <= SPAWN_ATTEMPTS; i++)
|
for(int i = 0; i <= SPAWN_ATTEMPTS; i++)
|
||||||
{
|
{
|
||||||
|
|
||||||
SDL_Rect spawnRect = {
|
SDL_Rect spawnRect = {
|
||||||
rand() % (int)(spawnArea.x - size.x),
|
rand() % (SCREEN_SIZE_WIDTH - width),
|
||||||
rand() % (int)(spawnArea.y - size.y),
|
rand() % (SCREEN_SIZE_HEIGHT - height),
|
||||||
size.x,
|
width,
|
||||||
size.y
|
height
|
||||||
};
|
};
|
||||||
|
|
||||||
std::vector<ColliderComponent*> colliders = this->man->getGame()->collisionHandler->getColliders({Entity::GroupLabel::MAPTILES});
|
std::vector<ColliderComponent*> colliders = this->man->getGame()->collisionHandler->getColliders({Entity::GroupLabel::MAPTILES});
|
||||||
@ -105,7 +103,7 @@ Vector2D AssetManager::calculateSpawnPosition(Vector2D size, Vector2D spawnArea)
|
|||||||
}
|
}
|
||||||
|
|
||||||
template <typename T>
|
template <typename T>
|
||||||
T AssetManager::calculateRandomType(int amount)
|
T AssetManager::calculateType(int amount)
|
||||||
{
|
{
|
||||||
T type = T(rand() % amount);
|
T type = T(rand() % amount);
|
||||||
return type;
|
return type;
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user