added last part of tutorial

This commit is contained in:
Lyzzy 2024-03-10 18:42:40 +01:00
parent fc3773150a
commit f86f2e5dce
2 changed files with 19 additions and 6 deletions

Binary file not shown.

Before

Width:  |  Height:  |  Size: 329 B

After

Width:  |  Height:  |  Size: 1.1 KiB

View file

@ -99,8 +99,8 @@ class Convo(Label):
self.convos = [ 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', 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.']], ['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', 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 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 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): def draw(self, screen):
@ -157,7 +157,7 @@ class MainCharacter(Fighter):
self.talking = False self.talking = False
self.level = Level(1000, 38, 150, 40, level, f'will to live: {level}%', 'simple', 20, ) 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.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.freezing = True
self.killed = killed #amount of mobs that were killed self.killed = killed #amount of mobs that were killed
@ -262,7 +262,7 @@ class MainCharacter(Fighter):
self.walk(keys, objects) self.walk(keys, objects)
if pg.mouse.get_pressed()[0]: if pg.mouse.get_pressed()[0]:
self.attack(objects, vec(mouse)) self.attack(objects, vec(mouse))
self.thinks.update(self) self.thinks.update(objects, self)
if self.health.health <= 0: if self.health.health <= 0:
return 'village' return 'village'
else: else:
@ -327,6 +327,7 @@ class Level(Label):
class Thinks(Label): class Thinks(Label):
def __init__(self, x, y, width, height, text, font='simple', font_size=15, font_color='#000000', sprite='thinks.png') -> None: 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) super().__init__(x, y, width, height, text, font, font_size, font_color, sprite)
self.scene = 0
def draw(self, screen, x, y): def draw(self, screen, x, y):
if self.hidden: if self.hidden:
@ -335,10 +336,22 @@ class Thinks(Label):
self.y = y self.y = y
super().draw(screen) super().draw(screen)
def update(self, main): def update(self, objects, main):
if not self.hidden: if not self.hidden:
if not main.freezing: if self.scene == 0 and not main.freezing:
self.scene = 1
self.hidden = True 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(): class Book():
def __init__(self, x, y, spells, current_spell, current_shield) -> None: def __init__(self, x, y, spells, current_spell, current_shield) -> None: