Skip to content

Commit

Permalink
Scrolling TODOs.
Browse files Browse the repository at this point in the history
  • Loading branch information
Trey Tomes committed Dec 20, 2023
1 parent 79e5420 commit 99da861
Show file tree
Hide file tree
Showing 3 changed files with 35 additions and 6 deletions.
6 changes: 4 additions & 2 deletions main.ms
Original file line number Diff line number Diff line change
Expand Up @@ -201,11 +201,12 @@ main = function()

Display.clear()

Service.world.map.clearScreen(Display.map)
Service.world.map.clear(Display.map)
// Service.world.map.draw_v2(Display.map)
Service.world.map.draw_v1(Display.map, Service.world.player, renderOffset)
drawEntities(Display.map, Service.world.map, renderOffset)
Display.map.flip
Display.map.setCell 5, 5, "*", color.red, color.blue
// Display.map.setCell 5, 5, "*", color.red, color.blue

drawHUD(Display.hud, Service.world.player)

Expand Down Expand Up @@ -247,6 +248,7 @@ main = function()
Service.messages.report("YOU ARE DEAD!")
end if


Service.world.map.draw_v1(Display.map, Service.world.player, renderOffset)
drawEntities(Display.map, Service.world.map, renderOffset)
Display.map.flip
Expand Down
14 changes: 14 additions & 0 deletions src/MapDisplay.ms
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,20 @@ MapDisplay.flip = function()
return self
end function

MapDisplay.scrollTo = function(x, y)
self.display0.scrollX = x
self.display0.scrollY = y

self.display0Back.scrollX = x
self.display0Back.scrollY = y

self.display1.scrollX = x
self.display1.scrollY = y

self.display1Back.scrollX = x
self.display1Back.scrollY = y
end function

MapDisplay.setCellBackColor = function(x, y, backColor)
if backColor isa Color then
backColor = backColor.str()
Expand Down
21 changes: 17 additions & 4 deletions src/map.ms
Original file line number Diff line number Diff line change
Expand Up @@ -118,19 +118,23 @@ Map.findHiddenSpawnPoint = function()
end while
end function
Map.clearScreen = function(dsp)
Map.clear = function(dsp)
for y in range(0, SCREEN_MAX_Y)
for x in range(0, SCREEN_MAX_X)
dsp.setCell x, y, "#", color.black, color.gray
end for
end for
end function
Map.drawTile = function(dsp, x, y, renderOffset)
Map.drawTile = function(dsp, x, y, renderOffset=null)
//if self.isEntityAt(point.make(x, y)) then return
rx = renderOffset.x + x
ry = renderOffset.y + y
rx = x
ry = y
if renderOffset != null then
rx += renderOffset.x
ry += renderOffset.y
end if
if not math.isInRange(rx, 0, SCREEN_MAX_X) or not math.isInRange(ry, 0, SCREEN_MAX_Y) then
return
Expand Down Expand Up @@ -162,6 +166,15 @@ Map.draw_v1 = function(display, player, renderOffset)
end for
end function
// In this version we draw the entire map to the TileDisplay, then use built-in functions to scroll the map later on.
Map.draw_v2 = function(dsp)
for y in range(0, self.height - 1)
for x in range(0, self.width - 1)
self.drawTile dsp, x, y
end for
end for
end function
Map.getDrawInfo = function(display, x, y, renderOffset)
//if self.isEntityAt(point.make(x, y)) then return
Expand Down

0 comments on commit 99da861

Please sign in to comment.