Add new getTileOnCoord method
New method uses pygame.rect.collidepoint method which doesn't need exact tile's coordinates
This commit is contained in:
parent
2ba090b2d4
commit
013e8b524d
@ -158,9 +158,8 @@ class AutomaticMovement:
|
|||||||
|
|
||||||
# TODO: Nie znajduje terraina na ktorym stoi player
|
# TODO: Nie znajduje terraina na ktorym stoi player
|
||||||
if terrainTile is None:
|
if terrainTile is None:
|
||||||
return 0
|
return 1000
|
||||||
# return terrainTile.cost
|
return terrainTile.cost
|
||||||
return 0
|
|
||||||
|
|
||||||
def priority(self, elem: AStarNode):
|
def priority(self, elem: AStarNode):
|
||||||
coordsWithUiOffset = [elem.state[0] + self.leftUiWidth, elem.state[1]]
|
coordsWithUiOffset = [elem.state[0] + self.leftUiWidth, elem.state[1]]
|
||||||
|
@ -119,6 +119,15 @@ class Map:
|
|||||||
result = tile
|
result = tile
|
||||||
return result
|
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
|
# TODO: REMOVE DONT ADD
|
||||||
def addEntity(self, entity, DONTADD=False):
|
def addEntity(self, entity, DONTADD=False):
|
||||||
self.screen.draw(entity, Locations.MAP, 0, 0)
|
self.screen.draw(entity, Locations.MAP, 0, 0)
|
||||||
|
Loading…
Reference in New Issue
Block a user