[Added] Start of enemies

This commit is contained in:
Ninjaws
2024-12-16 22:27:06 +01:00
parent 5af531a08b
commit e8c78770b5
17 changed files with 580 additions and 101 deletions
+17 -1
View File
@@ -6,13 +6,16 @@
#include "services/MapService.h"
#include "entities/Vector2i.h"
#include "entities/Crate.h"
#include "entities/PBullet.h"
#include "entities/Jelly.h"
#include "entities/AmmoPack.h"
#include "entities/HealthPack.h"
#include "entities/Powerup.h"
#include "entities/Flag.h"
#include <vector>
/**
* Service that manages the collectables (jellies), consumables (Ammo, health, powerups), and the finish flag
*/
class CollectableService : public Service<CollectableService>
{
public:
@@ -23,6 +26,7 @@ public:
initAmmoPacks();
initHealthPacks();
initPowerups();
initFlag();
}
void collectableLogic()
@@ -32,6 +36,7 @@ public:
ammoPackLogic();
healthPackLogic();
powerupLogic();
flag.logic();
}
void drawCollectables()
@@ -41,6 +46,7 @@ public:
drawAmmoPacks();
drawHealthpacks();
drawPowerups();
flag.draw();
}
std::vector<Crate> &getCrates()
@@ -62,6 +68,10 @@ public:
return this->powerUps;
}
Flag& getFlag() {
return this->flag;
}
int getMaxAmountOfJellies()
{
return this->amountOfCrates;
@@ -82,6 +92,7 @@ private:
std::vector<HealthPack> healthPacks;
std::vector<Jelly> jellies;
std::vector<Powerup> powerUps;
Flag flag;
void initCrates()
{
@@ -146,6 +157,11 @@ private:
powerUps[0].getObject().setPosition({41.0f * tileSize+8, 10.0f * tileSize-25});
}
void initFlag() {
int tileSize = MapService::getInstance().getMap().getTileSize();
this->flag = Flag({118.0f*tileSize-tileSize/2.0f, 3.0f * tileSize-8});
}
void crateLogic()
{
for (auto it = crates.begin(); it != crates.end();)