diff --git a/imperium-porcorum.love/scenes/worldmap/init.lua b/imperium-porcorum.love/scenes/worldmap/init.lua index 25d5594..6c0f827 100644 --- a/imperium-porcorum.love/scenes/worldmap/init.lua +++ b/imperium-porcorum.love/scenes/worldmap/init.lua @@ -14,6 +14,7 @@ function WorldMap:new() self.cursor.x, self.cursor.y = 0, 0 self.cursor.drawx, self.cursor.drawy = 0, 0 self.cursor.canMove = true + self.cursor.dotAtPoint = nil self:addLevels() self:register() @@ -71,8 +72,10 @@ function WorldMap:update(dt) end if (self.cursor.drawy == self.cursor.y) and (self.cursor.drawx == self.cursor.x) then - self.cursor.canMove = true + self.cursor.canMove = true end + + self.cursor.dotAtPoint = self:getDotAtPoint(self.cursor.x, self.cursor.y) end function WorldMap:mousemoved(x, y) @@ -88,6 +91,17 @@ function WorldMap:mousemoved(x, y) end end +function WorldMap:getDotAtPoint(x, y) + local dot = nil + for i,v in ipairs(self.leveldots) do + if (v.data.x == x) and (v.data.y == y) then + dot = v + end + end + + return dot +end + function WorldMap:draw() self.assets:drawImage("background", 0, 0) @@ -95,6 +109,10 @@ function WorldMap:draw() v:draw() end + if (self.cursor.dotAtPoint ~= nil) then + self.cursor.dotAtPoint:drawName() + end + love.graphics.draw(self.banner, 0, 8) local x, y = 16 + self.cursor.drawx * 16 - CURSOR_PADDING, 48 + self.cursor.drawy * 16 - CURSOR_PADDING diff --git a/imperium-porcorum.love/scenes/worldmap/leveldot.lua b/imperium-porcorum.love/scenes/worldmap/leveldot.lua index 537774f..fc82792 100644 --- a/imperium-porcorum.love/scenes/worldmap/leveldot.lua +++ b/imperium-porcorum.love/scenes/worldmap/leveldot.lua @@ -4,7 +4,7 @@ function LevelDot:new(scene, levelname) self.scene = scene self.data = require("datas.levels." .. levelname) self.isActive = self.data.isActive or true - + self:register() end @@ -20,4 +20,9 @@ function LevelDot:draw() end end +function LevelDot:drawName() + local _, w, h = 0, core.screen:getDimensions() + love.graphics.printf(self.data.name, 0, h-16, w, "center") +end + return LevelDot