implemented stepping mode

This commit is contained in:
Simon Pirkelmann 2021-09-06 00:34:26 +02:00
parent 57cd60de8c
commit 4c3c3f973e

View File

@ -420,6 +420,9 @@ class Game:
elif event.key == pygame.K_r:
# run program
self.state = 'running'
elif event.key == pygame.K_s:
self.state = 'manual'
self.prg.step()
return self.state
def reset(self):
@ -442,6 +445,8 @@ class Game:
self.state = self.reset()
elif self.state == 'quit':
running = False
elif self.state == 'manual':
pass
else:
print("unknown state")
return
@ -452,4 +457,8 @@ class Game:
if __name__ == "__main__":
random.seed(42)
game = Game(dimx=7, dimy=4, robotx=3, roboty=1)
game.run()
game.run()
# TODOs
# - in stepping mode (s) it is possible to drive outside of the map
# - when no P0 command is present the program counter will overflow