1 # object classes - classes for game interactive objects
7 # base class for all objects
9 # initialization routine
10 def __init__ (self
, row
, col
, image
= None):
15 # override this for interaction
19 # use the object on another object
20 def use (self
, otherobject
):
24 class Key (GameObject
):
25 def __init__ (self
, row
, col
, image
, key_id
):
27 GameObject
.__init
__ (self
, row
, col
, image
)
29 # ask whether to pick up the key
30 def interact (self
, surface
):
31 ans
= utility
.ask_question (surface
, "You found a key.", ["Pick it up", "Leave it"])
35 def use (self
, lockitem
):
36 if type (lockitem
) == Chest
or type (lockitem
) == Door
:
37 if self
.key_id
== lockitem
.key_id
:
38 if lockitem
.unlocked
is False:
39 lockitem
.unlocked
= True
41 lockitem
.unlocked
= True