diff --git a/PixelShaders.cpp b/PixelShaders.cpp index 376ec5e68630a9ce9abef6eeeea324296450fd91..d5298d700ce5776be5659c69f9522a994195ff1c 100644 --- a/PixelShaders.cpp +++ b/PixelShaders.cpp @@ -49,3 +49,8 @@ Color DiagonalFadeoutShader::peekUnchecked(PixelPoint const &pos) const } return (pos.x <= x_end) ? _0 : src; } +Color ReloadShader::peekUnchecked(PixelPoint const &pos) const +{ + auto src = input.peek(pos); + +} diff --git a/PixelShaders.hpp b/PixelShaders.hpp index bb20dc2de2823d08007dec4422d3ed3790644126..6f42fc362cdb5492fb3748ef7b29430b4db170ff 100644 --- a/PixelShaders.hpp +++ b/PixelShaders.hpp @@ -31,5 +31,13 @@ public: virtual Color peekUnchecked(PixelPoint const &pos) const; }; +class ReloadShader: public ShadedPixelBuffer{ +public: + float percent; + virtual Color peekUnchecked(PixelPoint const &pos) const; + ReloadShader(PixelBuffer const &input, float percent) : + ShadedPixelBuffer(input), percent(percent) { + } +}; #endif /* PIXELSHADERS_HPP */ diff --git a/main.cpp b/main.cpp index 8aa9c7d803ad0b7e46133092c90ab5fff7f065b0..eebdf98fe45d14c99231e971b6659b457ec91ec6 100644 --- a/main.cpp +++ b/main.cpp @@ -31,7 +31,7 @@ float difficultyChangeTime = 60.0f; int screenWidth = 320; int screenHeigth = 320; int difficulty = 0; - +//lives // global helper funktion to add "buildings" void addBuilding(float x, float y, int size, Level &level_ptr) @@ -229,8 +229,9 @@ public: framebuffer.blit_topleft({ 0, 0 }, levelBuffer); for(auto & i : Highscore.ScoreBoard){ framebuffer.blit_topleft(i.ScorePos,i.getScoreSprite()); - } + } } + framebuffer.blit_topleft({3,3},player_.getLivesSprite(player_.getHitPoints())); // kruegerzo72182> // <hoffmanncl72341 platform.render(framebuffer); diff --git a/player.cpp b/player.cpp index 700dbbd316d7d2f91e86440ae114441dd38bc48b..2ea762a7f11561699f9f7c0cd4c6cec8a9bcc067 100644 --- a/player.cpp +++ b/player.cpp @@ -176,6 +176,7 @@ void Player::move(Platform &p, FloatSeconds const & Frametime, Level &level) case ' ': { shoot(level); + attack=true; } } } @@ -218,3 +219,63 @@ void Player::shoot(Level &level) } } +static StaticPixelBuffer<39,7> constexpr lives[6]={ + {{{ + {" "}, + {" "}, + {" "}, + {" "}, + {" "}, + {" "}, + {" "} + }}}, + {{{ + {" 22 22 "}, + {"2222222 "}, + {"2222222 "}, + {"2222222 "}, + {" 22222 "}, + {" 222 "}, + {" 2 "} + }}}, + {{{ + {" 22 22 22 22 "}, + {"2222222 2222222 "}, + {"2222222 2222222 "}, + {"2222222 2222222 "}, + {" 22222 22222 "}, + {" 222 222 "}, + {" 2 2 "} + }}}, + {{{ + {" 22 22 22 22 22 22 "}, + {"2222222 2222222 2222222 "}, + {"2222222 2222222 2222222 "}, + {"2222222 2222222 2222222 "}, + {" 22222 22222 22222 "}, + {" 222 222 222 "}, + {" 2 2 2 "} + }}}, + {{{ + {" 22 22 22 22 22 22 22 22 "}, + {"2222222 2222222 2222222 2222222 "}, + {"2222222 2222222 2222222 2222222 "}, + {"2222222 2222222 2222222 2222222 "}, + {" 22222 22222 22222 22222 "}, + {" 222 222 222 222 "}, + {" 2 2 2 2 "} + }}}, + {{{ + {" 22 22 22 22 22 22 22 22 22 22 "}, + {"2222222 2222222 2222222 2222222 2222222"}, + {"2222222 2222222 2222222 2222222 2222222"}, + {"2222222 2222222 2222222 2222222 2222222"}, + {" 22222 22222 22222 22222 22222 "}, + {" 222 222 222 222 222 "}, + {" 2 2 2 2 2 "} + }}} +}; +const PixelBuffer& Player::getLivesSprite(int hitpoints) +{ + return lives[hitpoints]; +} diff --git a/player.hpp b/player.hpp index c37d0df83481e43c7aab0b8244b0cd6c05490081..bc13f98d97982afd411a5841219d488738920631 100644 --- a/player.hpp +++ b/player.hpp @@ -17,11 +17,13 @@ protected: int animationstep=0; float timetillreload=0.0f; float animationtimer=0.0f; + bool attack=false; public: Player(float x, float y); PixelBuffer const& getSprite() override; void move(Platform &p, FloatSeconds const & Frametime, Level &level); void shoot(Level &level); + const PixelBuffer& getLivesSprite(int hitpoints); }; #endif // PLAYER_HPP