Add Alot
This commit is contained in:
@@ -1,10 +1,11 @@
|
||||
#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 },
|
||||
Particle::Particle(const Vector2f& pos, const Vector2f& velocity,const Vector2f& gravity, float lifetime, Texture* pTexture): m_Position { pos }, m_Velocity { velocity }, m_LifeTime { lifetime }, m_Gravity(gravity),
|
||||
m_pTexture { pTexture } {
|
||||
}
|
||||
void Particle::Update(float elapsedSec) {
|
||||
m_Acceleration = Vector2f { 0.0f, -9.81f * 20};
|
||||
// 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;
|
||||
@@ -12,8 +13,12 @@ void Particle::Update(float elapsedSec) {
|
||||
|
||||
}
|
||||
void Particle::Draw() const {
|
||||
m_pTexture->Draw(m_Position);
|
||||
m_pTexture->Draw(m_Position, {}, m_Flipped);
|
||||
|
||||
}
|
||||
bool Particle::IsDead() const {
|
||||
return m_LifeTime <= 0.0f;
|
||||
}
|
||||
void Particle::SetFlipped(bool flipped) {
|
||||
m_Flipped = flipped;
|
||||
}
|
||||
|
||||
@@ -4,16 +4,22 @@
|
||||
class Particle {
|
||||
public:
|
||||
Particle() = default;
|
||||
Particle(const Vector2f& pos, const Vector2f& velocity,float lifetime, Texture* pTexture);
|
||||
Particle(const Vector2f& pos, const Vector2f& velocity, const Vector2f& gravity, float lifetime, Texture* pTexture);
|
||||
~Particle() = default;
|
||||
|
||||
void Update(float elapsedSec);
|
||||
void Draw() const;
|
||||
bool IsDead() const;
|
||||
void SetFlipped(bool flipped);
|
||||
|
||||
private:
|
||||
Vector2f m_Position;
|
||||
Vector2f m_Velocity;
|
||||
Vector2f m_Acceleration;
|
||||
|
||||
Vector2f m_Gravity;
|
||||
|
||||
bool m_Flipped{ false };
|
||||
float m_LifeTime;
|
||||
|
||||
Texture* m_pTexture;
|
||||
|
||||
Reference in New Issue
Block a user