]> Skullheadx's Git Forge - word-hunt.git/commitdiff
timer moves with word display
authorSkullheadx <94652084+Skullheadx@users.noreply.github.com>
Fri, 25 Nov 2022 16:30:56 +0000 (11:30 -0500)
committerSkullheadx <94652084+Skullheadx@users.noreply.github.com>
Fri, 25 Nov 2022 16:30:56 +0000 (11:30 -0500)
Main/__pycache__/game.cpython-310.pyc
Main/__pycache__/timer.cpython-310.pyc
Main/__pycache__/words_display.cpython-310.pyc
Main/game.py
Main/timer.py
Main/words_display.py

index 851c75d07bb0e7c07e411a5164b3e8db12ed3820..e54377ff2c48516249daf751a53804677453c9aa 100644 (file)
Binary files a/Main/__pycache__/game.cpython-310.pyc and b/Main/__pycache__/game.cpython-310.pyc differ
index 95bcd967e30b66ae108800efc971473b2b15fd76..029c675b6049c897dcb27059381ee5b73fe6b1d4 100644 (file)
Binary files a/Main/__pycache__/timer.cpython-310.pyc and b/Main/__pycache__/timer.cpython-310.pyc differ
index be2ef95b818154bb547cc3ac7a6c017f5350c9fc..54149a84fedb7288207a5074b2563b645879af6f 100644 (file)
Binary files a/Main/__pycache__/words_display.cpython-310.pyc and b/Main/__pycache__/words_display.cpython-310.pyc differ
index 097563a0a4ffad9e93448522719bfbc69eb6e24e..c71c26f1124452a987ca7893cecc3c45e13364f1 100644 (file)
@@ -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)
index af755b00c0dc05df0144dae0ac5c20f68f20dbec..db6389fdf06c5012c8c1d74b71d93d6151fc2bbd 100644 (file)
@@ -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())
index 56d6c94df25639b50029e70ab8f88cc9e8725b4c..5ae382c63ce2158d89941601d993bf7e270cb172 100644 (file)
@@ -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