aboutsummaryrefslogtreecommitdiffstats
path: root/src/gameplay.cpp
diff options
context:
space:
mode:
authorsalaaad2 <arthurdurant263@gmail.com>2022-01-03 22:10:27 +0100
committersalaaad2 <arthurdurant263@gmail.com>2022-01-03 22:10:27 +0100
commit0292e135be5f576d14e9589ad0ed8543a03b544c (patch)
treedc8b0ba9c0c566959ea47871119b56d3fd978a57 /src/gameplay.cpp
parentadd circles (diff)
downloadthreshold-0292e135be5f576d14e9589ad0ed8543a03b544c.tar.gz
threshold-0292e135be5f576d14e9589ad0ed8543a03b544c.tar.bz2
threshold-0292e135be5f576d14e9589ad0ed8543a03b544c.tar.xz
threshold-0292e135be5f576d14e9589ad0ed8543a03b544c.tar.zst
threshold-0292e135be5f576d14e9589ad0ed8543a03b544c.zip
balls move yknow
Diffstat (limited to '')
-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
+{
}