]> git.mcshandy.xyz Git - sumeriangame/commitdiff
Ensure player collision detection uses active map view-switch
authorRandy McShandy <randy@mcshandy.xyz>
Thu, 26 Feb 2026 03:51:29 +0000 (21:51 -0600)
committerRandy McShandy <randy@mcshandy.xyz>
Thu, 26 Feb 2026 03:51:29 +0000 (21:51 -0600)
main/assets.lua
main/handlers.lua
main/player.lua

index 14f6879fa0932b11c9037c555027a3da17ec69b3..0a5c590831ee397f77b126d8b7390f64bbaef00b 100644 (file)
@@ -48,7 +48,6 @@ function assets.integrate_object_layers(pmap)
         pmap[ov.name] = {}
         pmap[ov.name].vec = vector.new_xy(ov.x, ov.y)
         pmap[ov.name].name = ov.name
-        utils.shallow_dump('ovec', ov)
 
         if object and utils.flag_set(object.properties, PropertyFlag.HasSprite) then
           object.image = love.graphics.newImage(object.path)
index 0af8f0900f4093dc7335865672456ce9da6313ee..c7301865f68f7391b04a71d69135708a1750021c 100644 (file)
@@ -26,5 +26,8 @@ function love.handlers.movement_control(key, value)
   love.audio.play(assets.walk_sfx[n])
 end
 
+function love.handlers.collision(focus, pos)
+end
+
 function love.handlers.collision(collider, tile)
 end
index c1d2b7a7c7947267243ff3e451415ec2db7df039..84f1c194f6c67dfe8d32d38219d9461ea8c50319 100644 (file)
@@ -14,8 +14,8 @@ function player_module.init_controls(player_obj, active_map)
 
   player_obj.movement_control = function(self, key, value)
     -- Calculate target tile coordinates (current tile + direction)
-    local current_tile_x = math.floor(self.vec.x / active_map.tilewidth)
-    local current_tile_y = math.floor(self.vec.y / active_map.tileheight)
+    local current_tile_x = math.floor(self.vec.x / render.map.active_map.tilewidth)
+    local current_tile_y = math.floor(self.vec.y / render.map.active_map.tileheight)
 
     -- Direction vectors for each heading
     local dx = math.floor(math.cos(value.heading) + 0.5)
@@ -26,10 +26,10 @@ function player_module.init_controls(player_obj, active_map)
     local target_tile_x = current_tile_x + dx
     local target_tile_y = current_tile_y + dy
 
-    if not collision.is_tile_collidable(active_map, target_tile_x + 1, target_tile_y + 1) then
+    if not collision.is_tile_collidable(render.map.active_map, target_tile_x + 1, target_tile_y + 1) then
       -- Move to target tile (convert back to world coordinates)
-      self.vec.x = target_tile_x * active_map.tilewidth
-      self.vec.y = target_tile_y * active_map.tileheight
+      self.vec.x = target_tile_x * render.map.active_map.tilewidth
+      self.vec.y = target_tile_y * render.map.active_map.tileheight
     else
       love.event.push('collision', player_module.player, { x = current_tile_x + 1, y = current_tile_y + 1 })
     end