diff options
author | salaaad2 <arthurdurant263@gmail.com> | 2022-01-05 22:23:10 +0100 |
---|---|---|
committer | salaaad2 <arthurdurant263@gmail.com> | 2022-01-05 22:23:10 +0100 |
commit | 63f9cf175480c8f5c41ca4a7fbd350053932c96d (patch) | |
tree | e4994686599f1fa7150b9b7e1877f632582bc6e8 | |
parent | reload works (diff) | |
download | threshold-63f9cf175480c8f5c41ca4a7fbd350053932c96d.tar.gz threshold-63f9cf175480c8f5c41ca4a7fbd350053932c96d.tar.bz2 threshold-63f9cf175480c8f5c41ca4a7fbd350053932c96d.tar.xz threshold-63f9cf175480c8f5c41ca4a7fbd350053932c96d.tar.zst threshold-63f9cf175480c8f5c41ca4a7fbd350053932c96d.zip |
longer shotty range, add hit function which does not work
-rw-r--r-- | meta/maps/stage_1_start.bfm | 2 | ||||
-rw-r--r-- | src/gameplay.cpp | 28 | ||||
-rw-r--r-- | src/gameplay.hpp | 1 | ||||
-rw-r--r-- | src/weapon.cpp | 2 | ||||
-rw-r--r-- | src/weapon.hpp | 2 |
5 files changed, 18 insertions, 17 deletions
diff --git a/meta/maps/stage_1_start.bfm b/meta/maps/stage_1_start.bfm index 310eba0..e17c49c 100644 --- a/meta/maps/stage_1_start.bfm +++ b/meta/maps/stage_1_start.bfm @@ -1,2 +1,2 @@ -ENEMIES 2 20 +ENEMIES 15 20 NEXT stage_1_boss.bfm diff --git a/src/gameplay.cpp b/src/gameplay.cpp index 9e37221..1a4a9e4 100644 --- a/src/gameplay.cpp +++ b/src/gameplay.cpp @@ -96,6 +96,9 @@ void Game::draw() const if (player->fury >= 5) { DrawText("[E] FURY", SCREENWIDTH - 300, 10, 50, RED); } + for (auto i = 0; i < player->wp->barrel; i++) { + DrawRectangle(40 + (i * 20), SCREENHEIGHT - 60, 10, 30, RED); + } } @@ -136,7 +139,7 @@ int Game::tick() const en->posY += en->direction.y; if (en->hp != 0 && // check for player death (one shot one kill) CheckCollisionCircles((Vector2){player->posX, player->posY}, 10, - (Vector2){en->posX, en->posY}, 10)) { + (Vector2){en->posX, en->posY}, 40)) { return (1); } } @@ -147,24 +150,22 @@ int Game::getKeys() const { auto oldX = 0, oldY = 0; // get position before processing keys to check for player movement // in threshold mode - auto aimer = player->direction; // duplicate player direction before making changes to it. this becomes the reticle - oldX = player->posX; oldY = player->posY; if (IsKeyDown(KEY_W)) { player->posX += 0; - player->posY += -4; + player->posY += -7; } if (IsKeyDown(KEY_S)) { player->posX += 0; - player->posY += 4; + player->posY += 7; } if (IsKeyDown(KEY_A)) { - player->posX += -4; + player->posX += -7; player->posY += 0; } if (IsKeyDown(KEY_D)) { - player->posX += 4; + player->posX += 7; player->posY += 0; } if (player->fury >= 5 && @@ -187,7 +188,6 @@ int Game::getKeys() const if (player->victims == nEnemies) { return (2); } - std::cout << player->victims << "|" << nEnemies << std::endl; } if (player->threshold) { @@ -215,9 +215,6 @@ int Game::getKeys() const player->wp->empty = false; } } - aimer.x = (player->direction.x / 3); - aimer.y = (player->direction.y / 3); - DrawLineEx((Vector2){player->posX, player->posY}, Vector2Add((Vector2){player->posX, player->posY}, aimer), 5, GREEN); return (0); } @@ -231,6 +228,9 @@ Game::shoot() const auto add1 = Vector2Add((Vector2){player->posX, player->posY}, rot1); auto add2 = Vector2Add((Vector2){player->posX, player->posY}, rot2); + auto r = player->direction; + r.x *= 2; + r.y *= 2; if (player->wp->empty == true) { return (0); } @@ -242,7 +242,7 @@ Game::shoot() const for (auto en = enemies->begin(); en != enemies->end(); en++) { if (CheckCollisionPointLine((Vector2){en->posX, en->posY}, (Vector2){player->posX, player->posY}, add1, (en->radius * 2)) || - CheckCollisionPointLine((Vector2){en->posX, en->posY}, (Vector2){player->posX, player->posY}, Vector2Add((Vector2){player->posX, player->posY}, player->direction), (en->radius * 2)) || + CheckCollisionPointLine((Vector2){en->posX, en->posY}, (Vector2){player->posX, player->posY}, Vector2Add((Vector2){player->posX, player->posY}, r), (en->radius * 2)) || CheckCollisionPointLine((Vector2){en->posX, en->posY}, (Vector2){player->posX, player->posY}, add2, (en->radius * 2))) { // enemy hit en->hp = 0; @@ -254,7 +254,7 @@ Game::shoot() const ORANGE); DrawLineEx((Vector2){player->posX, player->posY}, Vector2Add((Vector2){player->posX, player->posY}, - player->direction), + r), 10, ORANGE); DrawLineEx((Vector2){player->posX, player->posY}, add2, 10, ORANGE); @@ -265,7 +265,7 @@ Game::shoot() const DrawLineEx((Vector2){player->posX, player->posY}, add1, 10, ORANGE); DrawLineEx((Vector2){player->posX, player->posY}, Vector2Add((Vector2){player->posX, player->posY}, - player->direction), + r), 10, ORANGE); DrawLineEx((Vector2){player->posX, player->posY}, add2, 10, ORANGE); return (0); diff --git a/src/gameplay.hpp b/src/gameplay.hpp index 62da89f..6720560 100644 --- a/src/gameplay.hpp +++ b/src/gameplay.hpp @@ -48,6 +48,7 @@ class Game { int tick() const; int getKeys() const; int shoot() const; + int hit(Entity en, Vector2 add1, Vector2 add2) const ; std::string const &getNext() const; // returns next level's string }; diff --git a/src/weapon.cpp b/src/weapon.cpp index 507c5b3..ad94605 100644 --- a/src/weapon.cpp +++ b/src/weapon.cpp @@ -18,7 +18,7 @@ Weapon::Weapon(float const & rg, unsigned int const & dmg, const char *s, const reload = LoadSound(r); SetSoundVolume(shot, 0.3f); SetSoundVolume(reload, 0.3f); - max = barrel = 5; + max = barrel = 10; } Weapon::~Weapon() {} diff --git a/src/weapon.hpp b/src/weapon.hpp index 902b55f..f117230 100644 --- a/src/weapon.hpp +++ b/src/weapon.hpp @@ -15,7 +15,6 @@ class Weapon { Sound shot; Sound reload; - unsigned int barrel; unsigned int max; @@ -30,6 +29,7 @@ public: void refill(); bool empty; + unsigned int barrel; }; #endif // WEAPON_H_ |