diff --git a/art/images/background/insideHouse.png b/art/images/background/insideHouse.png index dbe316e..07adf06 100644 Binary files a/art/images/background/insideHouse.png and b/art/images/background/insideHouse.png differ diff --git a/main.py b/main.py index 712f72a..16f5d2f 100644 --- a/main.py +++ b/main.py @@ -114,10 +114,10 @@ def village(screen, clock, running, background, isblack, WIDTH, HEIGHT): main = [herbert] mobs = [] weapons = [] - others = [Obstacle('fireplace', 'interactable', 'art/images/background/fireplace.png', False, 500, 500), + others = [Obstacle('fireplace', 'interactable', 'art/images/background/fireplace.png', False, 200, 500), Obstacle('portal', 'interactable', 'art/images/background/portal.png', False, 700, 300), Obstacle('house', 'Interactable', 'art/images/background/house.png', False, 500, 150, WIDTH=180, HEIGHT=160)] - npcs = [NPC('name', 100, 'people/oldlady.png', 1, 200, 200)] + npcs = [NPC('oldlady', 100, 'people/oldlady.png', 0, 200, 200)] objects = [main, mobs, npcs, weapons, others] room = Room('village', 'village', 'art/images/background/village.png', objects, WIDTH - 64, HEIGHT - 64, [True, True, True, True], 0) freeze = True #Gameplay is freezed in certain situations @@ -187,7 +187,7 @@ def house(screen, clock, running, background, isblack, WIDTH, HEIGHT): mobs = [] weapons = [] others = [] - npcs = [NPC('oldman', 100, 'people/reddy.png', 1, 200, 200)] + npcs = [NPC('oldman', 100, 'people/reddy.png', 0, 200, 200)] objects = [main, mobs, npcs, weapons, others] room = Room('house', 'house', 'art/images/background/insideHouse.png', objects, WIDTH - 64, HEIGHT - 64, [True, True, True, True], 0) freeze = False #Gameplay is freezed in certain situations diff --git a/viecher.py b/viecher.py index 4bc2adf..0a5a3f6 100644 --- a/viecher.py +++ b/viecher.py @@ -58,11 +58,11 @@ class Objects(): pg.draw.rect(screen, '#ef0120', self.rect, 2) class NPC(Objects): - def __init__(self, name, ms, sprite, convo_act, x, y) -> None: + def __init__(self, name, ms, sprite, convo_scene, x, y) -> None: super().__init__(name, ms, sprite, x, y) self.talking = False self.hidden = False - self.conversation = Convo('Hello, you can shoot fireballs with f now.', convo_act, 'person') + self.conversation = Convo(self, convo_scene) self.lastUpdate = pg.time.get_ticks() def talk(self, objects): @@ -77,7 +77,7 @@ class NPC(Objects): def update(self, keys, objects): if self.lastUpdate + 200 < pg.time.get_ticks(): if self.talking: - self.conversation.update(keys, objects, self) + self.conversation.update(keys, objects) self.lastUpdate = pg.time.get_ticks() else: touches = pg.sprite.spritecollideany(self, objects[0]) @@ -87,14 +87,37 @@ class NPC(Objects): class Convo(Label): - def __init__(self, text, convo_act, person, x = 140, y = 600, width = 1000, height = 100, font='simple', font_size = 20) -> None: + def __init__(self, npc, convo_scene, text='', x = 140, y = 600, width = 1000, height = 100, font='simple', font_size = 20) -> None: super().__init__(x, y, width, height, text, font, font_size) - - def update(self, keys, objects, npc): + self.convo_act=0 + self.npc = npc + self.convo_scene = convo_scene + self.convos = [ + ['oldlady', 0, ['Hello', 'How are you?']], + ['oldman', 0, ['Please help', 'there are so many bad people']] + ] + + def draw(self, screen): + self.text = self.findConversation()[self.convo_act] + super().draw(screen) + + + def findConversation(self): + for convo in self.convos: + if convo[0] == self.npc.name and convo[1] == self.convo_scene: + return convo[2] + return ['ERROR'] + + def update(self, keys, objects): if keys[pg.K_SPACE]: - objects[0][0].book.addspell('fireball') - npc.talking = False - objects[0][0].talking = False + convo = self.findConversation() + if self.convo_act+1 < len(convo): + self.text = convo[self.convo_act] + self.convo_act += 1 + else: + self.convo_act = 0 + self.npc.talking = False + objects[0][0].talking = False class Fighter(Objects):