diff --git a/Bomber.cpp b/Bomber.cpp index 80505783c0ede2e1cab1b9b5533be742605c75b1..b937b627a08231aa4d9dcc596c0284afe1aec4b7 100644 --- a/Bomber.cpp +++ b/Bomber.cpp @@ -1,5 +1,5 @@ #include "Bomber.hpp" -//WeberMa73121: implementation enum direction dir ersetzt int direcion--------------------------------------- +//WeberMa73121: implementation enum direction dir replaces int direcion--------------------------------------- //Hauerch71498 ---------------------------------------------------------------------------------------------- Bomber::Bomber(float x, float y, enum direction dir, int animationstep) : Enemy(5,x,y,dir,animationstep) diff --git a/Bomber.hpp b/Bomber.hpp index c24ac0d59713ae0e21e6b8cb9794fe4737cc8fa2..0dc30c0ef38ae32d1f4a62b5c115553c49549c7b 100644 --- a/Bomber.hpp +++ b/Bomber.hpp @@ -2,7 +2,7 @@ #define BOMBER_HPP #include "Enemy.hpp" -//WeberMa73121: implementation enum direction dir ersetzt int direcion--------------------------------------- +//WeberMa73121: implementation enum direction dir replaces int direcion--------------------------------------- //Hauerch71498 ---------------------------------------------------------------------------------------------- class Level; diff --git a/Enemy.cpp b/Enemy.cpp index d38049f75c7c99f129e78d7b2861fca2ca749371..2d1e500ac3ef94e931261947c007e7150f22105e 100644 --- a/Enemy.cpp +++ b/Enemy.cpp @@ -1,7 +1,7 @@ #include "Enemy.hpp" #include "Level.hpp" #include "Enemyprojectile.hpp" -//WeberMa73121: implementation enum direction dir ersetzt int direcion--------------------------------------- +//WeberMa73121: implementation enum direction dir replaces int direcion--------------------------------------- //Hauerch71498 ---------------------------------------------------------------------------------------------- Enemy::Enemy(int health,float x, float y, enum direction dir, int animationstep) { diff --git a/Enemy.hpp b/Enemy.hpp index a2c6d36938dcc971887bad0c051d52ada7460e29..cc08cd032415cc5ca90b6c69edd0439337f4d2e5 100644 --- a/Enemy.hpp +++ b/Enemy.hpp @@ -4,7 +4,7 @@ #include "Entity.hpp" #include "PixelBuffer.hpp" #include "Platform.hpp" -//WeberMa73121: implementation enum direction dir ersetzt int direcion--------------------------------------- +//WeberMa73121: implementation enum direction dir replaces int direcion--------------------------------------- //Hauerch71498 ---------------------------------------------------------------------------------------------- class Level; diff --git a/Enemyprojectile.cpp b/Enemyprojectile.cpp index f4d9dcbf60921eed8970e463081e297c1536cb60..4d876b476ad2fbd6199ad02e3ed371b7cda498fb 100644 --- a/Enemyprojectile.cpp +++ b/Enemyprojectile.cpp @@ -1,7 +1,7 @@ #include "Enemyprojectile.hpp" #include "Platform.hpp" #include "Level.hpp" -//WeberMa73121: implementation enum direction dir ersetzt int direction--------------------------------------- +//WeberMa73121: implementation enum direction dir replaces int direction--------------------------------------- //Hauerch71498 ---------------------------------------------------------------------------------------------- EnemyProjectile::EnemyProjectile(float x, float y, enum direction dir) : Projectile(x,y,dir) diff --git a/Enemyprojectile.hpp b/Enemyprojectile.hpp index 78971c7ae6a2ee1007f4f6aa3f7419d81f7a5326..aacb8b23f56a62440a387839a9be3b905eb36029 100644 --- a/Enemyprojectile.hpp +++ b/Enemyprojectile.hpp @@ -1,7 +1,7 @@ #ifndef ENEMYPROJECTILE_HPP #define ENEMYPROJECTILE_HPP #include "Projectile.hpp" -//WeberMa73121: implementation enum direction dir ersetzt int direcion--------------------------------------- +//WeberMa73121: implementation enum direction dir replaces int direcion--------------------------------------- //Hauerch71498 ---------------------------------------------------------------------------------------------- Color constexpr ENEMY_PROJECTILE_COLOR = _2; class EnemyProjectile: public Projectile diff --git a/Level.cpp b/Level.cpp index 46acccb4be929d8896ee83cefcbc75fc6dcff211..04cf7c4586b63194905027692ccfe9621a1bb3ad 100644 --- a/Level.cpp +++ b/Level.cpp @@ -18,13 +18,10 @@ DynamicPixelBuffer Wall::constructWallBuffer(Orientation orientation, int length Wall::Wall(int length, int thickness, Position const &pos, Orientation orientation) : Entity(pos), - wallLength(length), - wallThickness(thickness), wallOrientation(orientation), - wallColor(_1), wallBuffer(constructWallBuffer(orientation, length, thickness)) { - this->wallBuffer.clear(this->wallColor); + this->wallBuffer.clear(_1); } PixelBuffer const& Wall::getSprite() @@ -32,11 +29,6 @@ PixelBuffer const& Wall::getSprite() return this->wallBuffer; } -void Wall::setWallColor(Color color) -{ - this->wallColor = color; -} - Orientation Wall::getOrientation() const { return this->wallOrientation; @@ -112,6 +104,7 @@ void Level::addEnemy(std::unique_ptr<Enemy> enemy_) enemyVector.push_back(std::move(enemy_)); } +// primes the trooperSpawner void Level::fillTrooperSpawner(float posX, float posY, unsigned int nmbrEnemies) { direction dir = direction::LEFT; @@ -139,6 +132,7 @@ void Level::addPlayerProjectile(const PlayerProjectile& projectile) // weberma73121> ---------------------------------------------------------------------- // <kruegerzo72182 ---------------------------------------------------------------------- +// pops the last trooper from the trooperSpawner and reduces the vector capacity std::unique_ptr<Enemy> Level::getTrooperSpawn() { if(trooperSpawner.back() != 0){ @@ -160,6 +154,7 @@ void Level::enemyVector_PushBack(std::unique_ptr<Enemy> enemy_) this->enemyVector.push_back(std::move(enemy_)); } +// do all the Steps for movement and animations bool Level::doDoSteps(FloatSeconds const &frame_time) { player.step(player.getTopLeft(), frame_time, *this); @@ -191,6 +186,7 @@ bool Level::doDoSteps(FloatSeconds const &frame_time) for(auto it = sceneryVector.begin(); it != sceneryVector.end();) { auto& i = *it; if(!i.step(player.getTopLeft(), frame_time, *this)) { + // call the step method from the Entity class to see if the object was hit it = sceneryVector.erase(it); } else { it++; @@ -200,6 +196,7 @@ bool Level::doDoSteps(FloatSeconds const &frame_time) for(auto it = wallVector.begin(); it != wallVector.end();) { auto& i = *it; if(!i.step(player.getTopLeft(), frame_time, *this)) { + // call the step method from the Entity class to see if the object was hit it = wallVector.erase(it); } else { it++; @@ -208,6 +205,7 @@ bool Level::doDoSteps(FloatSeconds const &frame_time) return true; } +// checks if the two given buffers are overlaping bool Level::collHelper(Position const& vecPos, PixelBuffer const& vecBuf, float buffPosX, float buffPosY, int buffWidth, int buffHeigth) { for(int x = static_cast<int>(vecPos.X); x <= static_cast<int>(vecPos.X) + vecBuf.w(); ++x){ @@ -220,6 +218,7 @@ bool Level::collHelper(Position const& vecPos, PixelBuffer const& vecBuf, float return false; } +// iterates through the border, walls and the scenery and checks for collisions bool Level::checkCollision(float posX, float posY, int bufferWidth, int bufferHeigth) { for(auto i = this->wallVector.begin(); i != this->wallVector.end(); i++ ){ @@ -246,6 +245,11 @@ bool Level::HitEnemy(float posX, float posY, int bufferWidth, int bufferHeigth) } return false; } + +int Level::getScore() const +{ + return score; +} // hauerch71498> ---------------------------------------------------------------------- // <weberma73121 ---------------------------------------------------------------------- @@ -268,6 +272,8 @@ bool Level::HitPlayer(float posX, float posY, int bufferWidth, int bufferHeigth) // weberma73121> ---------------------------------------------------------------------- // <kruegerzo72182 ---------------------------------------------------------------------- +// remove scenery and wall objects from their corresponding vectors if theay are hit +// vector.erase() happens in doDoSteps() do to animation by Claudio bool Level::HitObstacle(float posX, float posY, Color hitColor, int bufferWidth, int bufferHeigth) { for(auto &i : wallVector){ @@ -287,11 +293,7 @@ bool Level::HitObstacle(float posX, float posY, Color hitColor, int bufferWidth, return false; } -int Level::getScore() const -{ - return score; -} - +// blit all objects, enemies and the player stored in the level class to the levelBuffer DynamicPixelBuffer const& Level::draw() { this->levelBuffer.clear(_t); diff --git a/Level.hpp b/Level.hpp index af1b93d3d9a7ea3cd7738412fdaf94cb28339233..ce773657567d3ce10eb4008551f6990189b6f2a1 100644 --- a/Level.hpp +++ b/Level.hpp @@ -30,16 +30,10 @@ public: Wall(int length, int thickness, Position const &pos, Orientation orientation); DynamicPixelBuffer constructWallBuffer(Orientation orientation, int length, int thickness); PixelBuffer const& getSprite() override; - void setWallColor(Color color); Orientation getOrientation() const; private: - int wallLength; - int wallThickness; - Orientation wallOrientation; - Color wallColor; - DynamicPixelBuffer wallBuffer; }; diff --git a/Scoreb.cpp b/Scoreb.cpp index a84f60e24a2a1a977224ed61aa7c30aff570a7bb..3ee7eee84009fef94d54072e724a2345a695e86a 100644 --- a/Scoreb.cpp +++ b/Scoreb.cpp @@ -100,7 +100,7 @@ static StaticPixelBuffer<4,6> constexpr sechs= { static StaticPixelBuffer<4,6> constexpr sieben= { {{ {"777 "}, - {" 7 "}, + {" 070"}, {" 70"}, {" 7 0"}, {" 70 "}, diff --git a/Tank.cpp b/Tank.cpp index 731b7a10816017668ba3e95fac2433236144541e..e00098c1f5d426cbd1d7f7a6b483e9b0f91f5a7c 100644 --- a/Tank.cpp +++ b/Tank.cpp @@ -1,5 +1,5 @@ #include "Tank.hpp" -//WeberMa73121: implementation enum direction dir ersetzt int direction--------------------------------------- +//WeberMa73121: implementation enum direction dir replaces int direction--------------------------------------- //Hauerch71498 ---------------------------------------------------------------------------------------------- Tank::Tank(float x, float y, enum direction dir, int animationstep) : Enemy(3,x,y,dir,animationstep) diff --git a/Tank.hpp b/Tank.hpp index 48e95d2cbd36e5629c30cb3f6e7b2c3d21c869db..d9566aaa56c29a91e9f2d6394922165f5d78b64a 100644 --- a/Tank.hpp +++ b/Tank.hpp @@ -2,7 +2,7 @@ #define TANK_HPP #include "Enemy.hpp" #include "Level.hpp" -//WeberMa73121: implementation enum direction dir ersetzt int direcion--------------------------------------- +//WeberMa73121: implementation enum direction dir replaces int direcion--------------------------------------- //Hauerch71498 ---------------------------------------------------------------------------------------------- class Tank: public Enemy // Fight the Power! { diff --git a/Trooper.cpp b/Trooper.cpp index 0fef0d0115934cff9f71b6bedb4c48924652f1aa..1079b65627d2714f48565fdb0d440de02132aea2 100644 --- a/Trooper.cpp +++ b/Trooper.cpp @@ -1,6 +1,6 @@ #include "Level.hpp" #include "Trooper.hpp" -//WeberMa73121: implementation enum direction dir ersetzt int direction--------------------------------------- +//WeberMa73121: implementation enum direction dir replaces int direction--------------------------------------- //Hauerch71498 ---------------------------------------------------------------------------------------------- Trooper::Trooper(float x, float y, enum direction dir, int animationstep) diff --git a/Trooper.hpp b/Trooper.hpp index 3300cd50c0246b66e1ea6f7fb5fcc94ec6c288ed..cbac4caf09908d47f5e0bd0d53eca3cc989fbff8 100644 --- a/Trooper.hpp +++ b/Trooper.hpp @@ -1,6 +1,6 @@ #ifndef TROOPER_HPP #define TROOPER_HPP -//WeberMa73121: implementation enum direction dir ersetzt int direcion--------------------------------------- +//WeberMa73121: implementation enum direction dir replaces int direcion--------------------------------------- //Hauerch71498 ---------------------------------------------------------------------------------------------- #include "Enemy.hpp" class Level; diff --git a/main.cpp b/main.cpp index 11f050dd39575b9726e4f9cc9c091bd9014a8363..3c2ecf2c093ab16ff6bba66c4e146afc4c2adbf5 100644 --- a/main.cpp +++ b/main.cpp @@ -260,7 +260,7 @@ public: } } // hauerch71498> --------------------------------------------------------------------- - framebuffer.blit_topleft({ 3, 3 },player_.getLivesSprite()); + framebuffer.blit_topleft({ 3, 3 },player_.getLivesSprite()); //weberma73121 // kruegerzo72182> // <hoffmanncl72341 platform.render(framebuffer); diff --git a/player.cpp b/player.cpp index 9fde6abbc5afe3dc73f7e8eb243e9fad21fc45d7..2b5d5a640016e26051df3f0ecafc158589e28cfb 100644 --- a/player.cpp +++ b/player.cpp @@ -130,10 +130,11 @@ Player::Shader::Shader(Player const &player) : PixelBuffer(PLAYER_W, (PLAYER_H + 2)), player(player) { } - +//hoffmanncl72341---------------------------- Color Player::Shader::peekUnchecked(PixelPoint const &pos) const { auto const &basesprite = [this]() { + //hoffmanncl72341---------------------------- switch (player.dir) { case direction::BACK: return back[player.animationstep]; @@ -148,6 +149,7 @@ Color Player::Shader::peekUnchecked(PixelPoint const &pos) const default: return front[player.animationstep]; } + //hoffmanncl72341----------------------------- }(); if(player.timetillreload == 0.0f) { return basesprite.peek(pos); @@ -162,6 +164,7 @@ Color Player::Shader::peekUnchecked(PixelPoint const &pos) const } return basesprite.peek(pos); } +//hoffmanncl72341--------------------------- PixelBuffer const& Player::getSprite() {