summaryrefslogtreecommitdiffstats
path: root/src/World.cpp
diff options
context:
space:
mode:
authorLaG1924 <12997935+LaG1924@users.noreply.github.com>2018-08-08 21:39:14 +0200
committerLaG1924 <12997935+LaG1924@users.noreply.github.com>2018-08-08 21:39:14 +0200
commit32d836cb88db783c807c228fa2932ddecc1a8d07 (patch)
tree0fa82f23c098b2caf2c7996affb0068d499ee4fa /src/World.cpp
parentDisabled collisions for double plants and flowers (diff)
downloadAltCraft-32d836cb88db783c807c228fa2932ddecc1a8d07.tar
AltCraft-32d836cb88db783c807c228fa2932ddecc1a8d07.tar.gz
AltCraft-32d836cb88db783c807c228fa2932ddecc1a8d07.tar.bz2
AltCraft-32d836cb88db783c807c228fa2932ddecc1a8d07.tar.lz
AltCraft-32d836cb88db783c807c228fa2932ddecc1a8d07.tar.xz
AltCraft-32d836cb88db783c807c228fa2932ddecc1a8d07.tar.zst
AltCraft-32d836cb88db783c807c228fa2932ddecc1a8d07.zip
Diffstat (limited to '')
-rw-r--r--src/World.cpp17
1 files changed, 17 insertions, 0 deletions
diff --git a/src/World.cpp b/src/World.cpp
index 718f54c..251890b 100644
--- a/src/World.cpp
+++ b/src/World.cpp
@@ -201,6 +201,23 @@ void World::UpdatePhysics(float delta) {
entitiesMutex.lock();
for (auto& it : entities) {
+ if (it.isFlying) {
+ VectorF newPos = it.pos + VectorF(it.vel.x, it.vel.y, it.vel.z) * delta;
+ auto coll = testCollision(it.width, it.height, newPos);
+ if (coll.isCollide) {
+ it.vel = VectorF(0, 0, 0);
+ }
+ else {
+ it.pos = newPos;
+ }
+
+ const float AirResistance = 10.0f;
+ VectorF resistForce = it.vel * AirResistance * delta * -1.0;
+ it.vel = it.vel + resistForce;
+
+ continue;
+ }
+
{ //Vertical velocity
it.vel.y -= it.gravity * delta;
VectorF newPos = it.pos + VectorF(0, it.vel.y, 0) * delta;