From 3883237f91648979830af25aa75e79da0858238b Mon Sep 17 00:00:00 2001 From: SpagettiFisch <63868515+SpagettiFisch@users.noreply.github.com> Date: Sun, 10 Mar 2024 23:07:38 +0100 Subject: [PATCH] fied a bug were the game would crash during door creation Signed-off-by: SpagettiFisch <63868515+SpagettiFisch@users.noreply.github.com> --- classes.py | 19 ++++++++++--------- main.py | 2 +- 2 files changed, 11 insertions(+), 10 deletions(-) diff --git a/classes.py b/classes.py index 8a9ce87..247972b 100644 --- a/classes.py +++ b/classes.py @@ -293,15 +293,16 @@ class Room(GameObjects): return walls def createDoors(self, WIDTH): - if len(self.exits) == 1: - self.doors.append(Door(f'door{self.id}', self.exits[0][1], random.randint(64, round(WIDTH * 0.75)), 4, self.exits[0][0])) - elif len(self.exits) == 2: - self.doors.append(Door(f'door{self.id}', self.exits[0][1], random.randint(64, round(WIDTH * 0.45)), self.exits[0][0])) - self.doors.append(Door(f'door{self.id}', self.exits[1][1], random.randint(round(WIDTH * 0.5), round(WIDTH * 0.9)), self.exits[1][0])) - else: - self.doors.append(Door(f'door{self.id}', self.exits[0][1], random.randint(64, round(WIDTH * 0.3)), self.exits[0][0])) - self.doors.append(Door(f'door{self.id}', self.exits[1][1], random.randint(round(WIDTH * 0.33), round(WIDTH * 0.6)), self.exits[1][0])) - self.doors.append(Door(f'door{self.id}', self.exits[2][1], random.randint(round(WIDTH * 0.63), round(WIDTH * 0.95)), self.exits[2][0])) + if not self.type == 'boss': + if len(self.exits) == 1: + self.doors.append(Door(f'door{self.id}', self.exits[0][1], random.randint(64, round(WIDTH * 0.75)), 4, self.exits[0][0])) + elif len(self.exits) == 2: + self.doors.append(Door(f'door{self.id}', self.exits[0][1], random.randint(64, round(WIDTH * 0.45)), self.exits[0][0])) + self.doors.append(Door(f'door{self.id}', self.exits[1][1], random.randint(round(WIDTH * 0.5), round(WIDTH * 0.9)), self.exits[1][0])) + else: + self.doors.append(Door(f'door{self.id}', self.exits[0][1], random.randint(64, round(WIDTH * 0.3)), self.exits[0][0])) + self.doors.append(Door(f'door{self.id}', self.exits[1][1], random.randint(round(WIDTH * 0.33), round(WIDTH * 0.6)), self.exits[1][0])) + self.doors.append(Door(f'door{self.id}', self.exits[2][1], random.randint(round(WIDTH * 0.63), round(WIDTH * 0.95)), self.exits[2][0])) def update(self, objects): if objects is not None: diff --git a/main.py b/main.py index f110c19..001162c 100644 --- a/main.py +++ b/main.py @@ -290,7 +290,7 @@ def options(screen, clock, running, background, isblack, WIDTH, HEIGHT): def menu(screen, clock, running, background, isblack, WIDTH, HEIGHT): objects = [] - objects.append(Button(WIDTH / 2 - 80, HEIGHT / 2, 160, 64, 'textbox.png', 'medieval', 48, "Play", play, attributes=[screen, clock, running, background, isblack, WIDTH, HEIGHT])) + objects.append(Button(WIDTH / 2 - 80, HEIGHT / 2, 160, 64, 'textbox.png', 'medieval', 48, "Play", village, attributes=[screen, clock, running, background, isblack, WIDTH, HEIGHT])) #objects.append(Button(WIDTH / 2 - 80, HEIGHT / 2 - 72, 160, 64, 'textbox.png', 'medieval', 48, "Options", uwu)) objects.append(Button(WIDTH / 2 - 80, HEIGHT / 2 + 72, 160, 64, 'textbox.png', 'medieval', 48, "Exit game", quitGame)) while running: