From f86f2e5dced02ff22e8862c6e666b084b624b5c9 Mon Sep 17 00:00:00 2001 From: Lyzzy Date: Sun, 10 Mar 2024 18:42:40 +0100 Subject: [PATCH] added last part of tutorial --- art/images/box/thinks.png | Bin 329 -> 1084 bytes viecher.py | 25 +++++++++++++++++++------ 2 files changed, 19 insertions(+), 6 deletions(-) diff --git a/art/images/box/thinks.png b/art/images/box/thinks.png index c0d2d8ea873949a385c877272589bb7774e2d6bd..4273165c3cd8de2c7de3310b44e2b21d972a0436 100644 GIT binary patch literal 1084 zcmV-C1jGA@P)bWcK%Zf&!Lq`LVVBVb(3kOi%ag*ROjB z_D!DfO>o!`kn>9XF!IC5-@5brYow~GWGPvfqQz*&Hw#@Nv1q~Hl>@83#{YsHY_%Q& z@2y!E`NS;ZCvk4QTD_Y1i;e41rSSNUR*xqh*dp(;#Ceo+{|lG^5+LmQ6O%^;LB}5Z zZUs0Dnr2~L=zJT5w%RODVxPQJ)rd2#Lfd#;Tfy$d;0h4R5)`Qr28(3ewS*{?wiXIu zw1O05tM4)-uJW<{_CdRzNrcW>GY1f0iL~ljdIF+S1WwlV)LI-~T@F3V&Ld5=03JX$u2lRVxk(qj}Rf($#X~7@mNXRhg#asne;j!^;cb z?Fiy@3JHvu>VG&U{v1&*OHvJb4RtMn3zY?X$|O*!1u*ve-GeoA0ikrfFJZ;KT$k5r zGM&1^;nhI0luk3Z{1s>+*BkR5M+T@MEJ+ryp-MSc7majV}pe(4rc2ugi576o)A}ny+0xURE79~Js3T3WUo$Hg(S?Vka zc@iA=4uocVc-*lU?7q2!kse5iNbBj?hJ#C`<{7A_0mRO%YOW~SQ6y!9W0x-F=%7Kt zJuPo-uLEnD9qb$H#iVI=RtQ z)suTy>d#)ir=9jfYBa_TIvzl$)8-@$ENLxKsJ4xBexkChJI01wx&8KGt6aQeKZ>FTHs=oiJFI^n!;5 z1oe@?0qL58G!<9S1!}!Ky<3j`oRnq+172)rUJPUhtJT{M&K-XA{dvTb-Bi<6T`3)q zQA3Z@fIi)qn^SRpG~jFJo`8rE(Wpx=H+62ggi`LfEjMrcmiP)#CtV|lnkjjT0whmp zU1OAJ{lfMu033Y$Q|Ipi8p_c~7lvPAkpZbRDn&hEq5@}u7S?AI?=#Nd zb2e0?lAi##3>_{YLqF89JK34%#1N2G5D$3qfbhP&{NOxwe&){l(*PI_3l?F#s-3jwBtR#oB2|bpUBaZKw^O zt3au!c}<)SqLL{DKsk7@SN47u0E?w}L26v{5&YL(0O8yw9zhPYXHD!vN<3a~|? b<+|hxqi3oiBiiDR00000NkvXXu0mjfyOe;E diff --git a/viecher.py b/viecher.py index 750263b..0e2f3c3 100644 --- a/viecher.py +++ b/viecher.py @@ -99,8 +99,8 @@ class Convo(Label): self.convos = [ ['oldlady', 0, ['There are so many rats here.', 'I wish someone would to something against that.','An experienced fighter could kill them.', 'For them it only takes a mouseclick.']], ['oldlady', 1, ['Oh, did you kill all the rats?', 'You must be the chosen one!', 'It would be nice if you would go and talk to the village elder.']], - ['elder', 0, ['Who are you?', 'You want to help us?', 'We have a serious problem with some monsters.', 'One day they appeared out of nowhere and started attacking.', 'When you jump into the portal outside,', 'You will be send to some monsters.', 'PLEASE help us!']], - ['elder', 1, ['Who are you?', 'You want to help us?', 'We have a serious problem with some monsters.', 'One day they appeared out of nowhere and started attacking.', 'When you jump into the portal outside,', 'You will be send to some monsters.', 'PLEASE help us!']] + ['elder', 0, ['Who are you?', 'You want to help us?', 'We have a serious problem with monsters.', 'One day they appeared out of nowhere and started attacking.', 'When you jump into the portal over there,', 'You will be send to a place with monsters.', 'PLEASE help us!']], + ['elder', 1, ['Who are you?', 'You want to help us?', 'We have a serious problem with monsters.', 'One day they appeared out of nowhere and started attacking.', 'When you jump into the portal over there,', 'You will be send to a place with monsters.', 'PLEASE help us!']] ] def draw(self, screen): @@ -157,7 +157,7 @@ class MainCharacter(Fighter): self.talking = False self.level = Level(1000, 38, 150, 40, level, f'will to live: {level}%', 'simple', 20, ) self.health = Hearts(health, sprite=['fullheart.png', 'fullheart.png', 'fullheart.png', 'fullheart.png', 'fullheart.png'], x=900, y= 50, hurtCooldown=self.hurtCooldown) - self.thinks = Thinks(self.x+20, self.y-50, 150, 100, 'brr Im freezing') + self.thinks = Thinks(self.x+20, self.y-50, 150, 100, 'brr I\'m freezing') self.freezing = True self.killed = killed #amount of mobs that were killed @@ -262,7 +262,7 @@ class MainCharacter(Fighter): self.walk(keys, objects) if pg.mouse.get_pressed()[0]: self.attack(objects, vec(mouse)) - self.thinks.update(self) + self.thinks.update(objects, self) if self.health.health <= 0: return 'village' else: @@ -327,6 +327,7 @@ class Level(Label): class Thinks(Label): def __init__(self, x, y, width, height, text, font='simple', font_size=15, font_color='#000000', sprite='thinks.png') -> None: super().__init__(x, y, width, height, text, font, font_size, font_color, sprite) + self.scene = 0 def draw(self, screen, x, y): if self.hidden: @@ -335,10 +336,22 @@ class Thinks(Label): self.y = y super().draw(screen) - def update(self, main): + def update(self, objects, main): if not self.hidden: - if not main.freezing: + if self.scene == 0 and not main.freezing: + self.scene = 1 self.hidden = True + elif self.scene == 1 and main.talking: + self.scene = 2 + self.hidden = True + if self.scene == 1: + touches = pg.sprite.spritecollideany(main, objects[2]) + if touches is not None and isinstance(touches, NPC): + self.text = 'I should press \"f\"' + self.hidden = False + else: + self.hidden = False + self.text = 'the lady over there' class Book(): def __init__(self, x, y, spells, current_spell, current_shield) -> None: