Skip to content

Commit

Permalink
keys 1 - 0, not 0 - 9
Browse files Browse the repository at this point in the history
  • Loading branch information
fogleman committed Mar 31, 2013
1 parent 1b39e03 commit 5d6190b
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions main.py
Original file line number Diff line number Diff line change
Expand Up @@ -247,7 +247,9 @@ def __init__(self, *args, **kwargs):
self.dy = 0
self.inventory = [BRICK, GRASS, SAND]
self.block = self.inventory[0]
self.num_keys = [key._0, key._1, key._2, key._3, key._4, key._5, key._6, key._7, key._8, key._9]
self.num_keys = [
key._1, key._2, key._3, key._4, key._5,
key._6, key._7, key._8, key._9, key._0]
self.model = Model()
self.label = pyglet.text.Label('', font_name='Arial', font_size=18,
x=10, y=self.height - 10, anchor_x='left', anchor_y='top',
Expand Down Expand Up @@ -380,7 +382,8 @@ def on_key_press(self, symbol, modifiers):
elif symbol == key.TAB:
self.flying = not self.flying
elif symbol in self.num_keys:
self.block = self.inventory[(symbol - self.num_keys[0]) % len(self.inventory)]
index = (symbol - self.num_keys[0]) % len(self.inventory)
self.block = self.inventory[index]
def on_key_release(self, symbol, modifiers):
if symbol == key.W:
self.strafe[0] += 1
Expand Down

1 comment on commit 5d6190b

@DavidJFelix
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Surely it would make more sense for num_key[1] to return the 1 key, despite the fact that that's not their order on the keyboard, wouldn't it? In that case, wouldn't it be cleaner to revert the change on line +/-250 (+251, +252) and change line 385 to instead use self.num_keys[1]?

This is just a design consideration, not a bug.

Please sign in to comment.