[Added] Crates, Hud for bullets and health

This commit is contained in:
Ninjaws
2024-12-15 00:12:16 +01:00
parent 55792bb954
commit de958b02e6
17 changed files with 448 additions and 38 deletions
+19 -7
View File
@@ -1,23 +1,35 @@
#ifndef PBULLET_H
#define PBULLET_H
#include "services/CollectableService.h"
#include "services/AssetService.h"
#include "entities/Bullet.h"
#include <iostream>
class PBullet : public Bullet {
class PBullet : public Bullet
{
public:
PBullet() {}
PBullet(Vector2 pos, float angle) : Bullet(pos, angle) {
PBullet(Vector2 pos, float angle) : Bullet(pos, angle)
{
this->color = YELLOW;
}
private:
void objCollision() override {
void objCollision() override
{
/** Check for collisions with creates */
for (auto &crate : CollectableService::getInstance().getCrates())
{
if(this->position.x + this->size > crate.getObject().getPosition().x && this->position.x - this->size < crate.getObject().getPosition().x &&
this->position.y + this->size > crate.getObject().getPosition().y && this->position.y - this->size < crate.getObject().getPosition().y ) {
crate.setHit(true);
AssetService::getInstance().playSound(ESound::CRATE_BREAK);
// AssetService::getInstance().playSound(ESound::JELLY_FREED);
this->hasCollided = true;
}
}
}
};
#endif