Skip to content

Commit

Permalink
2x scaled minimap.
Browse files Browse the repository at this point in the history
  • Loading branch information
Trey Tomes committed Jan 2, 2024
1 parent acf365b commit 333db60
Show file tree
Hide file tree
Showing 3 changed files with 35 additions and 13 deletions.
8 changes: 4 additions & 4 deletions main.ms
Original file line number Diff line number Diff line change
Expand Up @@ -82,10 +82,10 @@ Display = {}
Display.initialize = function()
MapDisplay = require("MapDisplay")

PIXEL_0 = 1
HUD = 1
HUD_BACK = 2

HUD = 2
HUD_BACK = 3
PIXEL_0 = 3

PARTICLES_0 = 4
PARTICLES_1 = 5
Expand Down Expand Up @@ -153,7 +153,7 @@ drawHUD = function(display, player)
// drawMiniMap()

statusBar = "HP: {0}/{1} LVL: {2} XP: {3}/{4} world: {5}".fill([player.currentHP, player.maxHP, player.level, player.xp, player.xpToNextLevel, Service.world.currentLevel])
statusBar = statusBar + " " * (constants.UI_DISPLAY_WIDTH - statusBar.len)
statusBar = statusBar + " " * (constants.UI_DISPLAY_WIDTH - statusBar.len - 10)

display.print(statusBar, 0, constants.UI_DISPLAY_YMAX, color.white, color.black)
display.print(" " * constants.UI_DISPLAY_WIDTH, 0, constants.UI_DISPLAY_HEIGHT, color.white, color.black)
Expand Down
2 changes: 1 addition & 1 deletion src/factories/behaviors.ms
Original file line number Diff line number Diff line change
Expand Up @@ -205,7 +205,7 @@ makeUserInput = function()
stack = entity.inventory.get(index)
if stack.count > 1 then
count = ui.selectInteger(1, stack.count, "How much?")
count = ui.selectInteger(1, stack.count, "How many?")
// Service.messages.report("You selected {0}.".fill([count]))
else
count = 1
Expand Down
38 changes: 30 additions & 8 deletions src/map.ms
Original file line number Diff line number Diff line change
Expand Up @@ -169,27 +169,49 @@ Map.drawTile = function(dsp, x, y, renderOffset=null)
end function
Map.drawMiniMap = function()
Display.pixels.drawRect constants.PIXEL_WIDTH - self.width - 2, constants.PIXEL_HEIGHT - self.height - 2, self.width + 2, self.height + 2, color.brown, 2
cellSize = 2
renderWidth = self.width * cellSize
renderHeight = self.height * cellSize
borderSize = 2
borderX = constants.PIXEL_WIDTH - renderWidth - borderSize * 2
borderY = constants.PIXEL_HEIGHT - renderHeight - borderSize * 2
borderWidth = renderWidth + borderSize * 2
borderHeight = renderHeight + borderSize * 2
Display.pixels.drawRect borderX, borderY, borderWidth, borderHeight, color.brown, borderSize
for y in range(0, self.height)
for x in range(0, self.width)
if self.getTile(x, y).hasBeenVisited then
tile = self.getTile(x, y)
tile = self.getTile(x, y)
rx = constants.PIXEL_WIDTH - (renderWidth - x * cellSize) - borderSize - 1
ry = constants.PIXEL_HEIGHT - (renderHeight - y * cellSize) - borderSize - 1
if tile.hasBeenVisited then
c = tile.foregroundColor.str()
Display.pixels.setPixel constants.PIXEL_WIDTH - (self.width - x) - 1, constants.PIXEL_HEIGHT - (self.height - y) - 1, c
// Display.pixels.setPixel rx, ry, c
Display.pixels.drawRect rx, ry, cellSize, cellSize, c, 1
else
c = color.gray
Display.pixels.setPixel constants.PIXEL_WIDTH - (self.width - x) - 1, constants.PIXEL_HEIGHT - (self.height - y) - 1, c
// Display.pixels.setPixel rx, ry, c
Display.pixels.drawRect rx, ry, cellSize, cellSize, c, 1
end if
end for
end for
for e in self.entities
x = e.position.x
y = e.position.y
ex = e.position.x
ey = e.position.y
if not self.isVisible(ex, ey) then
continue
end if
c = e.tile.foregroundColor.str()
Display.pixels.setPixel constants.PIXEL_WIDTH - (self.width - x) - 1, constants.PIXEL_HEIGHT - (self.height - y) - 1, c
rx = constants.PIXEL_WIDTH - (renderWidth - ex * cellSize) - borderSize - 1
ry = constants.PIXEL_HEIGHT - (renderHeight - ey * cellSize) - borderSize - 1
// Display.pixels.setPixel rx, ry, c
Display.pixels.drawRect rx, ry, cellSize, cellSize, c, 1
end for
end function
Expand Down

0 comments on commit 333db60

Please sign in to comment.