aboutsummaryrefslogtreecommitdiffstats
path: root/src/entities.cpp
diff options
context:
space:
mode:
authorClyne Sullivan <tullivan99@gmail.com>2016-06-02 07:20:09 -0400
committerClyne Sullivan <tullivan99@gmail.com>2016-06-02 07:20:09 -0400
commit2e6369f4dbe2b49a3cb8bec3bacd6559c9733a55 (patch)
tree5171ff776a2a1d8a94ae1752d01f755ce3097b8f /src/entities.cpp
parentb22860234ff7991c851211042a9832d88ccbb958 (diff)
optimizations
Diffstat (limited to 'src/entities.cpp')
-rw-r--r--src/entities.cpp14
1 files changed, 10 insertions, 4 deletions
diff --git a/src/entities.cpp b/src/entities.cpp
index 18c91ed..2d9de76 100644
--- a/src/entities.cpp
+++ b/src/entities.cpp
@@ -941,11 +941,12 @@ Particles::Particles(float x, float y, float w, float h, float vx, float vy, Col
bounce = false;
index = Texture::getIndex(c);
zOffset = ((rand()%20)-10)/1000.0f;
+ stu = nullptr;
}
void Particles::draw(GLfloat*& p) const
{
- vec2 tc = vec2(0.25f * this->index.x, 0.125f * (8.0f - this->index.y));
+ vec2 tc = vec2(0.25f * index.x, 0.125f * (8.0f - index.y));
float z = 0.9;
if (behind)
@@ -1004,6 +1005,8 @@ void Particles::draw(GLfloat*& p) const
void Particles::update(float _gravity, float ground_y)
{
+ auto delta = game::time::getDeltaTime();
+
// handle ground collision
if (loc.y < ground_y) {
loc.y = ground_y;
@@ -1020,13 +1023,16 @@ void Particles::update(float _gravity, float ground_y)
// handle gravity
else if (gravity && vel.y > -1.0f) {
- vel.y -= _gravity * game::time::getDeltaTime();
+ vel.y -= _gravity * delta;
}
+
+ // handle lifetime
+ duration -= delta;
}
-bool Particles::kill(float delta)
+bool Particles::timeUp(void)
{
- return (duration -= delta) <= 0;
+ return !(duration > 0);
}
void Player::save(void) {