1
1
#!/usr/bin/env python3
2
2
# Piotr Beling, 2024
3
3
4
- import pyglet
5
- from pyglet import shapes , clock
4
+ from pyglet import shapes , clock , app , window , text
6
5
from pyglet .window import key
7
6
8
7
AUTO_PLAY_MOVE_TIME = 1 # in sec.
9
8
10
- class HanoiWindow (pyglet . window .Window ):
9
+ class HanoiWindow (window .Window ):
11
10
12
11
def __init__ (self ):
13
12
super ().__init__ (caption = "Tower of Hanoi" , resizable = True )
@@ -112,7 +111,7 @@ def on_draw(self):
112
111
rod_width = self .width / 5
113
112
rod_y = self .height / 5
114
113
rod_height = 3 * self .height / 5
115
- disk_height = rod_height / 10
114
+ disk_height = rod_height / 10
116
115
min_disk_width = rod_width / 2
117
116
disk_width_delta = rod_width * 9 / 10 - min_disk_width
118
117
@@ -141,10 +140,10 @@ def on_draw(self):
141
140
0 ))
142
141
disk .anchor_x = disk_w / 2
143
142
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 ()
148
147
149
148
window = HanoiWindow ()
150
- pyglet . app .run ()
149
+ app .run ()
0 commit comments