aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--CMakeLists.txt12
-rw-r--r--src/entity.cpp8
-rw-r--r--src/gameplay.cpp7
-rw-r--r--src/main.cpp4
-rw-r--r--src/weapon.hpp2
-rw-r--r--src/wp_assaultrifle.cpp2
-rw-r--r--src/wp_assaultrifle.hpp2
-rw-r--r--src/wp_enemyslingshot.cpp2
-rw-r--r--src/wp_enemyslingshot.hpp2
-rw-r--r--src/wp_nadelauncher.cpp1
-rw-r--r--src/wp_nadelauncher.hpp2
-rw-r--r--src/wp_shotty.cpp2
12 files changed, 31 insertions, 15 deletions
diff --git a/CMakeLists.txt b/CMakeLists.txt
index e1c1318..287d457 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -19,7 +19,17 @@ add_executable(${PROJECT_NAME}
src/terrain.cpp
src/entity.cpp)
-target_link_libraries(${PROJECT_NAME} raylib m pthread dl)
+target_link_libraries(${PROJECT_NAME}
+ raylib
+ m
+ pthread
+ dl
+)
+
+target_compile_options(${PROJECT_NAME}
+ PRIVATE "-O3"
+ PRIVATE "-march=native"
+)
# Checks if OSX and links appropriate frameworks (only required on MacOS)
if (APPLE)
diff --git a/src/entity.cpp b/src/entity.cpp
index 05dc270..409b67f 100644
--- a/src/entity.cpp
+++ b/src/entity.cpp
@@ -43,4 +43,10 @@ Entity::Entity(int const& h) : hp(h) {
threshold = false;
}
-Entity::~Entity() {}
+Entity::~Entity()
+{
+ for (auto it = wp.begin(); it != wp.end(); ++it)
+ {
+ delete it->second;
+ }
+}
diff --git a/src/gameplay.cpp b/src/gameplay.cpp
index 0e089ad..b42daee 100644
--- a/src/gameplay.cpp
+++ b/src/gameplay.cpp
@@ -168,10 +168,6 @@ void Game::draw() {
i++) { // draw weapon ammo
DrawRectangle(40 + (i * 20), SCREENHEIGHT - 60, 10, 30, RED);
}
-
- for (auto& pr : *projectiles) {
- DrawCircle(pr.posX, pr.posY, pr.radius, COOLPURPLE);
- }
}
// progress the game & check for player death
@@ -333,9 +329,6 @@ int Game::shoot() const {
return (0);
}
player->currentWeapon->bang(enemies, player);
- if (player->currentWeapon->hasProjectiles) {
- projectiles->push_back(player->currentWeapon->getProjectile());
- }
if (player->currentWeapon->empty == true) {
player->reloadTime = GetTime();
}
diff --git a/src/main.cpp b/src/main.cpp
index cb0894e..409c86e 100644
--- a/src/main.cpp
+++ b/src/main.cpp
@@ -84,12 +84,12 @@ int main(void) {
next += game->getNext();
saveOut << game->getCurrent();
- delete game;
CloseAudioDevice();
- std::cout << "next level " << next << std::endl;
if (game->getNext() != "0") {
+ delete game;
game = new Game(next);
gs = GAMEPLAY;
+ std::cout << "next level " << next << std::endl;
}
}
break;
diff --git a/src/weapon.hpp b/src/weapon.hpp
index 5e8fde4..dcd4005 100644
--- a/src/weapon.hpp
+++ b/src/weapon.hpp
@@ -42,7 +42,7 @@ class AWeapon {
const char* r, // reload sound path
std::string const& nm, // name
bool const& hasProj); // projectiles ? yea/nay
- ~AWeapon();
+ virtual ~AWeapon();
virtual int bang(std::vector<Entity>* enemies, Entity* player) = 0;
void refill();
diff --git a/src/wp_assaultrifle.cpp b/src/wp_assaultrifle.cpp
index f985d78..24b4c21 100644
--- a/src/wp_assaultrifle.cpp
+++ b/src/wp_assaultrifle.cpp
@@ -9,6 +9,8 @@
wp_assaultrifle::wp_assaultrifle(const char* s, const char* r)
: AWeapon(300.0f, 1, 30, 0.0, s, r, "ar", false) {}
+wp_assaultrifle::~wp_assaultrifle() {}
+
int wp_assaultrifle::bang(std::vector<Entity>* enemies, Entity* player) {
if (barrel == 0) {
return (1);
diff --git a/src/wp_assaultrifle.hpp b/src/wp_assaultrifle.hpp
index 9c66d91..02855df 100644
--- a/src/wp_assaultrifle.hpp
+++ b/src/wp_assaultrifle.hpp
@@ -14,7 +14,7 @@
class wp_assaultrifle : public AWeapon {
public:
wp_assaultrifle(const char* s, const char* r);
- ~wp_assaultrifle();
+ virtual ~wp_assaultrifle();
int bang(std::vector<Entity>* enemies, Entity* player);
Projectile const& getProjectile() const;
diff --git a/src/wp_enemyslingshot.cpp b/src/wp_enemyslingshot.cpp
index 2a212d6..3aa7d4b 100644
--- a/src/wp_enemyslingshot.cpp
+++ b/src/wp_enemyslingshot.cpp
@@ -10,6 +10,8 @@
wp_enemysling::wp_enemysling(const char* s, const char* r)
: AWeapon(300.0f, 10, 10, 0.0, s, r, "sling", false) {}
+wp_enemysling::~wp_enemysling() {}
+
int wp_enemysling::bang(std::vector<Entity>* enemies, Entity* baddie) {
if (barrel == 0) {
return (1);
diff --git a/src/wp_enemyslingshot.hpp b/src/wp_enemyslingshot.hpp
index 92fff7f..f481b62 100644
--- a/src/wp_enemyslingshot.hpp
+++ b/src/wp_enemyslingshot.hpp
@@ -14,7 +14,7 @@
class wp_enemysling : public AWeapon {
public:
wp_enemysling(const char* s, const char* r);
- ~wp_enemysling();
+ virtual ~wp_enemysling();
int bang(std::vector<Entity>* enemies, Entity* player);
Projectile const& getProjectile() const;
diff --git a/src/wp_nadelauncher.cpp b/src/wp_nadelauncher.cpp
index 7352b42..224b0a6 100644
--- a/src/wp_nadelauncher.cpp
+++ b/src/wp_nadelauncher.cpp
@@ -9,6 +9,7 @@
wp_nadelauncher::wp_nadelauncher(const char* s, const char* r)
: AWeapon(300.0f, 1, 30, 0.0, s, r, "nade", true) {}
+wp_nadelauncher::~wp_nadelauncher() {}
int wp_nadelauncher::bang(std::vector<Entity>* enemies, Entity* player) {
if (barrel == 0) {
diff --git a/src/wp_nadelauncher.hpp b/src/wp_nadelauncher.hpp
index 2619936..4a68e2c 100644
--- a/src/wp_nadelauncher.hpp
+++ b/src/wp_nadelauncher.hpp
@@ -14,7 +14,7 @@
class wp_nadelauncher : public AWeapon {
public:
wp_nadelauncher(const char* s, const char* r);
- ~wp_nadelauncher();
+ virtual ~wp_nadelauncher();
int bang(std::vector<Entity>* enemies, Entity* player);
Projectile const& getProjectile() const;
diff --git a/src/wp_shotty.cpp b/src/wp_shotty.cpp
index f314e54..08f7b71 100644
--- a/src/wp_shotty.cpp
+++ b/src/wp_shotty.cpp
@@ -9,6 +9,8 @@
wp_shotty::wp_shotty(const char* s, const char* r)
: AWeapon(100.0f, 3, 10, 0.5, s, r, "shotty", false) {}
+wp_shotty::~wp_shotty() {}
+
int wp_shotty::bang(std::vector<Entity>* enemies, Entity* player) {
if (barrel == 0 || GetTime() < (t + cooldown)) {
return (1);