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)
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)
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