mirror of
https://github.com/HowestDAE/dae16-VerhulstBram.git
synced 2025-12-16 04:41:47 +01:00
20 lines
714 B
C++
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;
|
|
}
|