diff options
author | Aki <please@ignore.pl> | 2022-04-17 14:03:10 +0200 |
---|---|---|
committer | Aki <please@ignore.pl> | 2022-04-17 14:03:10 +0200 |
commit | 85119293fe4f6814d44e8ee3f182c40876829128 (patch) | |
tree | 646c7b0f1be3aebed67a8b019092c72134087368 /Bullets.cpp | |
parent | a0705fcd7b51401b45ff9960a81c08520f142230 (diff) | |
download | bullethell2022-85119293fe4f6814d44e8ee3f182c40876829128.zip bullethell2022-85119293fe4f6814d44e8ee3f182c40876829128.tar.gz bullethell2022-85119293fe4f6814d44e8ee3f182c40876829128.tar.bz2 |
Added sample bullet and some generation
Diffstat (limited to 'Bullets.cpp')
-rw-r--r-- | Bullets.cpp | 21 |
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; + } +} |