fix small bug
This commit is contained in:
parent
34d7984b73
commit
dba353f826
3
map.py
3
map.py
|
@ -79,8 +79,7 @@ class Tile:
|
|||
this Tile is visible.
|
||||
"""
|
||||
try:
|
||||
# this is unsafe, do something different as default
|
||||
return self.textures[list(self.textures.keys())[0]].texture
|
||||
return self.textures[0]
|
||||
except IndexError:
|
||||
raise TileError("no textures to render!")
|
||||
|
||||
|
|
33
render.py
33
render.py
|
@ -21,13 +21,6 @@ class Renderer:
|
|||
if i.ttype == "standard":
|
||||
i.update(self.tiles)
|
||||
|
||||
def inViewport(self, pos):
|
||||
if pos[0] < 0 or pos[0] > self.viewport[0] - 1:
|
||||
return False
|
||||
if pos[1] < 0 or pos[1] > self.viewport[1] - 1:
|
||||
return False
|
||||
return True
|
||||
|
||||
def selectForRendering(self):
|
||||
"""
|
||||
Returns what tiles are in the viewport.
|
||||
|
@ -52,32 +45,30 @@ class Renderer:
|
|||
|
||||
return tilesInScene
|
||||
|
||||
<<<<<<< HEAD
|
||||
def render(self):
|
||||
board = [ ["."] * 24 ] * 80
|
||||
board = [["." for i in range(24)] for i in range(80)]
|
||||
|
||||
toRender = self.selectForRendering()
|
||||
|
||||
for tile in toRender:
|
||||
rendered = tile.render()
|
||||
print(rendered)
|
||||
coords = tile.getCoords()
|
||||
print(len(rendered), len(rendered[0]))
|
||||
for j in range(len(rendered)):
|
||||
for i in range(len(rendered[0])):
|
||||
print(coords[0], coords[1])
|
||||
print(i, j)
|
||||
board[i + coords[0]][j + coords[1]] = rendered[i][j]
|
||||
for j in range(len(rendered[0])):
|
||||
for i in range(len(rendered)):
|
||||
board[i + coords[0]][j + coords[1]] = rendered[j][i]
|
||||
|
||||
return board
|
||||
|
||||
def finalRender(self):
|
||||
def finalRender(self, rendered=None):
|
||||
if not rendered:
|
||||
rendered = self.render()
|
||||
|
||||
for j in range(self.viewport[1] - 1):
|
||||
for i in range(len(rendered[0])):
|
||||
buf = []
|
||||
for i in range(self.viewport[0] - 1):
|
||||
buf.append(rendered[i][j])
|
||||
for j in range(len(rendered)):
|
||||
buf.append(rendered[j][i])
|
||||
print(''.join(buf))
|
||||
|
||||
|
||||
|
||||
=======
|
||||
>>>>>>> parent of 34d7984 (demo under construction)
|
||||
|
|
Loading…
Reference in New Issue