#include "pch.h"
#include "Particle.h"
Particle::Particle(const Vector2f& pos, const Vector2f& velocity,const Vector2f& gravity, float lifetime, Texture* pTexture): m_Position { pos }, m_Velocity { velocity }, m_Gravity(gravity), m_LifeTime { lifetime },
                                                                                                      m_pTexture { pTexture } {
}
void Particle::Update(float elapsedSec) {
	// m_Acceleration = Vector2f { 0.0f, -9.81f * 20};
	m_Acceleration = m_Gravity;
	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, {}, m_Flipped);
	
}
bool Particle::IsDead() const {
	return m_LifeTime <= 0.0f;
}
void Particle::SetFlipped(bool flipped) {
	m_Flipped = flipped;
}
