Add debug printing terrain tiles under mouse click
This commit is contained in:
parent
87fc6bea1f
commit
2ba090b2d4
@ -43,10 +43,18 @@ class EventManager:
|
|||||||
pos = pygame.mouse.get_pos()
|
pos = pygame.mouse.get_pos()
|
||||||
|
|
||||||
# get a list of all sprites that are under the mouse cursor
|
# get a list of all sprites that are under the mouse cursor
|
||||||
clicked_sprites = [s for s in self.game.map.collidables if s.rect.collidepoint(pos)]
|
clicked_collidables = [s for s in self.game.map.collidables if s.rect.collidepoint(pos)]
|
||||||
# do something with the clicked sprites...
|
# do something with the clicked sprites...
|
||||||
if len(clicked_sprites) > 0:
|
if len(clicked_collidables) > 0:
|
||||||
self.game.movement.gotoToTarget(Random().choice(clicked_sprites))
|
self.game.movement.gotoToTarget(Random().choice(clicked_collidables))
|
||||||
|
else:
|
||||||
|
clicked_terrains = [tile for tile in self.game.map.terrainTilesList if tile.rect.collidepoint(pos)]
|
||||||
|
if len(clicked_terrains) > 0:
|
||||||
|
print("Terrains under clik:")
|
||||||
|
for terrain in clicked_terrains:
|
||||||
|
print(terrain)
|
||||||
|
else:
|
||||||
|
print("NO TERRAIN FOUND UNDER CLICK")
|
||||||
|
|
||||||
self.game.screen.ui.updateBasedOnPygameEvent(event)
|
self.game.screen.ui.updateBasedOnPygameEvent(event)
|
||||||
self.keyTimeout += self.keyTimer.tick()
|
self.keyTimeout += self.keyTimer.tick()
|
||||||
|
Loading…
Reference in New Issue
Block a user