mirror of
https://github.com/HowestDAE/dae16-VerhulstBram.git
synced 2025-12-16 20:41:47 +01:00
Add Particles (basic)
This commit is contained in:
@@ -1,10 +1,19 @@
|
||||
#include "pch.h"
|
||||
#include "Particle.h"
|
||||
Particle::Particle(const Vector2f& pos, const Vector2f& velocity, Texture* pTexture): m_Position{ pos }, m_Velocity{ velocity }, m_pTexture{ pTexture }
|
||||
{}
|
||||
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;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user