diff --git a/include/AssetManager.h b/include/AssetManager.h index 37eb645..d87dc63 100644 --- a/include/AssetManager.h +++ b/include/AssetManager.h @@ -15,7 +15,7 @@ public: AssetManager(Manager* manager); ~AssetManager(); - void createProjectile(Vector2D pos, Vector2D velocity, bool source, int scale, int range, int speed, const char* texturePath, TeamLabel teamLabel); + void createProjectile(Vector2D pos, Vector2D velocity, int scale, int range, int speed, const char* texturePath, TeamLabel teamLabel); //texture management void addTexture(std::string id, const char* path); diff --git a/include/HealthComponent.h b/include/HealthComponent.h index 6daf17b..78b9451 100644 --- a/include/HealthComponent.h +++ b/include/HealthComponent.h @@ -17,13 +17,11 @@ public: void init() override; - void resetHearts(); + void refreshHearts(); void createHeartComponents(int x); private: int health; Direction side; - bool player; //true if player1 / false if player2 - }; \ No newline at end of file diff --git a/include/ProjectileComponent.h b/include/ProjectileComponent.h index 8fa949c..76a5e7b 100644 --- a/include/ProjectileComponent.h +++ b/include/ProjectileComponent.h @@ -10,14 +10,12 @@ class ProjectileComponent : public Component //can maybe be split in separate .cpp file public: - ProjectileComponent(int range, int speed, Vector2D direction, bool source) : range(range), speed(speed), direction(direction), source(source) {} + ProjectileComponent(int range, int speed, Vector2D direction) : range(range), speed(speed), direction(direction) {} ~ProjectileComponent() {} void init() override; void update() override; - bool getSource() { return this->source; } - private: TransformComponent* transformComponent; @@ -25,7 +23,5 @@ private: int speed = 0; int distance = 0; - const bool source; //true if from player1 / false if from player2 - Vector2D direction; }; \ No newline at end of file diff --git a/src/AssetManager.cpp b/src/AssetManager.cpp index 9c4e909..b6988dd 100644 --- a/src/AssetManager.cpp +++ b/src/AssetManager.cpp @@ -26,12 +26,12 @@ Mix_Chunk* AssetManager::getSound(std::string id) { return soundEffects.at(id); } -void AssetManager::createProjectile(Vector2D pos, Vector2D velocity, bool source, int scale, int range, int speed, const char* texturePath, TeamLabel teamLabel) { +void AssetManager::createProjectile(Vector2D pos, Vector2D velocity, int scale, int range, int speed, const char* texturePath, TeamLabel teamLabel) { auto& projectile(man->addEntity()); projectile.addComponent(pos.x, pos.y, 32, 32, scale); //32x32 is standard size for objects projectile.addComponent(texturePath); - projectile.addComponent(range, speed, velocity, source); + projectile.addComponent(range, speed, velocity); projectile.addComponent("projectile", 0.6f); projectile.addGroup((size_t)GroupLabel::PROJECTILE); projectile.setTeam(teamLabel); diff --git a/src/HealthComponent.cpp b/src/HealthComponent.cpp index 4f9132b..77c9e0e 100644 --- a/src/HealthComponent.cpp +++ b/src/HealthComponent.cpp @@ -8,16 +8,16 @@ void HealthComponent::init() { - resetHearts(); + refreshHearts(); } void HealthComponent::modifyHealth(int health) { this->health += health; - this->resetHearts(); + this->refreshHearts(); } -void HealthComponent::resetHearts() +void HealthComponent::refreshHearts() { // clear hearts if exist for (auto& heart : this->entity->getManager().getGroup((size_t) GroupLabel::HEARTS)) { diff --git a/src/KeyboardController.cpp b/src/KeyboardController.cpp index a892083..c699ae3 100644 --- a/src/KeyboardController.cpp +++ b/src/KeyboardController.cpp @@ -63,12 +63,12 @@ void KeyboardController::update() if (fireVelocity.x > 0) { sprite->setDirection(Direction::RIGHT); Game::assets->createProjectile(Vector2D(player->position.x, player->position.y), fireVelocity, - false, 1, 180, 1, "assets/egg.png", this->entity->getTeam()); + 1, 180, 1, "assets/egg.png", this->entity->getTeam()); } else { sprite->setDirection(Direction::LEFT); Game::assets->createProjectile(Vector2D(player->position.x, player->position.y), fireVelocity, - true, 1, 180, 1, "assets/egg.png", this->entity->getTeam()); + 1, 180, 1, "assets/egg.png", this->entity->getTeam()); } lastFireTime = currentTicks;