implemented stepping mode
This commit is contained in:
parent
57cd60de8c
commit
4c3c3f973e
|
@ -420,6 +420,9 @@ class Game:
|
||||||
elif event.key == pygame.K_r:
|
elif event.key == pygame.K_r:
|
||||||
# run program
|
# run program
|
||||||
self.state = 'running'
|
self.state = 'running'
|
||||||
|
elif event.key == pygame.K_s:
|
||||||
|
self.state = 'manual'
|
||||||
|
self.prg.step()
|
||||||
return self.state
|
return self.state
|
||||||
|
|
||||||
def reset(self):
|
def reset(self):
|
||||||
|
@ -442,6 +445,8 @@ class Game:
|
||||||
self.state = self.reset()
|
self.state = self.reset()
|
||||||
elif self.state == 'quit':
|
elif self.state == 'quit':
|
||||||
running = False
|
running = False
|
||||||
|
elif self.state == 'manual':
|
||||||
|
pass
|
||||||
else:
|
else:
|
||||||
print("unknown state")
|
print("unknown state")
|
||||||
return
|
return
|
||||||
|
@ -452,4 +457,8 @@ class Game:
|
||||||
if __name__ == "__main__":
|
if __name__ == "__main__":
|
||||||
random.seed(42)
|
random.seed(42)
|
||||||
game = Game(dimx=7, dimy=4, robotx=3, roboty=1)
|
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
|
Loading…
Reference in New Issue
Block a user