From 902946fef868b2c9448532d616745b29356d6bfa Mon Sep 17 00:00:00 2001
From: salaaad2 <arthurdurant263@gmail.com>
Date: Wed, 5 Jan 2022 18:38:15 +0100
Subject: terrain is fukkkkd

---
 CMakeLists.txt   |  1 +
 src/gameplay.cpp | 11 +++++------
 src/gameplay.hpp |  3 +++
 src/terrain.cpp  | 15 +++++++++++++++
 src/terrain.hpp  | 16 ++++++++++++++++
 5 files changed, 40 insertions(+), 6 deletions(-)
 create mode 100644 src/terrain.cpp
 create mode 100644 src/terrain.hpp

diff --git a/CMakeLists.txt b/CMakeLists.txt
index 8f2d3cd..111e2cf 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -10,6 +10,7 @@ add_executable(${PROJECT_NAME}
     src/window.cpp
     src/gameplay.cpp
     src/weapon.cpp
+    src/terrain.cpp
     src/entity.cpp)
 
 target_link_libraries(${PROJECT_NAME} raylib m pthread dl)
diff --git a/src/gameplay.cpp b/src/gameplay.cpp
index 3adaa2d..d732a48 100644
--- a/src/gameplay.cpp
+++ b/src/gameplay.cpp
@@ -59,6 +59,7 @@ Game::~Game()
 {
     delete enemies;
     delete player;
+    delete terrain;
 }
 
 void Game::start()
@@ -78,7 +79,9 @@ void Game::start()
 void Game::draw() const
 {
     auto left = std::to_string(enemies->size());
+
     ClearBackground(COOLPURPLE);
+
     for (auto & en : *enemies)
     {
         DrawCircleV((Vector2){en.posX, en.posY}, en.radius, DARKBLUE);
@@ -87,10 +90,8 @@ void Game::draw() const
     Rectangle destRec = { player->posX, player->posY, frameWidth * 1.4f, frameHeight * 1.4f };
 
     // Origin of the texture (rotation/scale point), it's relative to destination rectangle size
-
     DrawTexturePro(player->tex, sourceRec, destRec, origin, Vector2Angle((Vector2){0.0f, 0.0f}, player->direction), WHITE);
 
-
     DrawText("Enemies left : ", 10, 10, 20, GREEN);
     DrawText(left.c_str(), 150, 10, 20, RED);
     if (player->fury >= 5) {
@@ -234,13 +235,10 @@ Game::shoot() const
             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}, add2, (en->radius * 2)))
-            {
-              std::cout << "hit enemy at " << en->posX << "|" << en->posY
-                        << std::endl;
+            { // enemy hit
               en->hp = 0;
               en->direction.x = (player->direction.x / 2);
               en->direction.y = (player->direction.y / 2);
-              // enemies->erase(en);
               player->victims++;
               player->fury++;
               DrawLineEx((Vector2){player->posX, player->posY}, add1, 10,
@@ -254,6 +252,7 @@ Game::shoot() const
               return (1);
             }
         }
+        // shotty cone
         DrawLineEx((Vector2){player->posX, player->posY}, add1, 10, ORANGE);
         DrawLineEx((Vector2){player->posX, player->posY},
                    Vector2Add((Vector2){player->posX, player->posY},
diff --git a/src/gameplay.hpp b/src/gameplay.hpp
index e325730..62da89f 100644
--- a/src/gameplay.hpp
+++ b/src/gameplay.hpp
@@ -9,6 +9,7 @@
 #ifndef GAMEPLAY_H_
 #define GAMEPLAY_H_
 
+#include "terrain.hpp"
 #include "window.hpp"
 #include "entity.hpp"
 
@@ -23,6 +24,8 @@ class Game {
 
     std::vector<Entity> * enemies;
 
+    std::vector<Terrain*> * terrain;
+
     Entity * player;
 
     std::string next; // next level
diff --git a/src/terrain.cpp b/src/terrain.cpp
new file mode 100644
index 0000000..692bb97
--- /dev/null
+++ b/src/terrain.cpp
@@ -0,0 +1,15 @@
+#include "terrain.hpp"
+
+#include <iostream>
+
+#include "raylib.h"
+
+Terrain::Terrain(int const & x, int const & y, int const & thick)
+    : x(x), y(y), thick(thick)
+{
+    std::cout << "\ncreate new terrain with parameters :\n" << this->x << " " << this->y << " " << this->thick << std::endl;
+}
+
+Terrain::~Terrain(void) {
+    std::cout << "destroy terrain\n";
+}
diff --git a/src/terrain.hpp b/src/terrain.hpp
new file mode 100644
index 0000000..6d7cf7e
--- /dev/null
+++ b/src/terrain.hpp
@@ -0,0 +1,16 @@
+#ifndef TERRAIN_H_
+#define TERRAIN_H_
+
+class Terrain {
+    public:
+        Terrain();
+        Terrain(int const & x, int const & y, int const & thick);
+        ~Terrain();
+
+        void draw() const ;
+        int x;
+        int y;
+        int thick;
+};
+
+#endif // TERRAIN_H_
-- 
cgit v1.2.3