diff options
author | salaaad2 <arthurdurant263@gmail.com> | 2022-01-03 21:52:49 +0100 |
---|---|---|
committer | salaaad2 <arthurdurant263@gmail.com> | 2022-01-03 21:52:49 +0100 |
commit | 85823665568eb4e482c40c5eb3256d545d0dfde5 (patch) | |
tree | 9c5dd5bde3a49cc0565bdc13fd24c2715e4830c4 | |
parent | initial commit (diff) | |
download | threshold-85823665568eb4e482c40c5eb3256d545d0dfde5.tar.gz threshold-85823665568eb4e482c40c5eb3256d545d0dfde5.tar.bz2 threshold-85823665568eb4e482c40c5eb3256d545d0dfde5.tar.xz threshold-85823665568eb4e482c40c5eb3256d545d0dfde5.tar.zst threshold-85823665568eb4e482c40c5eb3256d545d0dfde5.zip |
add circles
-rw-r--r-- | src/gameplay.cpp | 14 | ||||
-rw-r--r-- | src/gameplay.hpp | 10 |
2 files changed, 18 insertions, 6 deletions
diff --git a/src/gameplay.cpp b/src/gameplay.cpp index 4368954..90b6603 100644 --- a/src/gameplay.cpp +++ b/src/gameplay.cpp @@ -1,5 +1,8 @@ #include "gameplay.hpp" +#include <iostream> + + Enemy::Enemy(void) { posX = GetRandomValue(0, SCREENWIDTH); @@ -12,12 +15,19 @@ Game::~Game() {} Game::Game(void) { - nEnemies = GetRandomValue(0, 15); + nEnemies = GetRandomValue(5, 15); - enemies = new Enemy[15]; + enemies = new std::vector<Enemy>(nEnemies); } void Game::start() const { + std::cout << "----- Gameplay: Start -----" << std::endl; + std::cout << "Gameplay: " << nEnemies << "enemies need to be spawned" << std::endl; + + for (auto & en : *enemies) + { + DrawCircleV(en.direction, 10, RED); + } } diff --git a/src/gameplay.hpp b/src/gameplay.hpp index 3b611fe..3c73d09 100644 --- a/src/gameplay.hpp +++ b/src/gameplay.hpp @@ -3,11 +3,13 @@ #include "window.hpp" +#include <vector> + class Enemy { - float posX; - float posY; - Vector2 direction; public: + float posX; + float posY; + Vector2 direction; Enemy(); ~Enemy(); }; @@ -15,7 +17,7 @@ class Enemy { class Game { int nEnemies; - Enemy * enemies; + std::vector<Enemy> * enemies; public: Game(); |