Files
dae16-VerhulstBram-GameProject/Game/Particle/Particle.cpp
2024-05-09 13:50:52 +02:00

20 lines
714 B
C++

#include "pch.h"
#include "Particle.h"
Particle::Particle(const Vector2f& pos, const Vector2f& velocity, float lifetime, Texture* pTexture): m_Position { pos }, m_Velocity { velocity }, m_LifeTime { lifetime },
m_pTexture { pTexture } {
}
void Particle::Update(float elapsedSec) {
m_Acceleration = Vector2f { 0.0f, -9.81f * 20};
m_Velocity += m_Acceleration * elapsedSec;
m_Position += m_Velocity * elapsedSec;
m_LifeTime -= elapsedSec;
m_Acceleration = Vector2f { 0.0f, 0.0f };
}
void Particle::Draw() const {
m_pTexture->Draw(m_Position);
}
bool Particle::IsDead() const {
return m_LifeTime <= 0.0f;
}