[Added] Crates, Hud for bullets and health
This commit is contained in:
@@ -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
|
||||
Reference in New Issue
Block a user