#include "pch.h" #include "ParticleManager.h" #include <algorithm> #include <iostream> ParticleManager::ParticleManager() : m_pParticles{ } { } ParticleManager::~ParticleManager() { for (int i{}; i < int(m_pParticles.size()); i++) { delete m_pParticles[i]; m_pParticles[i] = nullptr; } } Particle* ParticleManager::AddParticle(Particle* pParticle) { m_pParticles.push_back(pParticle); return m_pParticles.back(); } void ParticleManager::CreateBlood(const Point2f& pos) { AddParticle(new Particle{ pos, Vector2f{ 750, 500 } }); AddParticle(new Particle{ pos, Vector2f{ 150, 750 } }); AddParticle(new Particle{ pos, Vector2f{ -750, 500 } }); } void ParticleManager::Update(float elapsedSec, const Level& level) { bool deleted{}; using ForwardIt = std::vector<Particle*>::reverse_iterator; for (Particle* pParticle : m_pParticles) { pParticle->Update(elapsedSec, level); } } void ParticleManager::Draw() const { for (Particle* pParticle : m_pParticles) { pParticle->Draw(); } } size_t ParticleManager::Size() const { return m_pParticles.size(); } std::vector<Particle*>& ParticleManager::GetParticles() { return m_pParticles; }