X-Git-Url: https://harishankar.org/repos/?p=butaba-adventures.git;a=blobdiff_plain;f=gameobjects.py;h=2edbc5b1c86a11ddb16853c926b191013e35741c;hp=e64dc91c374d437ffb7ad1259621ea89990be83d;hb=4d50728c1454554fef2ad4841345d0c28101702d;hpb=f4b468331db23412a3d8195e8ca2650093411697 diff --git a/gameobjects.py b/gameobjects.py index e64dc91..2edbc5b 100644 --- a/gameobjects.py +++ b/gameobjects.py @@ -1,18 +1,15 @@ # object classes - classes for game interactive objects -import pygame -import os.path - -import utility # base class for all objects class GameObject: # initialization routine - def __init__ (self, row, col, text, image = None, can_pickup = True): + def __init__ (self, row, col, text, image = None, can_pickup = True, use_str = "Use"): self.row = row self.col = col self.image = image self.text = text self.can_pickup = can_pickup + self.use_str = use_str # override this for interaction, i.e. when character walks into the item def interact (self): @@ -25,12 +22,27 @@ class GameObject: def use (self, otherobject): pass +class GoldCoins (GameObject): + # initialize + def __init__ (self, row, col, image, value): + text = "gold coins" + self.value = value + GameObject.__init__ (self, row, col, text, image, False, "Take") + + # no interaction with this object + def interact (self): + return True + + # use the object on Butaba - add to his gold + def use (self, butaba): + butaba.gold += self.value + class HealthPotion (GameObject): # initialize def __init__ (self, row, col, image): text = "health potion" - GameObject.__init__ (self, row, col, text, image, True) + GameObject.__init__ (self, row, col, text, image, True, "Drink") # no interaction with this object def interact (self): @@ -43,11 +55,11 @@ class HealthPotion (GameObject): butaba.health = butaba.MAXHEALTH class Chest (GameObject): - def __init__ (self, row, col, text, image, key_id, locked = False, items = []): + def __init__ (self, row, col, text, image, key_id, locked = False, objects = []): self.key_id = key_id self.locked = locked - self.items = items - GameObject.__init__ (self, row, col, text, image, False) + self.objects = objects + GameObject.__init__ (self, row, col, text, image, False, "Open") # no interaction with this object. Also solid so return False def interact (self):