From: Skullheadx <94652084+Skullheadx@users.noreply.github.com> Date: Fri, 25 Nov 2022 16:02:25 +0000 (-0500) Subject: timer box added X-Git-Url: http://git.skullheadx.com/about.html?a=commitdiff_plain;h=950fd858c6f9fe6c4650220682c7f339c8194e27;p=word-hunt.git timer box added --- diff --git a/.idea/misc.xml b/.idea/misc.xml index a4652f3..d8a3dd8 100644 --- a/.idea/misc.xml +++ b/.idea/misc.xml @@ -1,4 +1,4 @@ - + \ No newline at end of file diff --git a/.idea/word-hunt.iml b/.idea/word-hunt.iml index 7efdecd..a3fe4f9 100644 --- a/.idea/word-hunt.iml +++ b/.idea/word-hunt.iml @@ -5,7 +5,7 @@ - + \ No newline at end of file diff --git a/Main/__pycache__/board.cpython-310.pyc b/Main/__pycache__/board.cpython-310.pyc index d6f0cae..8f37252 100644 Binary files a/Main/__pycache__/board.cpython-310.pyc and b/Main/__pycache__/board.cpython-310.pyc differ diff --git a/Main/__pycache__/game.cpython-310.pyc b/Main/__pycache__/game.cpython-310.pyc index 186ed23..851c75d 100644 Binary files a/Main/__pycache__/game.cpython-310.pyc and b/Main/__pycache__/game.cpython-310.pyc differ diff --git a/Main/__pycache__/setup.cpython-310.pyc b/Main/__pycache__/setup.cpython-310.pyc index 34c28cf..800458e 100644 Binary files a/Main/__pycache__/setup.cpython-310.pyc and b/Main/__pycache__/setup.cpython-310.pyc differ diff --git a/Main/__pycache__/tile.cpython-310.pyc b/Main/__pycache__/tile.cpython-310.pyc index 45cfd25..44094fe 100644 Binary files a/Main/__pycache__/tile.cpython-310.pyc and b/Main/__pycache__/tile.cpython-310.pyc differ diff --git a/Main/__pycache__/timer.cpython-310.pyc b/Main/__pycache__/timer.cpython-310.pyc index 7dd974e..95bcd96 100644 Binary files a/Main/__pycache__/timer.cpython-310.pyc and b/Main/__pycache__/timer.cpython-310.pyc differ diff --git a/Main/__pycache__/word_connector.cpython-310.pyc b/Main/__pycache__/word_connector.cpython-310.pyc index e4da122..4d258cd 100644 Binary files a/Main/__pycache__/word_connector.cpython-310.pyc and b/Main/__pycache__/word_connector.cpython-310.pyc differ diff --git a/Main/__pycache__/words_display.cpython-310.pyc b/Main/__pycache__/words_display.cpython-310.pyc index b4b7b64..be2ef95 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 dbbba98..097563a 100644 --- a/Main/game.py +++ b/Main/game.py @@ -49,7 +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.word_disp_separation_distance)) + self.timer = Timer(self.unknown_word_display.position + pygame.Vector2(0, self.unknown_word_display.get_rect().height/2 )) def update(self, delta): self.word += self.board.update(delta, self.bg_colour, self.points) diff --git a/Main/timer.py b/Main/timer.py index c7b1b0c..af755b0 100644 --- a/Main/timer.py +++ b/Main/timer.py @@ -4,16 +4,25 @@ from setup import * class Timer: font = pygame.font.Font("font/Silkscreen-Regular.ttf", 30) + inset = 15 + edge_radius = 10 + bezel = 4 + def __init__(self, position): 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): - self.time = max(0, self.time - delta/1000) 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) + + 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()) def draw(self, surf): + pygame.draw.rect(surf,Colour.LIGHT_GRAY,self.get_rect(),border_radius=self.edge_radius) + pygame.draw.rect(surf,Colour.DARK_GRAY,self.get_rect(),width= self.bezel,border_radius=self.edge_radius) surf.blit(self.text, self.text.get_rect(topleft =self.position))