From 333db600a519a25236febe31d85c80251c5edb1c Mon Sep 17 00:00:00 2001 From: Trey Tomes Date: Tue, 2 Jan 2024 08:56:38 -0600 Subject: [PATCH] 2x scaled minimap. --- main.ms | 8 ++++---- src/factories/behaviors.ms | 2 +- src/map.ms | 38 ++++++++++++++++++++++++++++++-------- 3 files changed, 35 insertions(+), 13 deletions(-) diff --git a/main.ms b/main.ms index 805997d..d1e0622 100644 --- a/main.ms +++ b/main.ms @@ -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 @@ -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) diff --git a/src/factories/behaviors.ms b/src/factories/behaviors.ms index ef1c502..8f6ad1c 100644 --- a/src/factories/behaviors.ms +++ b/src/factories/behaviors.ms @@ -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 diff --git a/src/map.ms b/src/map.ms index 7e837c1..faa5ae8 100644 --- a/src/map.ms +++ b/src/map.ms @@ -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