Wrap perfectly the map on the screen, bricks won't teleport randomly anymore

This commit is contained in:
Yohann D'ANELLO
2020-11-26 21:59:48 +01:00
parent f2f34bfbc6
commit 3e7dabc94e
2 changed files with 12 additions and 1 deletions

View File

@ -31,9 +31,17 @@ class MapDisplay(Display):
smaxrow = min(smaxrow, self.height - 1)
smaxcol = self.pack.tile_width * self.map.width - \
(x + deltax) + self.width - 1
# Wrap perfectly the map according to the width of the tiles
pmincol = self.pack.tile_width * (pmincol // self.pack.tile_width)
smincol = self.pack.tile_width * (smincol // self.pack.tile_width)
smaxcol = self.pack.tile_width \
* (smaxcol // self.pack.tile_width + 1) - 1
smaxcol = min(smaxcol, self.width - 1)
pminrow = max(0, min(self.map.height, pminrow))
pmincol = max(0, min(self.pack.tile_width * self.map.width, pmincol))
self.pad.clear()
self.update_pad()
self.refresh_pad(self.pad, pminrow, pmincol, sminrow, smincol, smaxrow,