PhysicsManager now has a job, CollisionManager enabled, using Player velocity instead of position for movement controls, added Entity drag, added spaces

This commit is contained in:
2019-08-09 08:27:34 -05:00
parent 3b662090fc
commit f84b680de5
5 changed files with 61 additions and 42 deletions

View File

@@ -10,9 +10,27 @@ class IMICFPS
resolve(entity, other)
end
end
simulate
end
def resolve(entity, other)
if other.is_a?(Terrain)
entity.velocity.y = 0 if entity.velocity.y < 0
else
entity.velocity.y = other.velocity.y if other.velocity.y < entity.velocity.y && entity.velocity.y < 0
end
end
def simulate
@collision_manager.game_state.entities.each do |entity|
entity.velocity.x *= entity.drag
entity.velocity.z *= entity.drag
entity.position.x += entity.velocity.x * entity.delta_time
entity.position.y += entity.velocity.y * entity.delta_time
entity.position.z += entity.velocity.z * entity.delta_time
end
end
end
end