Skip to content
This repository was archived by the owner on Mar 31, 2020. It is now read-only.

Commit 8a94fdd

Browse files
committed
Changed how motion behaves
1 parent 2811eff commit 8a94fdd

File tree

2 files changed

+9
-9
lines changed

2 files changed

+9
-9
lines changed

src/animate.py

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -133,20 +133,19 @@ def __init__(self, canvas: tk.Canvas):
133133

134134
def start(self):
135135
while self._motions:
136+
complete = self.run(self._motions.copy())
137+
self._motions -= complete
136138
time.sleep(1/self.fps)
137-
self.run()
138139

139-
def run(self):
140-
freeze = self._motions.copy()
140+
def run(self, frame):
141141
done = set()
142-
for motion in freeze:
142+
for motion in frame:
143143
try:
144144
next(motion)()
145145
self.canvas.update()
146146
except StopIteration:
147147
done.add(motion)
148-
new = self._motions - freeze
149-
self._motions = (freeze - done).union(new)
148+
return done
150149

151150
def add(self, motion: Motion):
152151
self._motions.add(iter(motion))

src/view.py

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -87,11 +87,12 @@ def change_view(self, view: View, direction: Direction = None):
8787
direction = Direction[direction.upper()] # Cast string for convenience
8888
self.animater.clear()
8989

90-
self.move_out(self.current, direction)
91-
self.move_in(view, direction.flip())
90+
last = self.current
91+
self.current = view
92+
self.move_in(self.current, direction.flip())
93+
self.move_out(last, direction)
9294

9395
self.animater.start()
94-
self.current = view
9596

9697
def get_distance(self, direction: Direction):
9798
if not isinstance(direction, Direction):

0 commit comments

Comments
 (0)