diff options
author | salaaad2 <arthurdurant263@gmail.com> | 2022-01-11 17:04:34 +0100 |
---|---|---|
committer | salaaad2 <arthurdurant263@gmail.com> | 2022-01-11 17:04:34 +0100 |
commit | 0f52cc0373370d639b8de42c7c9551da0db86d52 (patch) | |
tree | 35c270760a1d9b3b1c11e3a3b55268aac464d1ea /src | |
parent | mouselook on shotgun (diff) | |
download | threshold-0f52cc0373370d639b8de42c7c9551da0db86d52.tar.gz threshold-0f52cc0373370d639b8de42c7c9551da0db86d52.tar.bz2 threshold-0f52cc0373370d639b8de42c7c9551da0db86d52.tar.xz threshold-0f52cc0373370d639b8de42c7c9551da0db86d52.tar.zst threshold-0f52cc0373370d639b8de42c7c9551da0db86d52.zip |
clang-format chromium test
Diffstat (limited to '')
-rw-r--r-- | src/gameplay.cpp | 27 | ||||
-rw-r--r-- | src/gameplay.hpp | 4 | ||||
-rw-r--r-- | src/wp_assaultrifle.cpp | 29 | ||||
-rw-r--r-- | src/wp_shotty.cpp | 1 |
4 files changed, 21 insertions, 40 deletions
diff --git a/src/gameplay.cpp b/src/gameplay.cpp index 3a3d09b..9017de0 100644 --- a/src/gameplay.cpp +++ b/src/gameplay.cpp @@ -158,16 +158,6 @@ void Game::draw() } -int Game::getDiff(Vector2 pos, Vector2 tip, Vector2 target) const -{ - if(((tip.x-pos.x)*(target.y-pos.y)-(tip.y-pos.y)*(target.x-pos.x))<0) - return -1; - if(((tip.x-pos.x)*(target.y-pos.y)-(tip.y-pos.y)*(target.x-pos.x))>0) - return 1; - - return 0; -} - // progress the game & check for player death // NEW: go towards player NEXT: spawn at different furyTimes int Game::tick() const @@ -222,7 +212,7 @@ int Game::tick() const if (en->hp != 0 && // check for player death (one shot one kill) CheckCollisionCircles((Vector2){player->posX, player->posY}, 10, (Vector2){en->posX, en->posY}, 40)) { - std::cout << "cool" << std::endl; + return (1); } } return (0); @@ -263,14 +253,7 @@ int Game::getKeys() const if (IsKeyDown(KEY_TWO)) { player->currentWeapon = player->wp[1]; } - if (IsKeyDown(KEY_LEFT)) { - player->direction = Vector2Rotate(player->direction, -0.1f); // left - } - if (IsKeyDown(KEY_RIGHT)) { - player->direction = Vector2Rotate(player->direction, 0.1f); - } - if (IsKeyPressed(KEY_SPACE)) { - std::cout << "key space"; + if (IsKeyPressed(KEY_SPACE) || IsMouseButtonPressed(MOUSE_BUTTON_LEFT)) { if (shoot()) { return (0); } @@ -280,14 +263,12 @@ int Game::getKeys() const } if (player->threshold) { - if (GetTime() >= (player->furyTime + 5)) - { + if (GetTime() >= (player->furyTime + 5)) { player->fury = 0; player->threshold = false; } if (oldX != player->posX || - oldY != player->posY) - { + oldY != player->posY) { if (this->tick()) { return (1); } diff --git a/src/gameplay.hpp b/src/gameplay.hpp index 17a17f4..b379332 100644 --- a/src/gameplay.hpp +++ b/src/gameplay.hpp @@ -41,7 +41,7 @@ class Game { int nWaves; // number of waves in level int nPerWave; // number of enemies per wave. - // NOTE : maps are assumed to be correct. tyhus, no + // NOTE : maps are assumed to be correct. therefore, no // checks are made to verify their integrity. // having wrong maps can (and probably will) result in a crash @@ -75,8 +75,6 @@ class Game { int shoot() const; int hit(Entity en, Vector2 add1, Vector2 add2) const ; - int getDiff(Vector2 pos, Vector2 tip, Vector2 target) const ; - std::string const &getNext() const; // returns next level's string std::string const &getCurrent() const; // returns next level's string }; diff --git a/src/wp_assaultrifle.cpp b/src/wp_assaultrifle.cpp index 1ed9e19..2d4ab0f 100644 --- a/src/wp_assaultrifle.cpp +++ b/src/wp_assaultrifle.cpp @@ -7,7 +7,7 @@ #include "entity.hpp" wp_assaultrifle::wp_assaultrifle(const char *s, const char *r) - : AWeapon(100, 10, 30, 0.0, s, r) + : AWeapon(300.0f, 10, 30, 0.0, s, r) {} @@ -18,22 +18,25 @@ int wp_assaultrifle::bang(std::vector<Entity> * enemies, Entity * player) { return (1); } else { + Vector2 playerDirection = Vector2Normalize(player->direction); + playerDirection.x *= range; + playerDirection.y *= range; + Vector2 playerPosition = (Vector2){player->posX, player->posY}; + Vector2 rot1 = Vector2Rotate(playerDirection, -0.2f); + Vector2 rot2 = Vector2Rotate(playerDirection, 0.2f); + + Vector2 add1 = Vector2Add(playerPosition, rot1); + Vector2 add2 = Vector2Add(playerPosition, rot2); + + Vector2 r; barrel--; PlaySound(shot); + t = GetTime(); // here // - Vector2 playerDirection = player->direction; - Vector2 playerPosition = (Vector2){player->posX, player->posY}; - auto rot1 = Vector2Rotate(playerDirection, -0.2f); - auto rot2 = Vector2Rotate(playerDirection, 0.2f); - - auto add1 = Vector2Add(playerPosition, rot1); - auto add2 = Vector2Add(playerPosition, rot2); - - auto r = playerDirection; - r.x *= 4; - r.y *= 4; - + r = playerDirection; + r.x *= 2; + r.y *= 2; for (auto en = enemies->begin(); en != enemies->end(); en++) { if (CheckCollisionPointLine((Vector2){en->posX, en->posY}, playerPosition, add1, (en->radius * 2)) || diff --git a/src/wp_shotty.cpp b/src/wp_shotty.cpp index 1b5573a..e60e0aa 100644 --- a/src/wp_shotty.cpp +++ b/src/wp_shotty.cpp @@ -35,7 +35,6 @@ int wp_shotty::bang(std::vector<Entity> * enemies, Entity * player) t = GetTime(); // here // - std::cout << "range : " << range << std::endl; r = playerDirection; r.x *= 2; r.y *= 2; |