6cb93f087dd54045393acc971a5e04e5e0067ee2
1 # object classes - classes for game interactive objects
7 # base class for all objects
9 # initialization routine
10 def __init__ (self
, row
, col
, text
, image
= None, can_pickup
= True):
15 self
.can_pickup
= can_pickup
17 # override this for interaction, i.e. when character walks into the item
19 # always return True if the object is interacted with
20 # return False to make the object block the player from
24 # use the object on another object
25 def use (self
, otherobject
):
29 class HealthPotion (GameObject
):
31 def __init__ (self
, row
, col
, image
):
32 text
= "health potion"
33 GameObject
.__init
__ (self
, row
, col
, text
, image
, True)
35 # no interaction with this object
40 def use (self
, butaba
):
43 class Key (GameObject
):
44 def __init__ (self
, row
, col
, text
, image
, key_id
):
46 GameObject
.__init
__ (self
, row
, col
, text
, image
, True)
48 # no interaction with this object
50 # key is not a solid object so return True
54 def use (self
, lockitem
):
55 if type (lockitem
) == Chest
or type (lockitem
) == Door
:
56 if self
.key_id
== lockitem
.key_id
:
57 if lockitem
.unlocked
is False:
58 lockitem
.unlocked
= True
60 lockitem
.unlocked
= True