Skip to content
Snippets Groups Projects
Commit 0660af11 authored by Claudio Hoffmann's avatar Claudio Hoffmann
Browse files

Entity: Add an unexpectedly awesome destruction animation :boom:

parent adc007e4
Branches
No related tags found
No related merge requests found
...@@ -65,7 +65,7 @@ int Entity::takeDamage() ...@@ -65,7 +65,7 @@ int Entity::takeDamage()
void Entity::blit(DynamicPixelBuffer &buf) void Entity::blit(DynamicPixelBuffer &buf)
{ {
if(hittime > 0.0f) { if(hittime > 0.0f) {
HitShader hs{ getSprite(), hittime, HIT_TIME }; HitShader hs{ getSprite(), (hittime / HIT_TIME), (hitpoints == 0) };
buf.blit_topleft(topleft, hs); buf.blit_topleft(topleft, hs);
} else if(hitpoints > 0) { } else if(hitpoints > 0) {
buf.blit_topleft(topleft, getSprite()); buf.blit_topleft(topleft, getSprite());
......
...@@ -22,5 +22,5 @@ Color HitShader::peekUnchecked(PixelPoint const &pos) const ...@@ -22,5 +22,5 @@ Color HitShader::peekUnchecked(PixelPoint const &pos) const
if(src == _t) { if(src == _t) {
return _t; return _t;
} }
return (dist(rng.rng) > 0.95f) ? _3 : src; return (dist(rng.rng) > 0.95f) ? _3 : (is_final ? _t : src);
} }
...@@ -6,9 +6,10 @@ ...@@ -6,9 +6,10 @@
class HitShader : public ShadedPixelBuffer { class HitShader : public ShadedPixelBuffer {
public: public:
float percent; float percent;
bool is_final;
HitShader(PixelBuffer const &input, float time_cur, float time_total) HitShader(PixelBuffer const &input, float percent, bool is_final)
: ShadedPixelBuffer(input), percent(time_cur / time_total) { : ShadedPixelBuffer(input), percent(percent), is_final(is_final) {
} }
virtual Color peekUnchecked(PixelPoint const &pos) const; virtual Color peekUnchecked(PixelPoint const &pos) const;
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment