diff options
Diffstat (limited to 'src/wp_assaultrifle.cpp')
-rw-r--r-- | src/wp_assaultrifle.cpp | 46 |
1 files changed, 20 insertions, 26 deletions
diff --git a/src/wp_assaultrifle.cpp b/src/wp_assaultrifle.cpp index 2d4ab0f..e12b440 100644 --- a/src/wp_assaultrifle.cpp +++ b/src/wp_assaultrifle.cpp @@ -1,21 +1,16 @@ #include "wp_assaultrifle.hpp" -#include <iostream> -#include <raymath.h> #include <raylib.h> +#include <raymath.h> +#include <iostream> #include "entity.hpp" -wp_assaultrifle::wp_assaultrifle(const char *s, const char *r) - : AWeapon(300.0f, 10, 30, 0.0, s, r) -{} - - +wp_assaultrifle::wp_assaultrifle(const char* s, const char* r) + : AWeapon(300.0f, 10, 30, 0.0, s, r) {} -int wp_assaultrifle::bang(std::vector<Entity> * enemies, Entity * player) -{ - if (barrel == 0) - { +int wp_assaultrifle::bang(std::vector<Entity>* enemies, Entity* player) { + if (barrel == 0) { return (1); } else { Vector2 playerDirection = Vector2Normalize(player->direction); @@ -37,36 +32,35 @@ int wp_assaultrifle::bang(std::vector<Entity> * enemies, Entity * player) 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)) || - CheckCollisionPointLine((Vector2){en->posX, en->posY}, playerPosition, Vector2Add(playerPosition, r), (en->radius * 2)) || - CheckCollisionPointLine((Vector2){en->posX, en->posY}, playerPosition, add2, (en->radius * 2))) - { // enemy hit + for (auto en = enemies->begin(); en != enemies->end(); en++) { + 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))) { // enemy hit std::cout << "hit" << std::endl; en->hp--; - if (en->hp == 0) - { + if (en->hp == 0) { en->direction.x = (playerDirection.x / 2); en->direction.y = (playerDirection.y / 2); player->victims += 1; } player->fury += 1; - break ; + break; } } // assaultrifle cone DrawLineEx(playerPosition, add1, 10, ORANGE); - DrawLineEx(playerPosition, - Vector2Add(playerPosition, - r), - 10, ORANGE); + DrawLineEx(playerPosition, Vector2Add(playerPosition, r), 10, ORANGE); DrawLineEx(playerPosition, add2, 10, ORANGE); // // there - if (barrel == 0) - { + if (barrel == 0) { empty = true; } return (0); |