Mercurial > pyntnclick
annotate gamelib/hand.py @ 166:0db92b3b5833
Add inventory interactions
author | Neil Muller <neil@dip.sun.ac.za> |
---|---|
date | Wed, 25 Aug 2010 12:03:08 +0200 |
parents | ef4da30f0f38 |
children |
rev | line source |
---|---|
36 | 1 # Button for the hand image |
2 | |
57
4f9d412d83db
Use hand icon from openclipart
Neil Muller <neil@dip.sun.ac.za>
parents:
49
diff
changeset
|
3 from constants import BUTTON_SIZE |
4f9d412d83db
Use hand icon from openclipart
Neil Muller <neil@dip.sun.ac.za>
parents:
49
diff
changeset
|
4 |
159
ef4da30f0f38
Make hand activate on mouse down, like inventory
Neil Muller <neil@dip.sun.ac.za>
parents:
144
diff
changeset
|
5 from albow.controls import Image |
36 | 6 from albow.resource import get_image |
57
4f9d412d83db
Use hand icon from openclipart
Neil Muller <neil@dip.sun.ac.za>
parents:
49
diff
changeset
|
7 from pygame.rect import Rect |
36 | 8 |
124 | 9 |
159
ef4da30f0f38
Make hand activate on mouse down, like inventory
Neil Muller <neil@dip.sun.ac.za>
parents:
144
diff
changeset
|
10 class HandButton(Image): |
44
79062a225703
Correct out-by-one indentation error. :)
Simon Cross <simon@simonx>
parents:
36
diff
changeset
|
11 """The fancy hand button for the widget""" |
36 | 12 |
44
79062a225703
Correct out-by-one indentation error. :)
Simon Cross <simon@simonx>
parents:
36
diff
changeset
|
13 def __init__(self, action): |
79062a225703
Correct out-by-one indentation error. :)
Simon Cross <simon@simonx>
parents:
36
diff
changeset
|
14 # FIXME: Yes, please. |
57
4f9d412d83db
Use hand icon from openclipart
Neil Muller <neil@dip.sun.ac.za>
parents:
49
diff
changeset
|
15 this_image = get_image('items', 'hand.png') |
159
ef4da30f0f38
Make hand activate on mouse down, like inventory
Neil Muller <neil@dip.sun.ac.za>
parents:
144
diff
changeset
|
16 Image.__init__(self, image=this_image) |
ef4da30f0f38
Make hand activate on mouse down, like inventory
Neil Muller <neil@dip.sun.ac.za>
parents:
144
diff
changeset
|
17 self.action = action |
57
4f9d412d83db
Use hand icon from openclipart
Neil Muller <neil@dip.sun.ac.za>
parents:
49
diff
changeset
|
18 self.set_rect(Rect(0, 0, BUTTON_SIZE, BUTTON_SIZE)) |
36 | 19 |
159
ef4da30f0f38
Make hand activate on mouse down, like inventory
Neil Muller <neil@dip.sun.ac.za>
parents:
144
diff
changeset
|
20 def mouse_down(self, event): |
ef4da30f0f38
Make hand activate on mouse down, like inventory
Neil Muller <neil@dip.sun.ac.za>
parents:
144
diff
changeset
|
21 self.action() |
ef4da30f0f38
Make hand activate on mouse down, like inventory
Neil Muller <neil@dip.sun.ac.za>
parents:
144
diff
changeset
|
22 |