From: Randy McShandy Date: Thu, 26 Feb 2026 03:51:29 +0000 (-0600) Subject: Ensure player collision detection uses active map X-Git-Url: http://git.mcshandy.xyz/gitweb.cgi?a=commitdiff_plain;h=532bd743e08c66866455f53f953d4bb16e67500d;p=sumeriangame Ensure player collision detection uses active map --- diff --git a/main/assets.lua b/main/assets.lua index 14f6879..0a5c590 100644 --- a/main/assets.lua +++ b/main/assets.lua @@ -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) diff --git a/main/handlers.lua b/main/handlers.lua index 0af8f09..c730186 100644 --- a/main/handlers.lua +++ b/main/handlers.lua @@ -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 diff --git a/main/player.lua b/main/player.lua index c1d2b7a..84f1c19 100644 --- a/main/player.lua +++ b/main/player.lua @@ -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