diff --git a/level.py b/level.py index 444f64b..7efc4a0 100644 --- a/level.py +++ b/level.py @@ -51,6 +51,7 @@ def __init__(self, question: str, difficulty: int): self.difficulty = difficulty self._amountOfObjects = random.randint(difficulty * 10 + 5, difficulty * 20 + 10) self._initialTimer = 10 + self.number_correct = 0 def start(self): self._startLevelTime = int(time.time()) @@ -93,6 +94,7 @@ def __on_timeout(self): return def __on_correct_answer(self, all_objects: pg.sprite.Group) -> pg.sprite.Group: + self.number_correct += 1 return random.choice([Correct(all_objects),CorrectPicture(all_objects), DeadSheep(all_objects)]).execute() def get_amount_of_objects(self) -> int: @@ -103,10 +105,13 @@ def is_stopped(self) -> bool: def get_question(self) -> str: return self.question + + def get_number_correct(self) -> int: + return self.number_correct def reset(self): self._startLevelTime: int = -1 self._stopLevelTime: int = -1 self.answer: str = "" self._amountOfObjects = random.randint(self.difficulty * 10 + 5, self.difficulty * 20 + 10) - self.start() \ No newline at end of file + self.start() diff --git a/main-window.py b/main-window.py index 63b9979..135b9df 100644 --- a/main-window.py +++ b/main-window.py @@ -200,7 +200,10 @@ def main(): timerColor=(0,0,0) if timer <= 5: timerColor=(255,0,0) - text = font.render(str(timer), True, timerColor) + timer_str = str(timer) + if currentLevel.number_correct > 4: + timer_str = str(bin(timer)[2:]) + text = font.render(timer_str, True, timerColor) textpos = text.get_rect(centerx=co.rb_topright[0], y=co.rb_topright[1] - 50) screen.blit(text, textpos)