diff --git a/Bomber.cpp b/Bomber.cpp index 4c3e5e9743620dbfe003ff2ffb447d88e4ddf895..5dcbf5c8f6bcb2e42b6047c7857ed04ab669d842 100644 --- a/Bomber.cpp +++ b/Bomber.cpp @@ -1,6 +1,6 @@ #include "Bomber.hpp" -Bomber::Bomber(float x, float y, int direction, int animationstep) - : Enemy(5,x,y,direction,animationstep) +Bomber::Bomber(float x, float y, enum direction dir, int animationstep) + : Enemy(5,x,y,dir,animationstep) { } int Bomber::getScore() @@ -118,15 +118,15 @@ static StaticPixelBuffer<23,11> constexpr left[2] = { const PixelBuffer& Bomber::getSprite() { - switch ( direcion ) { + switch (dir) { - case 1: + case direction::BACK: return back[animationstep]; break; - case 2: + case direction::LEFT: return left[animationstep]; break; - case 3: + case direction::RIGHT: return right[animationstep]; break; @@ -147,14 +147,14 @@ void Bomber::move(FloatSeconds const & Frametime, [[maybe_unused]] Level &level) animationtimer += Frametime.count(); } /*replace with Pathfinding*/ - switch ( this->direcion ) { - case 1: //front + switch ( this->dir ) { + case direction::FRONT: //front this->topleft.Y -= 10*Frametime.count(); break; - case 2: //left + case direction::LEFT: //left this->topleft.X -= 10*Frametime.count(); break; - case 3: //right + case direction::RIGHT: //right this->topleft.X += 10*Frametime.count(); break; default: diff --git a/Bomber.hpp b/Bomber.hpp index 2e4fa6f079b24aa21e601b14dc37bbc33b85f0c6..4b3cbc65aab068a792c41daf7d25cc64ac1d06fa 100644 --- a/Bomber.hpp +++ b/Bomber.hpp @@ -7,7 +7,7 @@ class Level; class Bomber: public Enemy { public: - Bomber(float x, float y, int direction, int animationstep); + Bomber(float x, float y, enum direction dir, int animationstep); void doStep(float PlayerX, float PlayerY, FloatSeconds const & Frametime, Level &level) override; int getScore() override; diff --git a/Enemy.cpp b/Enemy.cpp index c4529046ea240107f95320ddba8830e9a8084e06..f3a4b2840018bcea4104dd024b1ad250549138e2 100644 --- a/Enemy.cpp +++ b/Enemy.cpp @@ -1,11 +1,11 @@ #include "Enemy.hpp" #include "Level.hpp" #include "Enemyprojectile.hpp" -Enemy::Enemy(int health,float x, float y, int direction, int animationstep) +Enemy::Enemy(int health,float x, float y, enum direction dir, int animationstep) { this->hitpoints = health; this->topleft = { x, y }; - this->direcion = direction; + this->dir = dir; this->animationstep = animationstep; } @@ -14,20 +14,20 @@ void Enemy::shoot(Level &level) const auto &sprite = this->getSprite(); if(timetillreload<0) { - switch ( this->direcion ) { - case 1: //Up + switch ( this->dir ) { + case direction::FRONT: //Up { - level.addEnemyProjectile({this->topleft.X+sprite.w()/2-1,this->topleft.Y-sprite.h()/2,direcion}); + level.addEnemyProjectile({this->topleft.X+sprite.w()/2-1,this->topleft.Y-sprite.h()/2,dir}); break; } - case 2: //left - level.addEnemyProjectile({this->topleft.X,this->topleft.Y+sprite.h()/2-1,direcion}); + case direction::LEFT: //left + level.addEnemyProjectile({this->topleft.X,this->topleft.Y+sprite.h()/2-1,dir}); break; - case 3: //right - level.addEnemyProjectile({this->topleft.X,this->topleft.Y+sprite.h()/2-1,direcion}); + case direction::RIGHT: //right + level.addEnemyProjectile({this->topleft.X,this->topleft.Y+sprite.h()/2-1,dir}); break; default: //Down - level.addEnemyProjectile({this->topleft.X+sprite.w()/2-1,this->topleft.Y+(sprite.h()/2),direcion}); + level.addEnemyProjectile({this->topleft.X+sprite.w()/2-1,this->topleft.Y+(sprite.h()/2),dir}); break; } timetillreload = 5; @@ -125,15 +125,15 @@ bool Enemy::lookright(float PlayerX, Level &level) bool Enemy::lookAtPlayer(float PlayerX, float PlayerY, Level &level) { - switch ( direcion ) { - case 1: //back + switch (dir) { + case direction::BACK: //back return lookup(PlayerY, level); break; - case 2: //left + case direction::LEFT: //left return lookleft(PlayerX, level); break; - case 3: //right + case direction::RIGHT: //right return lookright(PlayerX, level); break; default: @@ -148,12 +148,12 @@ bool Enemy::playerdetected(float PlayerX, float PlayerY, Level &level) { if(lookdown(PlayerY, level)) { - direcion = 0; + dir = direction::BACK; return true; } else if(lookup(PlayerY, level)) { - direcion = 1; + dir = direction::FRONT; return true; } else @@ -165,12 +165,12 @@ bool Enemy::playerdetected(float PlayerX, float PlayerY, Level &level) { if(lookleft(PlayerX, level)) { - direcion = 2; + dir = direction::LEFT; return true; } else if(lookright(PlayerX, level)) { - direcion = 3; + dir = direction::RIGHT; return true; } else diff --git a/Enemy.hpp b/Enemy.hpp index cc21381c6647fbb3fcb0307901a3ada7266e3d0b..55b37e80ad24fbcb253deb127f580a4d8a035733 100644 --- a/Enemy.hpp +++ b/Enemy.hpp @@ -15,11 +15,11 @@ class Level; class Enemy : public Entity { public: - Enemy(int Health, float x, float y, int direction, int animationstep); + Enemy(int Health, float x, float y, enum direction dir, int animationstep); virtual int getScore() = 0; protected: - int direcion; + direction dir; float timetillreload = 0; float animationtimer = 0; //Kann nicht copy diff --git a/Enemyprojectile.cpp b/Enemyprojectile.cpp index 88108a68288ec813b44368dbf0df6537648ef44d..9f53cb35a487ef09281327c2e6e06e25e566fcca 100644 --- a/Enemyprojectile.cpp +++ b/Enemyprojectile.cpp @@ -2,8 +2,8 @@ #include "Platform.hpp" #include "Level.hpp" -EnemyProjectile::EnemyProjectile(float x, float y, int direction) - : Projectile(x,y,direction) +EnemyProjectile::EnemyProjectile(float x, float y, enum direction dir) + : Projectile(x,y,dir) { }; static StaticPixelBuffer<3,3> constexpr Psprite= { @@ -20,9 +20,9 @@ bool EnemyProjectile::move(FloatSeconds const & Frametime, Level &level) { int speed = 15; const auto &sprite = this->getSprite(); - switch (this->direction) + switch (this->dir) { - case 1: //down + case direction::BACK: //down if(!level.checkCollision(this->x, this->y - 3*Frametime.count(), sprite.w(), sprite.h())) { this->y -= speed*Frametime.count(); @@ -40,7 +40,7 @@ bool EnemyProjectile::move(FloatSeconds const & Frametime, Level &level) break; break; - case 2: + case direction::LEFT: if(!level.checkCollision(this->x - 3*Frametime.count(), this->y, sprite.w(), sprite.h())) { this->x -= speed*Frametime.count(); @@ -58,7 +58,7 @@ bool EnemyProjectile::move(FloatSeconds const & Frametime, Level &level) break; break; - case 3: + case direction::RIGHT: if(!level.checkCollision(this->x + 3*Frametime.count(),this->y, sprite.w(), sprite.h())) { this->x += speed*Frametime.count(); diff --git a/Enemyprojectile.hpp b/Enemyprojectile.hpp index 87a5372a2f1c903e618a8fe4bb28781c3952ab7b..0df71126e9addfd0edc2c57ea34170a9390e870f 100644 --- a/Enemyprojectile.hpp +++ b/Enemyprojectile.hpp @@ -6,7 +6,7 @@ Color constexpr ENEMY_PROJECTILE_COLOR = _2; class EnemyProjectile: public Projectile { public: - EnemyProjectile(float x, float y, int direction); + EnemyProjectile(float x, float y, enum direction dir); bool doStep(FloatSeconds const & Frametime, Level &level) override; PixelBuffer const& getSprite() override; protected: diff --git a/Level.cpp b/Level.cpp index cec0902b5b2e5e035fe6e98a4adf52df6c663602..6a4d9fc477144028a60a0e94eede391549c34142 100644 --- a/Level.cpp +++ b/Level.cpp @@ -95,10 +95,10 @@ void Level::addEnemy(std::unique_ptr<Enemy> enemy_) void Level::fillTrooperSpawner(float posX, float posY, unsigned int nmbrEnemies) { - int direction = 2; + direction dir = direction::LEFT; for(unsigned int i = 0; i <= nmbrEnemies; ++i){ - trooperSpawner.push_back(std::make_unique<Trooper>(Trooper(posX,posY,direction,0))); - direction = rand() % 4; + trooperSpawner.push_back(std::make_unique<Trooper>(Trooper(posX,posY,dir,0))); + dir=direction(rand()%4); } } // kruegerzo72182> diff --git a/Position.hpp b/Position.hpp index bc529181a597999b172c56aeb5e6cec63aecd18a..78911853451652c40bb7a45b3a795488b427537c 100644 --- a/Position.hpp +++ b/Position.hpp @@ -26,5 +26,6 @@ public: return { static_cast<int>(X), static_cast<int>(Y) }; } }; +enum class direction {BACK, FRONT, RIGHT, LEFT}; #endif // POSITION_HPP diff --git a/Projectile.cpp b/Projectile.cpp index c9a6665bf401128e601670a61e5f5f19dd43de34..1af2a50d5d42d13bf122229c849a4c0086e6cfff 100644 --- a/Projectile.cpp +++ b/Projectile.cpp @@ -1,10 +1,10 @@ #include "Projectile.hpp" -Projectile::Projectile(float x, float y, int direction) +Projectile::Projectile(float x, float y, enum direction dir) { this->x = x; this->y = y; - this->direction=direction; + this->dir=dir; } Projectile::~Projectile() { diff --git a/Projectile.hpp b/Projectile.hpp index efc685deb92d8207a8077140105c9adb4aa33bfc..a7368f4caf558c7aefe9087a619c817c62059be6 100644 --- a/Projectile.hpp +++ b/Projectile.hpp @@ -7,14 +7,14 @@ class Level; class Projectile { public: - Projectile(float x, float y, int direction); + Projectile(float x, float y, enum direction dir); virtual ~Projectile(); float getX(); float getY(); virtual const PixelBuffer& getSprite() = 0; virtual bool doStep(FloatSeconds const & Frametime, Level &level) = 0; protected: - int direction; + direction dir; float x; float y; virtual bool move(FloatSeconds const & Frametime, Level &level) = 0; diff --git a/Tank.cpp b/Tank.cpp index 3adaee8ed3451f737965e52ad6998c6e10501c57..1909666bc2a24614f0001d14c19fbe576b6031a4 100644 --- a/Tank.cpp +++ b/Tank.cpp @@ -1,6 +1,6 @@ #include "Tank.hpp" -Tank::Tank(float x, float y, int direction, int animationstep) - : Enemy(3,x,y,direction,animationstep) +Tank::Tank(float x, float y, enum direction dir, int animationstep) + : Enemy(3,x,y,dir,animationstep) { } @@ -126,15 +126,15 @@ static StaticPixelBuffer<17,11> constexpr left[2] = { }; const PixelBuffer& Tank::getSprite() { - switch ( direcion ) { + switch (dir) { - case 1: + case direction::BACK: return back[animationstep]; break; - case 2: + case direction::LEFT: return left[animationstep]; break; - case 3: + case direction::RIGHT: return right[animationstep]; break; @@ -149,24 +149,24 @@ const PixelBuffer& Tank::getSprite() void Tank::changeDirection() { - this->direcion = rand() % 4; + dir=direction(rand()%4); }; bool Tank::checkmove(FloatSeconds const & Frametime, Level &level) { - switch (this->direcion) + switch (this->dir) { - case 1: //down + case direction::BACK: //down if(!level.checkCollision(this->topleft.X, this->topleft.Y - 3*Frametime.count(), this->getSprite().w(), this->getSprite().h())) {this->topleft.Y -= 3*Frametime.count(); return false;} else return true; break; - case 2: + case direction::LEFT: if(!level.checkCollision(this->topleft.X - 3*Frametime.count(), this->topleft.Y, this->getSprite().w(), this->getSprite().h())) {this->topleft.X -= 3*Frametime.count(); return false;} else return true; break; - case 3: + case direction::RIGHT: if(!level.checkCollision(this->topleft.X + 3*Frametime.count(),this->topleft.Y, this->getSprite().w(), this->getSprite().h())) {this->topleft.X += 3*Frametime.count(); return false;} else return true; @@ -202,22 +202,22 @@ void Tank::turnToPlayer(float PlayerX, float PlayerY) { if(this->topleft.Y > PlayerY) { - direcion = 1; //up + dir=direction::FRONT; //up } else { - direcion = 0; //down + dir=direction::BACK; //down } } else { if(this->topleft.X > PlayerX) { - direcion = 2; + dir=direction::RIGHT; } else { - direcion = 3; + dir=direction::LEFT; } } }; diff --git a/Tank.hpp b/Tank.hpp index 32e2267407873b2ff83e8304b93ab75cb17580bc..c82700a349a0fe0df762f64238bc7846d7735b7d 100644 --- a/Tank.hpp +++ b/Tank.hpp @@ -6,7 +6,7 @@ class Tank: public Enemy // Fight the Power! { public: - Tank(float x, float y, int direction, int animationstep); + Tank(float x, float y, enum direction dir, int animationstep); //~Tank() override; void doStep(float PlayerX, float PlayerY, FloatSeconds const & Frametime, Level &level) override; diff --git a/Trooper.cpp b/Trooper.cpp index a9e95b6059309ba68467c489baebb7fe469a827c..5fbb151fc00cbe2d2c0360a170df9b0303f83cb7 100644 --- a/Trooper.cpp +++ b/Trooper.cpp @@ -1,8 +1,8 @@ #include "Level.hpp" #include "Trooper.hpp" -Trooper::Trooper(float x, float y, int direction, int animationstep) - : Enemy(1,x,y,direction,animationstep) +Trooper::Trooper(float x, float y, enum direction dir, int animationstep) + : Enemy(1,x,y,dir,animationstep) { animationtimer = 0; } @@ -109,15 +109,15 @@ static StaticPixelBuffer<5,9> constexpr right[2] = { }; const PixelBuffer& Trooper::getSprite() { - switch ( direcion ) { + switch (dir) { - case 1: + case direction::BACK: return back[animationstep]; break; - case 2: + case direction::LEFT: return left[animationstep]; break; - case 3: + case direction::RIGHT: return right[animationstep]; break; @@ -134,25 +134,25 @@ const PixelBuffer& Trooper::getSprite() void Trooper::changeDirection() { - this->direcion = rand() % 4; + dir=direction(rand()%4); }; bool Trooper::checkmove(FloatSeconds const & Frametime, Level &level) { const auto &sprite = this->getSprite(); - switch (this->direcion) + switch (this->dir) { - case 1: //down + case direction::BACK: //down if(!level.checkCollision(this->topleft.X, this->topleft.Y - 3*Frametime.count(), sprite.w(), sprite.h())) {this->topleft.Y -= 3*Frametime.count(); return false;} else return true; break; - case 2: + case direction::LEFT: if(!level.checkCollision(this->topleft.X - 3*Frametime.count(), this->topleft.Y, sprite.w(), sprite.h())) {this->topleft.X -= 3*Frametime.count(); return false;} else return true; break; - case 3: + case direction::RIGHT: if(!level.checkCollision(this->topleft.X + 3*Frametime.count(), this->topleft.Y, sprite.w(), sprite.h())) {this->topleft.X += 3*Frametime.count(); return false;} else return true; @@ -188,22 +188,22 @@ void Trooper::turnToPlayer(float PlayerX, float PlayerY) { if(this->topleft.Y > PlayerY) { - direcion = 1; //up + dir=direction::FRONT; //up } else { - direcion = 0; //down + dir=direction::BACK; //down } } else { if(this->topleft.X > PlayerX) { - direcion = 2; + dir=direction::RIGHT; } else { - direcion = 3; + dir=direction::LEFT; } } }; diff --git a/Trooper.hpp b/Trooper.hpp index 32b7048c061cedc03388a659e19b93e84995395c..458b0a2a950e3fb16c9f4ff808bff5480f803d7a 100644 --- a/Trooper.hpp +++ b/Trooper.hpp @@ -12,7 +12,7 @@ class Level; class Trooper: public Enemy { public: - Trooper(float x, float y, int direction, int animationstep); + Trooper(float x, float y, enum direction dir, int animationstep); void doStep(float PlayerX, float PlayerY, FloatSeconds const & Frametime, Level &level) override; int getScore() override; diff --git a/main.cpp b/main.cpp index 0b63288d9ad6f78aa133dde576712b39509f8f73..b51b86b48eeced12e2df90a259142ed5f63fcc32 100644 --- a/main.cpp +++ b/main.cpp @@ -105,20 +105,20 @@ public: //Spawn bombers from different directions endlessly bomberTimer = bomberTimer + frame_time.count(); if(bomberTimer > bomberSpawnTime){ - int direction = rand() % 4; + direction dir=direction(rand()%4); float bombX; float bombY; int offset = 20; - switch ( direction ) { - case 1: //Up + switch (dir) { + case direction::FRONT: //Up bombX = player_.getTopLeft().X; bombY = static_cast<float>(screenHeigth + offset); break; - case 2: //left + case direction::LEFT: //left bombX = static_cast<float>(screenWidth + offset); bombY = player_.getTopLeft().Y; break; - case 3: //right + case direction::RIGHT: //right bombX = static_cast<float>(-offset); bombY = player_.getTopLeft().Y; break; @@ -127,7 +127,7 @@ public: bombY = static_cast<float>(-offset); break; } - level.enemyVector_PushBack(std::make_unique<Bomber>(Bomber(bombX, bombY, direction, 0))); + level.enemyVector_PushBack(std::make_unique<Bomber>(Bomber(bombX, bombY, dir, 0))); bomberTimer = 0.0f; if(difficulty < 25) { @@ -137,10 +137,10 @@ public: if(bomberSpawnTime < 4){ bomberSpawnTime = 5; } - + tankTimer = tankTimer + frame_time.count(); if(tankTimer > tankSpawnTime){ - int direction = 0; + direction dir; int position = rand() % 6; float tankX; float tankY; @@ -148,35 +148,35 @@ public: case 1: tankX = static_cast<float>(50); tankY = static_cast<float>(150); - direction = 0; + dir = direction::BACK; break; case 2: tankX = static_cast<float>(200); tankY = static_cast<float>(160); - direction = 2; + dir = direction::LEFT; break; case 3: tankX = static_cast<float>(270); tankY = static_cast<float>(50); - direction = 1; + dir = direction::FRONT; break; case 4: tankX = static_cast<float>(15); tankY = static_cast<float>(225); - direction = 3; + dir = direction::RIGHT; break; case 5: tankX = static_cast<float>(170); tankY = static_cast<float>(210); - direction = 2; + dir = direction::LEFT; break; default: tankX = static_cast<float>(20); tankY = static_cast<float>(25); - direction = 3; + dir = direction::RIGHT; break; } - level.enemyVector_PushBack(std::make_unique<Tank>(Tank(tankX, tankY, direction, 0))); + level.enemyVector_PushBack(std::make_unique<Tank>(Tank(tankX, tankY, dir, 0))); tankTimer = 0.0f; if(difficulty < 25) { @@ -196,7 +196,7 @@ public: // enemy movement GameOverFlag = (level.doDoSteps(frame_time) == false); - + difficultyTimer = difficultyTimer + frame_time.count(); if((difficultyTimer > difficultyChangeTime)) { @@ -207,7 +207,7 @@ public: trooperSpawnCount = trooperSpawnCount + 2; } } - + // Output to the console, Gamelogic should happen before this auto const &levelBuffer = level.draw(); if(GameOverFlag) { @@ -274,8 +274,8 @@ int run(Platform &platform) level1.addScenery(245, 25, SceneryType::Bush); // add enemies to the level - level1.addEnemy(std::make_unique<Tank>(Tank(50, 150, 0, 0))); - level1.addEnemy(std::make_unique<Tank>(Tank(200, 160, 2, 0))); + level1.addEnemy(std::make_unique<Tank>(Tank(50, 150, direction::BACK, 0))); + level1.addEnemy(std::make_unique<Tank>(Tank(200, 160, direction::LEFT, 0))); level1.fillTrooperSpawner(120, 170, 4); // kruegerzo72182> // <hoffmanncl72341 diff --git a/player.cpp b/player.cpp index 91656dc3fb76e3ef268ba4202a733f60055c6d93..ceb32c7cc0ea6a3b985f39e12b23d7e0574f2835 100644 --- a/player.cpp +++ b/player.cpp @@ -127,15 +127,15 @@ static StaticPixelBuffer<PLAYER_W, PLAYER_H> constexpr left[2] = { PixelBuffer const& Player::getSprite() { - switch ( direction ) { + switch ( dir ) { - case 1: + case direction::BACK: return back[animationstep]; break; - case 2: + case direction::LEFT: return left[animationstep]; break; - case 3: + case direction::RIGHT: return right[animationstep]; break; @@ -155,22 +155,22 @@ void Player::move(Platform &p, FloatSeconds const & Frametime, Level &level) { case 'W': case 'w': { - direction=1; + dir=direction::BACK; deltaY-= speed*Frametime.count(); break; } case 'A': case 'a': { - direction=2; + dir=direction::LEFT; deltaX-= speed*Frametime.count(); break; } case 'S': case 's': { - direction=0; + dir=direction::FRONT; deltaY+= speed*Frametime.count(); break; } case 'D': case 'd': { - direction=3; + dir=direction::RIGHT; deltaX+= speed*Frametime.count(); break; } case ' ': @@ -198,20 +198,20 @@ void Player::shoot(Level &level) if(timetillreload<0) { auto const &sprite = this->getSprite(); - switch ( this->direction ) { - case 1: //front + switch ( this->dir ) { + case direction::FRONT: //front { - level.addPlayerProjectile({this->topleft.X+sprite.w()/2-1,this->topleft.Y-sprite.h()/2,direction}); + level.addPlayerProjectile({this->topleft.X+sprite.w()/2-1,this->topleft.Y+sprite.h()/2,dir}); break; } - case 2: //left - level.addPlayerProjectile({this->topleft.X,this->topleft.Y+(sprite.h()/2-1),direction}); + case direction::LEFT: //left + level.addPlayerProjectile({this->topleft.X,this->topleft.Y+(sprite.h()/2-1),dir}); break; - case 3: //right - level.addPlayerProjectile({this->topleft.X,this->topleft.Y+(sprite.h()/2-1),direction}); + case direction::RIGHT: //right + level.addPlayerProjectile({this->topleft.X,this->topleft.Y+(sprite.h()/2-1),dir}); break; default: //back - level.addPlayerProjectile({this->topleft.X+sprite.w()/2-1,this->topleft.Y+(sprite.h()/2),direction}); + level.addPlayerProjectile({this->topleft.X+sprite.w()/2-1,this->topleft.Y-(sprite.h()/2),dir}); break; } timetillreload = 1; diff --git a/player.hpp b/player.hpp index 3e4a81f4d86c5602be56d79fd20f404370052bb0..c37d0df83481e43c7aab0b8244b0cd6c05490081 100644 --- a/player.hpp +++ b/player.hpp @@ -13,7 +13,7 @@ class Player : public Entity { protected: int speed=48; - int direction=0; + direction dir=direction::BACK; int animationstep=0; float timetillreload=0.0f; float animationtimer=0.0f; diff --git a/playerprojectile.cpp b/playerprojectile.cpp index 49ea5137b76ae3275fe30411c3fc5072b6bb5759..914c114a1a6a35624aa29ac25087f8b63c13883a 100644 --- a/playerprojectile.cpp +++ b/playerprojectile.cpp @@ -2,8 +2,8 @@ #include "Platform.hpp" #include "Level.hpp" -PlayerProjectile::PlayerProjectile(float x, float y, int direction) - : Projectile(x,y,direction) +PlayerProjectile::PlayerProjectile(float x, float y, enum direction dir) + : Projectile(x,y,dir) { }; static StaticPixelBuffer<3,3> constexpr Psprite= { @@ -20,9 +20,9 @@ bool PlayerProjectile::move(FloatSeconds const & Frametime, Level &level) { int speed = 15; const auto &sprite = this->getSprite(); - switch (this->direction) + switch (this->dir) { - case 1: //down + case direction::BACK: //down if(!level.checkCollision(this->x, this->y - 3*Frametime.count(), sprite.w(), sprite.h())) { this->y -= speed*Frametime.count(); @@ -40,7 +40,7 @@ bool PlayerProjectile::move(FloatSeconds const & Frametime, Level &level) break; break; - case 2: + case direction::LEFT: if(!level.checkCollision(this->x - 3*Frametime.count(), this->y, sprite.w(), sprite.h())) { this->x -= speed*Frametime.count(); @@ -58,7 +58,7 @@ bool PlayerProjectile::move(FloatSeconds const & Frametime, Level &level) break; break; - case 3: + case direction::RIGHT: if(!level.checkCollision(this->x + 3*Frametime.count(),this->y, sprite.w(), sprite.h())) { this->x += speed*Frametime.count(); diff --git a/playerprojectile.hpp b/playerprojectile.hpp index fdcb29b3c877e4f6f65c293ddb2b32ef7139e541..d936446690d7fa3273e276cad867ce799892c7d5 100644 --- a/playerprojectile.hpp +++ b/playerprojectile.hpp @@ -6,7 +6,7 @@ Color constexpr PLAYER_PROJECTILE_COLOR = _6; class PlayerProjectile: public Projectile { public: - PlayerProjectile(float x, float y, int direction); + PlayerProjectile(float x, float y, enum direction dir); bool doStep(FloatSeconds const & Frametime, Level &level) override; PixelBuffer const& getSprite() override; protected: