Add pausing decision tree run

This commit is contained in:
Michał Czekański 2020-05-24 13:58:33 +02:00
parent 5f7cd0dce7
commit c88965de38

View File

@ -244,8 +244,22 @@ class Game:
self.player = Player((6, 2), self.map.tileSize, Affinities(0.3, 0.6, 0.1, 0.5))
self.map.addEntity(self.player, DONTADD=True)
pause = False
# main loop without user input
while self.running:
while True:
for event in pygame.event.get():
if event.type == pygame.QUIT:
exit(0)
elif event.type == pygame.KEYDOWN:
if event.key == pygame.K_SPACE:
pause = not pause
if pause or not self.running:
pass
else:
# Tick the timers
self.ingameTimer.updateTime(self.pgTimer.tick())
self.screen.ui.updateTime()
@ -256,7 +270,7 @@ class Game:
self.spritesList.update()
self.spritesList.draw(self.screen.pygameScreen)
pygame.display.flip()
break
self.running = False
# Choose target for player using decision tree
if self.player.movementTarget is None:
@ -273,7 +287,3 @@ class Game:
# Flip the display
pygame.display.flip()
while True:
for event in pygame.event.get():
if event.type == pygame.QUIT:
exit(0)