mirror of
https://github.com/Nimac0/SDL_Minigame
synced 2026-01-12 10:13:42 +00:00
Cleanup of legacy code booleans
This commit is contained in:
parent
9a01a19385
commit
e979b4aa88
@ -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);
|
||||
|
||||
@ -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
|
||||
|
||||
};
|
||||
@ -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;
|
||||
};
|
||||
@ -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<TransformComponent>(pos.x, pos.y, 32, 32, scale); //32x32 is standard size for objects
|
||||
projectile.addComponent<SpriteComponent>(texturePath);
|
||||
projectile.addComponent<ProjectileComponent>(range, speed, velocity, source);
|
||||
projectile.addComponent<ProjectileComponent>(range, speed, velocity);
|
||||
projectile.addComponent<ColliderComponent>("projectile", 0.6f);
|
||||
projectile.addGroup((size_t)GroupLabel::PROJECTILE);
|
||||
projectile.setTeam(teamLabel);
|
||||
|
||||
@ -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)) {
|
||||
|
||||
@ -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;
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user