summaryrefslogtreecommitdiffhomepage
path: root/Bullets.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'Bullets.cpp')
-rw-r--r--Bullets.cpp21
1 files changed, 21 insertions, 0 deletions
diff --git a/Bullets.cpp b/Bullets.cpp
new file mode 100644
index 0000000..312e12e
--- /dev/null
+++ b/Bullets.cpp
@@ -0,0 +1,21 @@
+#include "Bullets.h"
+
+#include <vector>
+
+#include <raylib.h>
+
+
+void
+update(const float dt, std::vector<ConstantVelocityBullet>& bullets)
+{
+ auto it = bullets.begin();
+ while (it != bullets.end()) {
+ auto& bullet = *it;
+ bullet.position.x += bullet.velocity.x * dt;
+ bullet.position.y += bullet.velocity.y * dt;
+ if (bullet.position.y > 800)
+ it = bullets.erase(it);
+ else
+ ++it;
+ }
+}