@@ -247,7 +247,9 @@ def __init__(self, *args, **kwargs):
247
247
self .dy = 0
248
248
self .inventory = [BRICK , GRASS , SAND ]
249
249
self .block = self .inventory [0 ]
250
- self .num_keys = [key ._0 , key ._1 , key ._2 , key ._3 , key ._4 , key ._5 , key ._6 , key ._7 , key ._8 , key ._9 ]
250
+ self .num_keys = [
251
+ key ._1 , key ._2 , key ._3 , key ._4 , key ._5 ,
252
+ key ._6 , key ._7 , key ._8 , key ._9 , key ._0 ]
251
253
self .model = Model ()
252
254
self .label = pyglet .text .Label ('' , font_name = 'Arial' , font_size = 18 ,
253
255
x = 10 , y = self .height - 10 , anchor_x = 'left' , anchor_y = 'top' ,
@@ -380,7 +382,8 @@ def on_key_press(self, symbol, modifiers):
380
382
elif symbol == key .TAB :
381
383
self .flying = not self .flying
382
384
elif symbol in self .num_keys :
383
- self .block = self .inventory [(symbol - self .num_keys [0 ]) % len (self .inventory )]
385
+ index = (symbol - self .num_keys [0 ]) % len (self .inventory )
386
+ self .block = self .inventory [index ]
384
387
def on_key_release (self , symbol , modifiers ):
385
388
if symbol == key .W :
386
389
self .strafe [0 ] += 1
0 commit comments