split update_delay

This commit is contained in:
rhiannon morris 2023-08-17 15:36:30 +02:00
parent 1a635a3140
commit 63491e0227

View file

@ -97,18 +97,27 @@ class Quox(Application):
def think(self, state, Δ):
super().think(state, Δ)
self.update_delay(Δ)
self.pick_direction()
self.pick_step()
self.maybe_move()
def update_delay(self, Δ):
self.turn_delay -= Δ
self.step_delay -= Δ
self.move_delay -= Δ
def pick_direction(self):
if self.turn_delay <= 0:
old_delay = self.turn_delay
self.choose_direction()
self.choose_turn_delay(old_delay)
def pick_step(self):
if self.step_delay <= 0:
self.step_delay = Quox.STEP_DELAY
self.step = (self.step + 1) & 3
def maybe_move(self):
if self.move_delay <= 0:
self.move_delay += Quox.MOVE_DELAY
self.move()