From: Skullheadx <94652084+Skullheadx@users.noreply.github.com> Date: Fri, 25 Nov 2022 16:30:56 +0000 (-0500) Subject: timer moves with word display X-Git-Url: http://git.skullheadx.com/index.css?a=commitdiff_plain;h=48608dcd255c3c7033d94bafd27720208155087a;p=word-hunt.git timer moves with word display --- diff --git a/Main/__pycache__/game.cpython-310.pyc b/Main/__pycache__/game.cpython-310.pyc index 851c75d..e54377f 100644 Binary files a/Main/__pycache__/game.cpython-310.pyc and b/Main/__pycache__/game.cpython-310.pyc differ diff --git a/Main/__pycache__/timer.cpython-310.pyc b/Main/__pycache__/timer.cpython-310.pyc index 95bcd96..029c675 100644 Binary files a/Main/__pycache__/timer.cpython-310.pyc and b/Main/__pycache__/timer.cpython-310.pyc differ diff --git a/Main/__pycache__/words_display.cpython-310.pyc b/Main/__pycache__/words_display.cpython-310.pyc index be2ef95..54149a8 100644 Binary files a/Main/__pycache__/words_display.cpython-310.pyc and b/Main/__pycache__/words_display.cpython-310.pyc differ diff --git a/Main/game.py b/Main/game.py index 097563a..c71c26f 100644 --- a/Main/game.py +++ b/Main/game.py @@ -49,8 +49,7 @@ class Game: self.word_connector = WordConnector() self.bg_colour = Colour.LIGHT_GRAY self.unknown_word_display = UnknownWordDisplay((SCREEN_WIDTH*2/3-UnknownWordDisplay.inset,self.board.position.y),self.word_frequency) - self.timer = Timer(self.unknown_word_display.position + pygame.Vector2(0, self.unknown_word_display.get_rect().height/2 )) - + self.timer = Timer(self.unknown_word_display.position +pygame.Vector2(0,self.unknown_word_display.get_rect().height)) def update(self, delta): self.word += self.board.update(delta, self.bg_colour, self.points) self.word_connector.update(self.board.grid.last_selected, self.colour_converter[self.bg_colour]) @@ -77,7 +76,7 @@ class Game: self.bg_colour = self.correct_colour self.word_display = self.font.render(self.word, True, Colour.BLACK) - self.timer.update(delta) + self.timer.update(delta, self.unknown_word_display.position +pygame.Vector2(0,self.unknown_word_display.get_rect().height-self.unknown_word_display.inset + self.word_disp_separation_distance/2)) def draw(self, surf): surf.fill(Palette.primary_shade1) diff --git a/Main/timer.py b/Main/timer.py index af755b0..db6389f 100644 --- a/Main/timer.py +++ b/Main/timer.py @@ -1,3 +1,5 @@ +import pygame + from setup import * @@ -12,12 +14,12 @@ class Timer: self.position = pygame.Vector2(position) self.time = 120 # 120 seconds self.text = self.font.render(f"{self.time//60}:{'%.2f' % (self.time % 60)}",True,Colour.BLACK) - - def update(self,delta): + def update(self,delta, position): mins, secs = divmod(int(self.time), 60) timer = '{:02d}:{:02d}'.format(mins, secs) self.text = self.font.render(f"{timer}",True,Colour.BLACK) self.time = max(0, self.time - delta/1000) + self.position = pygame.Vector2(position) def get_rect(self): return pygame.Rect(self.position.x - self.inset, self.position.y, self.text.get_width() + 2 * self.inset, self.text.get_height()) diff --git a/Main/words_display.py b/Main/words_display.py index 56d6c94..5ae382c 100644 --- a/Main/words_display.py +++ b/Main/words_display.py @@ -9,7 +9,8 @@ class ListDisplay: self.frequencies = frequencies self.display = [] for i in self.frequencies: - self.display.append(self.font.render(f"({self.frequencies[i]}) {'?' * i}", True, Colour.BLACK)) + if frequencies[i] > 0: + self.display.append(self.font.render(f"({self.frequencies[i]}) {'?' * i}", True, Colour.BLACK)) def update(self, delta, seen): f = {i + 1: 0 for i in range(16)} @@ -57,7 +58,7 @@ class UnknownWordDisplay: self.words_found = 0 self.total_words = sum(word_frequency.values()) # self.title = self.title_font.render("Word Bank", True, Colour.DARK_GRAY) - self.title = self.title_font.render(f"Words: {self.words_found} / {self.total_words}", True, Colour.DARK_GRAY) + self.title = self.title_font.render(f"Words: {self.words_found}/{self.total_words}", True, Colour.DARK_GRAY) self.list_display = ListDisplay(self.position+ pygame.Vector2(0,self.title.get_height()/2), self.word_frequency) def update(self, delta, seen): @@ -81,4 +82,6 @@ class UnknownWordDisplay: #self.position.y-self.inset + max(self.title.get_height(),self.inset)/2) # pygame.draw.circle(surf, Colour.RED,self.position, 4) + # pygame.draw.circle(surf, Colour.GREEN,self.position + pygame.Vector2(0,self.get_rect().height-self.inset), 4) + # pygame.draw.circle(surf, Colour.BLUE,self.list_display.position, 5) \ No newline at end of file