summaryrefslogtreecommitdiffhomepage
path: root/Bullets.cpp
blob: 312e12edece183f03719251e00aba506451e1112 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
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;
    }
}