Skip to content

Commit 9b92303

Browse files
committed
minor refactoring
1 parent 4eb8d45 commit 9b92303

File tree

1 file changed

+8
-9
lines changed

1 file changed

+8
-9
lines changed

hanoi_tower.py

Lines changed: 8 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,12 @@
11
#!/usr/bin/env python3
22
# Piotr Beling, 2024
33

4-
import pyglet
5-
from pyglet import shapes, clock
4+
from pyglet import shapes, clock, app, window, text
65
from pyglet.window import key
76

87
AUTO_PLAY_MOVE_TIME = 1 # in sec.
98

10-
class HanoiWindow(pyglet.window.Window):
9+
class HanoiWindow(window.Window):
1110

1211
def __init__(self):
1312
super().__init__(caption="Tower of Hanoi", resizable=True)
@@ -112,7 +111,7 @@ def on_draw(self):
112111
rod_width = self.width / 5
113112
rod_y = self.height / 5
114113
rod_height = 3 * self.height / 5
115-
disk_height = rod_height/10
114+
disk_height = rod_height / 10
116115
min_disk_width = rod_width / 2
117116
disk_width_delta = rod_width * 9 / 10 - min_disk_width
118117

@@ -141,10 +140,10 @@ def on_draw(self):
141140
0))
142141
disk.anchor_x = disk_w/2
143142
disk.draw()
144-
pyglet.text.Label('Make optimal move (ENTER)',
145-
font_size=36,
146-
x=window.width//2, y=self.height-30,
147-
anchor_x='center', anchor_y='center').draw()
143+
text.Label('Make optimal move (ENTER)',
144+
font_size=36,
145+
x=window.width//2, y=self.height-30,
146+
anchor_x='center', anchor_y='center').draw()
148147

149148
window = HanoiWindow()
150-
pyglet.app.run()
149+
app.run()

0 commit comments

Comments
 (0)