aboutsummaryrefslogtreecommitdiffstats
path: root/src/gameplay.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/gameplay.cpp')
-rw-r--r--src/gameplay.cpp34
1 files changed, 32 insertions, 2 deletions
diff --git a/src/gameplay.cpp b/src/gameplay.cpp
index 90b6603..56429d9 100644
--- a/src/gameplay.cpp
+++ b/src/gameplay.cpp
@@ -7,7 +7,13 @@ Enemy::Enemy(void)
{
posX = GetRandomValue(0, SCREENWIDTH);
posY = GetRandomValue(0, SCREENHEIGHT);
- direction = (Vector2){posX, posY};
+ if (static_cast<int>(posX) & 1)
+ {
+ direction = (Vector2){posX / 100, -posY / 100};
+ } else {
+ direction = (Vector2){-posX / 100, posY / 100};
+ }
+
}
Enemy::~Enemy() {}
@@ -24,10 +30,34 @@ void Game::start() const
{
std::cout << "----- Gameplay: Start -----" << std::endl;
std::cout << "Gameplay: " << nEnemies << "enemies need to be spawned" << std::endl;
+}
+
+void Game::draw() const
+{
+ for (auto & en : *enemies)
+ {
+ DrawCircleV((Vector2){en.posX, en.posY}, 10, RED);
+ }
+}
+
+void Game::tick() const
+{
for (auto & en : *enemies)
{
- DrawCircleV(en.direction, 10, RED);
+ if (en.posX >= SCREENWIDTH || en.posX <= 0)
+ {
+ en.direction.x = -en.direction.x;
+ }
+ if (en.posY >= SCREENHEIGHT || en.posY <= 0)
+ {
+ en.direction.y = -en.direction.y;
+ }
+ en.posX += en.direction.x;
+ en.posY += en.direction.y;
}
+}
+void Game::getKeys() const
+{
}