diff options
author | salaaad2 <arthurdurant263@gmail.com> | 2022-01-14 16:40:11 +0100 |
---|---|---|
committer | salaaad2 <arthurdurant263@gmail.com> | 2022-01-14 16:40:11 +0100 |
commit | 7a0ec30b5444b9f07ddeaa6943edaf5bd02e0349 (patch) | |
tree | a85c1a47e1f41c6c6530f3fe3cb6ce66a2ea61c7 | |
parent | strange behavior... I WILL find out whats going on ! (diff) | |
download | threshold-7a0ec30b5444b9f07ddeaa6943edaf5bd02e0349.tar.gz threshold-7a0ec30b5444b9f07ddeaa6943edaf5bd02e0349.tar.bz2 threshold-7a0ec30b5444b9f07ddeaa6943edaf5bd02e0349.tar.xz threshold-7a0ec30b5444b9f07ddeaa6943edaf5bd02e0349.tar.zst threshold-7a0ec30b5444b9f07ddeaa6943edaf5bd02e0349.zip |
enemy slingshot is functional
-rw-r--r-- | meta/maps/stage_2_start.bfm | 2 | ||||
-rw-r--r-- | src/gameplay.cpp | 23 | ||||
-rw-r--r-- | src/projectile.cpp | 3 | ||||
-rw-r--r-- | src/weapon.cpp | 2 | ||||
-rw-r--r-- | src/weapon.hpp | 16 | ||||
-rw-r--r-- | src/wp_enemyslingshot.cpp | 10 |
6 files changed, 29 insertions, 27 deletions
diff --git a/meta/maps/stage_2_start.bfm b/meta/maps/stage_2_start.bfm index c5af193..bde292a 100644 --- a/meta/maps/stage_2_start.bfm +++ b/meta/maps/stage_2_start.bfm @@ -1,5 +1,5 @@ BOSS 1 10 -ENEMIES 2 100 +ENEMIES 2 50 WAVES 1 2 NEXT stage_1_boss.bfm BACKGROUND ../meta/media/sprites/stage_1_bossbg.png diff --git a/src/gameplay.cpp b/src/gameplay.cpp index 44987c9..bfa9190 100644 --- a/src/gameplay.cpp +++ b/src/gameplay.cpp @@ -64,9 +64,7 @@ Game::Game(std::string const& path) : current(path) { InitAudioDevice(); AWeapon* shotty = new wp_shotty(SHOTTY_BANG, SHOTTY_RELOAD); - AWeapon* ar = new wp_assaultrifle(AR_BANG, - SHOTTY_RELOAD - ); + AWeapon* ar = new wp_assaultrifle(AR_BANG, SHOTTY_RELOAD); AWeapon* sling = new wp_enemysling(SHOTTY_BANG, SHOTTY_RELOAD); for (auto i = 0; i < nPerWave; i++) { @@ -151,14 +149,17 @@ void Game::draw() { if (player->fury >= 5) { DrawText("[E] FURY", SCREENWIDTH - 300, 10, 50, RED); } - for (auto i = 0; i < player->currentWeapon->barrel; i++) { // draw weapon ammo + for (auto i = 0; i < player->currentWeapon->barrel; + i++) { // draw weapon ammo DrawRectangle(40 + (i * 20), SCREENHEIGHT - 60, 10, 30, RED); } - if (enemies->at(0).hp >= 2) { // draw hp in boss stages + if (enemies->at(0).hp >= 2) { // draw hp in boss stages for (auto i = 0; i < enemies->size(); i++) { - for (auto j = 0; j < enemies->at(i).hp; j++) { - DrawRectangle(400 + (j * 40), 80 + (i * 40), 40, 30, - COOLPURPLE); + if (enemies->at(i).hp >= 2) { + for (auto j = 0; j < enemies->at(i).hp; j++) { + DrawRectangle(400 + (j * 40), 80 + (i * 40), 40, 30, + COOLPURPLE); + } } } } @@ -214,10 +215,12 @@ int Game::tick() { en->posY += 2.1f; en->direction.y += 0.1f; } - if ((GetRandomValue(0, 100) == 50) && (en->currentWeapon != - nullptr)) { + if ((GetRandomValue(0, 100) == 50) && + (en->currentWeapon != nullptr)) { std::cout << "spawn enemy" << std::endl; en->currentWeapon->bang(enemies, &(*en)); + nEnemies++; + return (0); } } else { if (en->posX >= SCREENWIDTH || en->posX <= 0 || diff --git a/src/projectile.cpp b/src/projectile.cpp index de7b10e..e65222e 100644 --- a/src/projectile.cpp +++ b/src/projectile.cpp @@ -6,7 +6,6 @@ Projectile::Projectile(Vector2 const& dir, Vector2 const& pos) Projectile::~Projectile() {} -Projectile * -Projectile::getProjectile() { +Projectile* Projectile::getProjectile() { return (this); } diff --git a/src/weapon.cpp b/src/weapon.cpp index a8553e3..4e56117 100644 --- a/src/weapon.cpp +++ b/src/weapon.cpp @@ -16,7 +16,7 @@ AWeapon::AWeapon(float const rg, double const& cd, const char* s, const char* r, - std::string const & nm) + std::string const& nm) : range(rg), damage(dmg), max(mag), cooldown(cd), name(nm) { shot = LoadSound(s); reload = LoadSound(r); diff --git a/src/weapon.hpp b/src/weapon.hpp index ad63344..d75d826 100644 --- a/src/weapon.hpp +++ b/src/weapon.hpp @@ -11,8 +11,8 @@ #include "raylib.h" -#include <vector> #include <iostream> +#include <vector> class Entity; @@ -31,13 +31,13 @@ class AWeapon { const std::string name; public: - AWeapon(float const rg, // range - unsigned int const& dmg, // damage - unsigned int const& mag, // mag capacity - double const& cooldown, // duh - const char* s, // shot sound path - const char* r, // reload sound path - std::string const & nm); // name + AWeapon(float const rg, // range + unsigned int const& dmg, // damage + unsigned int const& mag, // mag capacity + double const& cooldown, // duh + const char* s, // shot sound path + const char* r, // reload sound path + std::string const& nm); // name ~AWeapon(); virtual int bang(std::vector<Entity>* enemies, Entity* player) = 0; diff --git a/src/wp_enemyslingshot.cpp b/src/wp_enemyslingshot.cpp index ad113e8..068f404 100644 --- a/src/wp_enemyslingshot.cpp +++ b/src/wp_enemyslingshot.cpp @@ -8,22 +8,22 @@ #include "gameplay.hpp" wp_enemysling::wp_enemysling(const char* s, const char* r) - : AWeapon(300.0f, 10, 1, 0.0, s, r, "sling") {} + : AWeapon(300.0f, 10, 10, 0.0, s, r, "sling") {} int wp_enemysling::bang(std::vector<Entity>* enemies, Entity* baddie) { if (barrel == 0) { return (1); } else { barrel--; - PlaySound(shot); t = GetTime(); // enemysling spawns a new enemy every @reload seconds. thats it. // it's a slingshot // Entity en(1); - en.posX = 0; - en.posY = 0; - en.direction = (Vector2){1.0f, 1.0f}; + en.posX = baddie->posX + 10; + en.posY = baddie->posY + 10; + en.direction.x = baddie->direction.x * 2.0f; + en.direction.y = baddie->direction.y * 2.0f; en.radius = 20; en.currentWeapon = nullptr; en.idleTex = LoadTexture(SBIRE_TEX_IDLE); |