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