diff --git a/main.py b/main.py index 5b542ae..71567dd 100644 --- a/main.py +++ b/main.py @@ -41,9 +41,8 @@ def genRooms(WIDTH, HEIGHT, type:str, objects:list): return rooms def play(screen, clock, running, background, isblack, WIDTH, HEIGHT): - main = [MainCharacter('Herbert', 100, 'people/oldman.png', 500, 500, 20, 5, 1, 1, 50)] + 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))] - weapons = [] others = [Fire('f1', 0, 200, 300)] npcs = [NPC('name', 100, 'people/oldlady.png', 1, 200, 200)] @@ -74,14 +73,14 @@ def play(screen, clock, running, background, isblack, WIDTH, HEIGHT): objects = scene.getObjects() screen.blit(scene.background, (32, 32)) - for weapon in objects[3]: - weapon.update(objects) - weapon.draw(screen) - for thing in objects[4]: thing.update(objects) thing.draw(screen) + for weapon in objects[3]: + weapon.update(objects) + weapon.draw(screen) + for thing in objects[0]: thing.book.hidden = not freeze if not thing.update(pygame.key.get_pressed(), pygame.mouse.get_pos(), objects): @@ -109,7 +108,7 @@ def play(screen, clock, running, background, isblack, WIDTH, HEIGHT): clock.tick(fps) # limits FPS to 60 def village(screen, clock, running, background, isblack, WIDTH, HEIGHT): - main = [MainCharacter('Herbert', 100, 'people/oldman.png', 500, 500, 20, 5, 1, 1, 50)] + main = [herbert] mobs = [] weapons = [] others = [Fire('f1', 0, 200, 300), Portal('p1', 0, 1000, 500)] @@ -117,6 +116,7 @@ def village(screen, clock, running, background, isblack, WIDTH, HEIGHT): 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 + main[0].health.health = 20 while running: screen.fill('#000000') @@ -329,4 +329,5 @@ def main(): pygame.quit() if __name__ == '__main__': + herbert = MainCharacter('Herbert', 100, 'people/oldman.png', 500, 500, 20, 5, 1, 1, 50) main() diff --git a/viecher.py b/viecher.py index 69ccb6e..8871b1d 100644 --- a/viecher.py +++ b/viecher.py @@ -418,7 +418,8 @@ class Weapons(Objects): if touches is not None and isinstance(touches, kills): touches.hurt(self.damage, objects) self.hidden = True - objects[3].remove(self) + if self in objects[3]: + objects[3].remove(self) def move(self, objects): self.moveto.scale_to_length(self.speed)