]> Skullheadx's Git Forge - word-hunt.git/commitdiff
timer added
authorSkullheadx <704277@pdsb.net>
Fri, 25 Nov 2022 02:43:00 +0000 (21:43 -0500)
committerSkullheadx <704277@pdsb.net>
Fri, 25 Nov 2022 02:43:00 +0000 (21:43 -0500)
12 files changed:
.idea/misc.xml
.idea/word-hunt.iml
Main/__pycache__/board.cpython-310.pyc
Main/__pycache__/game.cpython-310.pyc
Main/__pycache__/setup.cpython-310.pyc
Main/__pycache__/tile.cpython-310.pyc
Main/__pycache__/timer.cpython-310.pyc [new file with mode: 0644]
Main/__pycache__/word_connector.cpython-310.pyc
Main/__pycache__/words_display.cpython-310.pyc
Main/game.py
Main/main.py
Main/timer.py [new file with mode: 0644]

index d8a3dd862ab749b9d47a3524c1bf032024a561e9..a4652f355e26c43a58fbff0f10cd661868d00976 100644 (file)
@@ -1,4 +1,4 @@
 <?xml version="1.0" encoding="UTF-8"?>
 <project version="4">
-  <component name="ProjectRootManager" version="2" project-jdk-name="Python 3.10 (word-hunt)" project-jdk-type="Python SDK" />
+  <component name="ProjectRootManager" version="2" project-jdk-name="Python 3.10 (venv)" project-jdk-type="Python SDK" />
 </project>
\ No newline at end of file
index bfd0b6b900b3bf282452a6aed344f7ab5757429f..7efdecd328a17c536c884ecbc5c9748187a461a1 100644 (file)
@@ -5,7 +5,7 @@
       <excludeFolder url="file://$MODULE_DIR$/Main/venv" />
       <excludeFolder url="file://$MODULE_DIR$/venv" />
     </content>
-    <orderEntry type="jdk" jdkName="Python 3.10 (word-hunt)" jdkType="Python SDK" />
+    <orderEntry type="jdk" jdkName="Python 3.10 (venv)" jdkType="Python SDK" />
     <orderEntry type="sourceFolder" forTests="false" />
   </component>
 </module>
\ No newline at end of file
index 8f37252d064ad83dc1306458531ecbebef240ac0..d6f0cae572b428c499ff5a12ee4d2de00d971e20 100644 (file)
Binary files a/Main/__pycache__/board.cpython-310.pyc and b/Main/__pycache__/board.cpython-310.pyc differ
index b47c4e2aabc74fa44ded3314e5b4f0689b42d9dd..186ed23bc977075391b726a3481a9c2cdcf4df8f 100644 (file)
Binary files a/Main/__pycache__/game.cpython-310.pyc and b/Main/__pycache__/game.cpython-310.pyc differ
index 800458e329af3a0f5b2059fd6a639f2453d9dd37..34c28cf2aa5a7e90e43eb525e1639659909555c9 100644 (file)
Binary files a/Main/__pycache__/setup.cpython-310.pyc and b/Main/__pycache__/setup.cpython-310.pyc differ
index c274cebdb90fae9b13ce7eb127f94d1fbd0428bb..45cfd25fe0feff68f4e4671701de1ea96910b3fc 100644 (file)
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
new file mode 100644 (file)
index 0000000..7dd974e
Binary files /dev/null and b/Main/__pycache__/timer.cpython-310.pyc differ
index 4d258cd58aa32ffcfa0bff51e65c819f64fe547d..e4da1227ac47bb17e62f70e2bee295e727b1cd0f 100644 (file)
Binary files a/Main/__pycache__/word_connector.cpython-310.pyc and b/Main/__pycache__/word_connector.cpython-310.pyc differ
index be2ef95b818154bb547cc3ac7a6c017f5350c9fc..b4b7b646cec561affd509f00796f30671bef0c03 100644 (file)
Binary files a/Main/__pycache__/words_display.cpython-310.pyc and b/Main/__pycache__/words_display.cpython-310.pyc differ
index cddbd90ed05a4126ca4bfaa92efa7816a2c242d3..dbbba98c15450b51446b9361142810b0f450a91c 100644 (file)
@@ -5,6 +5,7 @@ from tile import Tile
 from board import Board
 from word_connector import WordConnector
 from words_display import UnknownWordDisplay
+from timer import Timer
 
 class Game:
     font = pygame.font.Font("font/Silkscreen-Regular.ttf", 40)
@@ -48,6 +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))
 
     def update(self, delta):
         self.word += self.board.update(delta, self.bg_colour, self.points)
@@ -75,6 +77,7 @@ class Game:
             self.bg_colour = self.correct_colour
 
         self.word_display = self.font.render(self.word, True, Colour.BLACK)
+        self.timer.update(delta)
 
     def draw(self, surf):
         surf.fill(Palette.primary_shade1)
@@ -89,7 +92,7 @@ class Game:
 
         self.word_connector.draw(surf)
         self.unknown_word_display.draw(surf)
-
+        self.timer.draw(surf)
         # pygame.draw.circle(surf, Colour.WHITE,r.center,5)
         # pygame.draw.line(surf, Colour.BLACK, (0, SCREEN_HEIGHT / 2), (SCREEN_WIDTH, SCREEN_HEIGHT / 2))
         # pygame.draw.line(surf, Colour.BLACK, (SCREEN_WIDTH / 2, 0), (SCREEN_WIDTH / 2, SCREEN_HEIGHT))
index cb2310faa22e8af0ce0f31deaa443497b844557e..a3eac6864ce8db7b8e9faa02337b2652c3265034 100644 (file)
@@ -1,7 +1,7 @@
 from setup import *
 from game import Game
 
-puzzle = f"puzzles/PuzzlePack{4}/puzzle{10}.txt"
+puzzle = f"puzzles/PuzzlePack{4}/puzzle{12}.txt"
 print(puzzle)
 scene = Game(puzzle)
 
diff --git a/Main/timer.py b/Main/timer.py
new file mode 100644 (file)
index 0000000..c7b1b0c
--- /dev/null
@@ -0,0 +1,19 @@
+from setup import *
+
+
+class Timer:
+    font = pygame.font.Font("font/Silkscreen-Regular.ttf", 30)
+
+    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)
+
+    def draw(self, surf):
+        surf.blit(self.text, self.text.get_rect(topleft =self.position))