Add new getTileOnCoord method

New method uses pygame.rect.collidepoint method which doesn't need exact tile's coordinates
This commit is contained in:
Michał Czekański 2020-04-26 18:42:00 +02:00
parent 2ba090b2d4
commit 013e8b524d
2 changed files with 11 additions and 3 deletions

View File

@ -158,9 +158,8 @@ class AutomaticMovement:
# TODO: Nie znajduje terraina na ktorym stoi player
if terrainTile is None:
return 0
# return terrainTile.cost
return 0
return 1000
return terrainTile.cost
def priority(self, elem: AStarNode):
coordsWithUiOffset = [elem.state[0] + self.leftUiWidth, elem.state[1]]

View File

@ -119,6 +119,15 @@ class Map:
result = tile
return result
def getTileOnCoord(self, coord):
result = None
for tile in self.terrainTilesList:
if tile.rect.collidepoint(coord[0], coord[1]):
result = tile
break
return result
# TODO: REMOVE DONT ADD
def addEntity(self, entity, DONTADD=False):
self.screen.draw(entity, Locations.MAP, 0, 0)