diff options
author | salaaad2 <arthurdurant263@gmail.com> | 2022-01-07 00:33:33 +0100 |
---|---|---|
committer | salaaad2 <arthurdurant263@gmail.com> | 2022-01-07 00:33:44 +0100 |
commit | 43852f3019c02645e625946fe8c237070eef6a2f (patch) | |
tree | e78b3423e6cda8e8d9dd3a5ef23e15184571978e | |
parent | almost there (diff) | |
download | threshold-43852f3019c02645e625946fe8c237070eef6a2f.tar.gz threshold-43852f3019c02645e625946fe8c237070eef6a2f.tar.bz2 threshold-43852f3019c02645e625946fe8c237070eef6a2f.tar.xz threshold-43852f3019c02645e625946fe8c237070eef6a2f.tar.zst threshold-43852f3019c02645e625946fe8c237070eef6a2f.zip |
weapons ready to be implemented. release v0.0.5
-rw-r--r-- | src/gameplay.cpp | 5 | ||||
-rw-r--r-- | src/weapon.hpp | 2 | ||||
-rw-r--r-- | src/wp_shotty.cpp | 11 | ||||
-rw-r--r-- | src/wp_shotty.hpp | 2 |
4 files changed, 8 insertions, 12 deletions
diff --git a/src/gameplay.cpp b/src/gameplay.cpp index d60c5ca..5b8e1bb 100644 --- a/src/gameplay.cpp +++ b/src/gameplay.cpp @@ -10,6 +10,7 @@ #include "raymath.h" #include <fstream> +#include <iostream> #include <raylib.h> #include "weapon.hpp" @@ -213,6 +214,7 @@ int Game::getKeys() const player->direction = Vector2Rotate(player->direction, 0.1f); } if (IsKeyPressed(KEY_SPACE)) { + std::cout << "key space"; if (shoot()) { return (0); } @@ -235,6 +237,7 @@ int Game::getKeys() const } } } else { + std::cout << "tick now" << std::endl; if (this->tick()) { return (1); } @@ -257,7 +260,7 @@ Game::shoot() const if (player->wp->empty == true) { return (0); } - player->wp->bang(enemies, player->direction, (Vector2){player->posX, player->posY}); + player->wp->bang(enemies, player->direction, (Vector2){player->posX, player->posY}, &player->victims); if (player->wp->empty == true) { player->reloadTime = GetTime(); } diff --git a/src/weapon.hpp b/src/weapon.hpp index a5099d2..ca03de3 100644 --- a/src/weapon.hpp +++ b/src/weapon.hpp @@ -30,7 +30,7 @@ public: AWeapon(float const &rg, unsigned int const &dmg, unsigned int const & mag, const char *s, const char *r); ~AWeapon(); - virtual int bang(std::vector<Entity> * enemies, Vector2 playerDirection, Vector2 playerPosition) = 0; + virtual int bang(std::vector<Entity> * enemies, Vector2 playerDirection, Vector2 playerPosition, int * victims) = 0; void refill(); bool empty; diff --git a/src/wp_shotty.cpp b/src/wp_shotty.cpp index a0d5de4..4efb64e 100644 --- a/src/wp_shotty.cpp +++ b/src/wp_shotty.cpp @@ -12,7 +12,7 @@ wp_shotty::wp_shotty(float const &rg, unsigned int const &dmg, unsigned int cons -int wp_shotty::bang(std::vector<Entity> * enemies, Vector2 playerDirection, Vector2 playerPosition) +int wp_shotty::bang(std::vector<Entity> * enemies, Vector2 playerDirection, Vector2 playerPosition, int * victims) { if (barrel == 0) { @@ -33,14 +33,8 @@ int wp_shotty::bang(std::vector<Entity> * enemies, Vector2 playerDirection, Vect r.x *= 2; r.y *= 2; - std::cout << "before loop"; - if (enemies == NULL) - { - return (0); - } for (auto en = enemies->begin(); en != enemies->end(); en++) { - std::cout << "loop"; if (CheckCollisionPointLine((Vector2){en->posX, en->posY}, playerPosition, add1, (en->radius * 2)) || CheckCollisionPointLine((Vector2){en->posX, en->posY}, playerPosition, Vector2Add(playerPosition, r), (en->radius * 2)) || CheckCollisionPointLine((Vector2){en->posX, en->posY}, playerPosition, add2, (en->radius * 2))) @@ -50,8 +44,8 @@ int wp_shotty::bang(std::vector<Entity> * enemies, Vector2 playerDirection, Vect { en->direction.x = (playerDirection.x / 2); en->direction.y = (playerDirection.y / 2); - // player->victims++; } + *victims += 1; } } // shotty cone @@ -67,7 +61,6 @@ int wp_shotty::bang(std::vector<Entity> * enemies, Vector2 playerDirection, Vect if (barrel == 0) { empty = true; - return (1); } return (0); } diff --git a/src/wp_shotty.hpp b/src/wp_shotty.hpp index bbeb112..8e91be5 100644 --- a/src/wp_shotty.hpp +++ b/src/wp_shotty.hpp @@ -16,7 +16,7 @@ class wp_shotty : public AWeapon { wp_shotty(float const &rg, unsigned int const &dmg, unsigned int const & mag, const char *s, const char *r); ~wp_shotty(); - int bang(std::vector<Entity> * enemies, Vector2 playerDirection, Vector2 playerPosition) ; + int bang(std::vector<Entity> * enemies, Vector2 playerDirection, Vector2 playerPosition, int * victims) ; }; |