diff --git a/art/images/weapons/empty.png b/art/images/weapons/empty.png index 3c86ed1..bbfeb27 100644 Binary files a/art/images/weapons/empty.png and b/art/images/weapons/empty.png differ diff --git a/classes.py b/classes.py index 3970b38..1198995 100644 --- a/classes.py +++ b/classes.py @@ -85,6 +85,7 @@ class Label(): self.font_color = font_color self.text = text self.hidden = False + self.sprite = sprite with open(f'art/images/box/{sprite}', 'r') as tb: self.box = pygame.image.load(tb) self.box = pygame.transform.scale(self.box, (width, height)) @@ -93,6 +94,9 @@ class Label(): def draw(self, screen): if self.hidden: return + with open(f'art/images/box/{self.sprite}', 'r') as tb: + self.box = pygame.image.load(tb) + self.box = pygame.transform.scale(self.box, (self.width,self.height)) self.labelRect = pygame.Rect(self.x, self.y, self.width, self.height) self.labelSurf = self.font.render(self.text, True, self.font_color) self.box.blit(self.labelSurf, [ diff --git a/main.py b/main.py index 16f5d2f..2e4c5ab 100644 --- a/main.py +++ b/main.py @@ -42,7 +42,7 @@ def genRooms(WIDTH, HEIGHT, type:str, objects:list): def play(screen, clock, running, background, isblack, WIDTH, HEIGHT): main = [herbert] - mobs = [Skeleton(i, random.randint(40, 60), random.randint(50, WIDTH - 50), random.randint(50, HEIGHT - 50), 5, 1, 1, 1, 200) for i in range(0,random.randint(2, 8))]+[Zombie(i, random.randint(40, 60), random.randint(50, WIDTH-50), random.randint(50, HEIGHT-50), 5, 1, 1, 1, 100) for i in range(0,random.randint(2, 8))] + mobs = [Skeleton(i, random.randint(40, 60), random.randint(50, WIDTH - 50), random.randint(50, HEIGHT - 50), 5, 1, 1, 1, 200) for i in range(0,random.randint(2, 5))]+[Zombie(i, random.randint(40, 60), random.randint(50, WIDTH-50), random.randint(50, HEIGHT-50), 5, 1, 1, 1, 25) for i in range(0,random.randint(2, 5))] weapons = [] others = [] npcs = [] diff --git a/viecher.py b/viecher.py index 0a5a3f6..1fcee22 100644 --- a/viecher.py +++ b/viecher.py @@ -33,7 +33,7 @@ fonts = { 'spacy': 'nasalization-rg.otf', 'sci-fi': 'neuropol.otf', 'hollow_big_edge': 'papercut.ttf', - 'space_shuttle': 'pdark.ttf', + 'f_shuttle': 'pdark.ttf', 'thin': 'PixelFJVerdana12pt.ttf', 'random': 'Seattle Avenue.ttf', 'pixel': 'yoster.ttf' @@ -75,13 +75,13 @@ class NPC(Objects): self.conversation.draw(screen) def update(self, keys, objects): - if self.lastUpdate + 200 < pg.time.get_ticks(): + if self.lastUpdate + 150 < pg.time.get_ticks(): if self.talking: self.conversation.update(keys, objects) self.lastUpdate = pg.time.get_ticks() else: touches = pg.sprite.spritecollideany(self, objects[0]) - if touches is not None and keys[pg.K_SPACE] and isinstance(touches, MainCharacter): + if touches is not None and keys[pg.K_f] and isinstance(touches, MainCharacter): self.talk(objects) self.lastUpdate = pg.time.get_ticks() @@ -93,28 +93,31 @@ class Convo(Label): self.npc = npc self.convo_scene = convo_scene self.convos = [ - ['oldlady', 0, ['Hello', 'How are you?']], + ['oldlady', 0, ['There are so many rats here.', 'I wish someone would to something against that','An experienced fighter could just 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 old wise man in the house.']], ['oldman', 0, ['Please help', 'there are so many bad people']] ] def draw(self, screen): - self.text = self.findConversation()[self.convo_act] + self.text = self.findConversation()[2][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 convo return ['ERROR'] def update(self, keys, objects): - if keys[pg.K_SPACE]: + if keys[pg.K_f]: convo = self.findConversation() - if self.convo_act+1 < len(convo): - self.text = convo[self.convo_act] + if self.convo_act+1 < len(convo[2]): + self.text = convo[2][self.convo_act] self.convo_act += 1 else: + if convo[0] == 'oldlady' and convo[1] == 0: + objects[1].append(Rat('r1', 200, 1000, 350, 1, 1, 1, 100, 25)) self.convo_act = 0 self.npc.talking = False objects[0][0].talking = False @@ -138,7 +141,7 @@ class MainCharacter(Fighter): super().__init__(name, ms, sprite, x, y, health, damage, level, asp, atr) self.book = Book(0, 0, [], None, None) self.talking = False - self.level = Level(1000, 38, 150, 40, 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.thinks = Thinks(self.x+20, self.y-50, 150, 100, 'brr Im freezing') self.freezing = True @@ -301,8 +304,9 @@ class Hearts(): class Level(Label): - def __init__(self, x, y, width, height, text, font='simple', font_size=20, font_color='#1e90ff', sprite='label.png') -> None: + def __init__(self, x, y, width, height, level, text, font='simple', font_size=20, font_color='#1e90ff', sprite='label.png') -> None: super().__init__(x, y, width, height, text, font, font_size, font_color, sprite) + self.level = level class Thinks(Label): def __init__(self, x, y, width, height, text, font='simple', font_size=15, font_color='#000000', sprite='thinks.png') -> None: @@ -438,6 +442,16 @@ class Zombie(Mobs): obj[3].append(Punch('punch', 100, self.x, self.y, moveto, self.damage)) self.lastAttack = pg.time.get_ticks() +class Rat(Mobs): + def __init__(self, name, ms, x, y, health, damage, level, asp, atr, sprite='people/rat.png', drops=0) -> None: + super().__init__(name, ms, sprite, x, y, health, damage, level, asp, atr, drops) + + + def attack(self, moveto, obj): + if self.lastAttack + self.attack_speed * 1000 < pg.time.get_ticks(): + obj[3].append(Punch('punch', 100, self.x, self.y, moveto, self.damage)) + self.lastAttack = pg.time.get_ticks() + class Weapons(Objects): def __init__(self, name, ms, sprite, x, y, moveto, damage, life_ticks) -> None: super().__init__(name, ms, sprite, x, y)