Fixed abysmal draw method
This commit is contained in:
parent
e66b0d4a59
commit
1eb75fc354
@ -88,27 +88,27 @@ class Map:
|
|||||||
for col, tile in enumerate(tiles):
|
for col, tile in enumerate(tiles):
|
||||||
if tile == 's':
|
if tile == 's':
|
||||||
object = TerrainTile(col, row, 'sand.png', self.tileSize, 15)
|
object = TerrainTile(col, row, 'sand.png', self.tileSize, 15)
|
||||||
self.screen.draw(object, Locations.MAP)
|
self.screen.addSprite(object, Locations.MAP)
|
||||||
self.terrainTilesList.append(object)
|
self.terrainTilesList.append(object)
|
||||||
elif tile == ',':
|
elif tile == ',':
|
||||||
object = TerrainTile(col, row, 'floor.png', self.tileSize, 0)
|
object = TerrainTile(col, row, 'floor.png', self.tileSize, 0)
|
||||||
self.screen.draw(object, Locations.MAP)
|
self.screen.addSprite(object, Locations.MAP)
|
||||||
self.terrainTilesList.append(object)
|
self.terrainTilesList.append(object)
|
||||||
elif tile == '.':
|
elif tile == '.':
|
||||||
object = TerrainTile(col, row, 'grass.png', self.tileSize, 10)
|
object = TerrainTile(col, row, 'grass.png', self.tileSize, 10)
|
||||||
self.screen.draw(object, Locations.MAP)
|
self.screen.addSprite(object, Locations.MAP)
|
||||||
self.terrainTilesList.append(object)
|
self.terrainTilesList.append(object)
|
||||||
elif tile == 'c':
|
elif tile == 'c':
|
||||||
object = TerrainTile(col, row, 'clay.png', self.tileSize, 20)
|
object = TerrainTile(col, row, 'clay.png', self.tileSize, 20)
|
||||||
self.screen.draw(object, Locations.MAP)
|
self.screen.addSprite(object, Locations.MAP)
|
||||||
self.terrainTilesList.append(object)
|
self.terrainTilesList.append(object)
|
||||||
elif tile == 'x':
|
elif tile == 'x':
|
||||||
object = TerrainTile(col, row, 'water.png', self.tileSize, 0)
|
object = TerrainTile(col, row, 'water.png', self.tileSize, 0)
|
||||||
self.screen.draw(object, Locations.MAP)
|
self.screen.addSprite(object, Locations.MAP)
|
||||||
self.collidables.add(object)
|
self.collidables.add(object)
|
||||||
elif tile == 'w':
|
elif tile == 'w':
|
||||||
object = TerrainTile(col, row, 'wall.png', self.tileSize, 0)
|
object = TerrainTile(col, row, 'wall.png', self.tileSize, 0)
|
||||||
self.screen.draw(object, Locations.MAP)
|
self.screen.addSprite(object, Locations.MAP)
|
||||||
self.collidables.add(object)
|
self.collidables.add(object)
|
||||||
|
|
||||||
def getEntityOnCoord(self, coord):
|
def getEntityOnCoord(self, coord):
|
||||||
@ -137,7 +137,7 @@ class Map:
|
|||||||
# TODO: REMOVE DONT ADD
|
# TODO: REMOVE DONT ADD
|
||||||
def addEntity(self, entity, DONTADD=False):
|
def addEntity(self, entity, DONTADD=False):
|
||||||
# TODO: This method should set entities coords
|
# TODO: This method should set entities coords
|
||||||
self.screen.draw(entity, Locations.MAP)
|
self.screen.addSprite(entity, Locations.MAP)
|
||||||
# dodajemy bo wszystkie entity są kolizyjne
|
# dodajemy bo wszystkie entity są kolizyjne
|
||||||
self.collidables.add(entity)
|
self.collidables.add(entity)
|
||||||
if not DONTADD:
|
if not DONTADD:
|
||||||
|
@ -47,19 +47,13 @@ class Screen:
|
|||||||
|
|
||||||
return result
|
return result
|
||||||
|
|
||||||
# method to draw a sprite. Location param specifies where to draw the item (Locations enum)
|
def addSprite(self, sprite, location):
|
||||||
# TODO: Retarded
|
"""
|
||||||
def draw(self, sprite, location, posX=0, posY=0):
|
Adds a sprite to a screen at a given location
|
||||||
# TODO: Screen cannot alter sprites position!!
|
:type location: Locations
|
||||||
from entities.Entity import Entity
|
:param sprite: A sprite to add.
|
||||||
# For UI, Map, and other sprites
|
:param location: Where should the sprite be displayed
|
||||||
if type(sprite) is not Entity:
|
"""
|
||||||
sprite.rect.x += posX
|
|
||||||
sprite.rect.y += posY
|
|
||||||
# For entities
|
|
||||||
else:
|
|
||||||
sprite.setCoords((posX, posY), True)
|
|
||||||
|
|
||||||
if location.value is Locations.RIGHT_UI.value:
|
if location.value is Locations.RIGHT_UI.value:
|
||||||
sprite.rect.x += self.mapCoord + self.mapSize
|
sprite.rect.x += self.mapCoord + self.mapSize
|
||||||
elif location.value == Locations.MAP.value:
|
elif location.value == Locations.MAP.value:
|
||||||
@ -78,14 +72,14 @@ class Screen:
|
|||||||
def __initUi__(self):
|
def __initUi__(self):
|
||||||
self.ui = Ui(self.getUiWidth(Locations.RIGHT_UI), self.getUiWidth(Locations.LEFT_UI), self.winY,
|
self.ui = Ui(self.getUiWidth(Locations.RIGHT_UI), self.getUiWidth(Locations.LEFT_UI), self.winY,
|
||||||
self.gameObject.ingameTimer)
|
self.gameObject.ingameTimer)
|
||||||
self.draw(self.ui.timerTextView, Locations.LEFT_UI)
|
self.addSprite(self.ui.timerTextView, Locations.LEFT_UI)
|
||||||
self.draw(self.ui.isDayTextView, Locations.LEFT_UI)
|
self.addSprite(self.ui.isDayTextView, Locations.LEFT_UI)
|
||||||
self.draw(self.ui.console, Locations.LEFT_UI)
|
self.addSprite(self.ui.console, Locations.LEFT_UI)
|
||||||
self.draw(self.ui.healthTextView, Locations.RIGHT_UI)
|
self.addSprite(self.ui.healthTextView, Locations.RIGHT_UI)
|
||||||
self.draw(self.ui.healthBar, Locations.RIGHT_UI)
|
self.addSprite(self.ui.healthBar, Locations.RIGHT_UI)
|
||||||
self.draw(self.ui.hungerTextView, Locations.RIGHT_UI)
|
self.addSprite(self.ui.hungerTextView, Locations.RIGHT_UI)
|
||||||
self.draw(self.ui.hungerBar, Locations.RIGHT_UI)
|
self.addSprite(self.ui.hungerBar, Locations.RIGHT_UI)
|
||||||
self.draw(self.ui.staminaTextView, Locations.RIGHT_UI)
|
self.addSprite(self.ui.staminaTextView, Locations.RIGHT_UI)
|
||||||
self.draw(self.ui.staminaBar, Locations.RIGHT_UI)
|
self.addSprite(self.ui.staminaBar, Locations.RIGHT_UI)
|
||||||
self.draw(self.ui.thirstTextView, Locations.RIGHT_UI)
|
self.addSprite(self.ui.thirstTextView, Locations.RIGHT_UI)
|
||||||
self.draw(self.ui.thirstBar, Locations.RIGHT_UI)
|
self.addSprite(self.ui.thirstBar, Locations.RIGHT_UI)
|
||||||
|
Loading…
Reference in New Issue
Block a user