Line data Source code
1 : #include "physicssystem.h"
2 :
3 : #include "game.h"
4 :
5 5 : void PhysicsSystem::update() {
6 5 : for (auto& ph : game_.physics.values()) {
7 0 : if (ph.type == PhysicsType::Projectile) {
8 0 : ph.position += ph.velocity;
9 0 : ph.velocity *= 0.95;
10 : // TODO: detect collisions
11 : }
12 :
13 : // Update position of sprite
14 0 : auto& e = game_.entities[ph.entity];
15 0 : if (e.sprite) {
16 0 : auto& sprite = game_.sprites[e.sprite];
17 0 : sprite.position = (vec2i)ph.position;
18 : }
19 : }
20 5 : }
|