Removed entity management from Game, refactored Map to MapLoader and added Map to manage world

This commit is contained in:
2019-09-27 14:30:23 -05:00
parent 1bfc6e6929
commit b091a489af
20 changed files with 260 additions and 239 deletions

View File

@@ -1,8 +1,8 @@
class IMICFPS
class CollisionManager
attr_reader :game_state, :collisions
def initialize(game_state:)
@game_state = game_state
attr_reader :map, :collisions
def initialize(map:)
@map = map
@collisions = {}
@aabb_tree = AABBTree.new
@@ -14,7 +14,7 @@ class IMICFPS
end
def update
@game_state.entities.each do |entity|
@map.entities.each do |entity|
next unless entity.is_a?(Entity)
next unless node = @aabb_tree.objects[entity]
@@ -42,7 +42,7 @@ class IMICFPS
@collisions.clear
broadphase = {}
@game_state.entities.each do |entity|
@map.entities.each do |entity|
next unless entity.collidable?
next if entity.collision == :static # Only dynamic entities can be resolved