]> Skullheadx's Git Forge - word-hunt.git/commitdiff
colour palette
authorSkullheadx <94652084+Skullheadx@users.noreply.github.com>
Tue, 22 Nov 2022 22:14:06 +0000 (17:14 -0500)
committerSkullheadx <94652084+Skullheadx@users.noreply.github.com>
Tue, 22 Nov 2022 22:14:06 +0000 (17:14 -0500)
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/board.py
Main/colour_palette.pdf [new file with mode: 0644]
Main/game.py
Main/main.py
Main/setup.py
Main/tile.py
Main/tree.py

index f25d6f4acb44f9f7d072e741791a136d3a620e7d..cace1e7226fa001f64ee123752b7e1bf23440967 100644 (file)
Binary files a/Main/__pycache__/board.cpython-310.pyc and b/Main/__pycache__/board.cpython-310.pyc differ
index 2633402d5b29b14051491564b5fbb9674b7dce13..0a852c987a4f882f6307625949e7c7f73dc7a4dc 100644 (file)
Binary files a/Main/__pycache__/game.cpython-310.pyc and b/Main/__pycache__/game.cpython-310.pyc differ
index 2c2f107aa9759a06384b665035f0e4431fadbc3c..4a854b823fc75af541887c63614ba826a555739f 100644 (file)
Binary files a/Main/__pycache__/setup.cpython-310.pyc and b/Main/__pycache__/setup.cpython-310.pyc differ
index 450e962d029f0b585c829ba98dccdcdf9d60f1b1..f9ad3d25f3a7aa82613119e36c17887c5edce4ef 100644 (file)
Binary files a/Main/__pycache__/tile.cpython-310.pyc and b/Main/__pycache__/tile.cpython-310.pyc differ
index 89f5f8b4077154306a70d6134704accf2ea3b2ed..b3a0473f36950d430c96fcef759b9dc3d2f12a6a 100644 (file)
@@ -8,7 +8,7 @@ class Board:
         self.position = pygame.Vector2(position)
         self.length = length
         self.width = width
-        self.board = [[Tile((self.position.x + col * Tile.side_length, self.position.y + row * Tile.side_length),
+        self.board = [[Tile((self.position.x + col * (Tile.side_length+Tile.separation_distance), self.position.y + row * (Tile.side_length+Tile.separation_distance)),
                             letters[row * self.width + col]) for col in range(self.width)][:] for row in range(self.length)]
 
         self.tiles = []
@@ -36,8 +36,8 @@ class Board:
         return letter
 
     def draw(self, surf):
-        pygame.draw.rect(surf, Colour.BLACK, pygame.Rect(self.position - pygame.Vector2(Tile.bezel / 2), (
-            self.length * Tile.side_length + Tile.bezel, self.width * Tile.side_length + Tile.bezel)))
+        pygame.draw.rect(surf, Colour.BLACK, pygame.Rect(self.position - pygame.Vector2(Tile.bezel / 2), (
+            self.length * Tile.side_length + Tile.bezel, self.width * Tile.side_length + Tile.bezel)))
         for tile in self.tiles:
             tile.draw(surf)
         # debug
diff --git a/Main/colour_palette.pdf b/Main/colour_palette.pdf
new file mode 100644 (file)
index 0000000..5610393
Binary files /dev/null and b/Main/colour_palette.pdf differ
index 4e7caf6c38f307138d91946a8ce0501a5b5ac763..b2a8423b2287a350dfce6302e783b7b6d16c18b6 100644 (file)
@@ -1,3 +1,5 @@
+import pygame
+
 from setup import *
 from tile import Tile
 from board import Board
@@ -7,7 +9,9 @@ class Game:
     font = pygame.font.Font("font/Silkscreen-Regular.ttf", 40)
     text_font = pygame.font.Font("font/Silkscreen-Regular.ttf", 20)
     title_font = pygame.font.Font("font/Silkscreen-Regular.ttf", 75)
-
+    inset = 15
+    edge_radius = 25
+    border_width = 8
     def __init__(self, imported_file_name=None):
         if imported_file_name is None:
             length, width = 4, 4
@@ -35,7 +39,7 @@ class Game:
     def update(self, delta):
         self.word += self.board.update(delta)
         if not pygame.mouse.get_pressed(3)[0]:  # mouse not down
-            if self.word in word_list:
+            if self.word in word_list and self.word not in self.seen:
                 self.seen.add(self.word)
                 self.points += 10 ** (len(self.word)-2)
                 self.points_display = self.text_font.render(f"Score: {self.points}", True, Colour.BLACK)
@@ -52,7 +56,11 @@ class Game:
         self.word_display = self.font.render(self.word, True, Colour.BLACK, bg_colour)
 
     def draw(self, surf):
+        surf.fill(Palette.primary_shade1)
+        pygame.draw.rect(surf, Palette.primary_shade2, pygame.Rect((self.board.position.x - self.inset, self.board.position.y - self.points_display.get_rect().height - self.inset), (self.inset *2+ self.board.length * (Tile.side_length + Tile.separation_distance) - Tile.separation_distance, self.inset*2 +self.points_display.get_rect().height+ self.board.width * (Tile.side_length + Tile.separation_distance)- Tile.separation_distance)),border_radius=self.edge_radius)
+        pygame.draw.rect(surf, Palette.secondary_shade0, pygame.Rect((self.board.position.x - self.inset, self.board.position.y - self.points_display.get_rect().height - self.inset), (self.inset *2+ self.board.length * (Tile.side_length + Tile.separation_distance)- Tile.separation_distance, self.inset*2 +self.points_display.get_rect().height+ self.board.width * (Tile.side_length + Tile.separation_distance)- Tile.separation_distance)),border_radius=self.edge_radius, width=self.border_width)
+
         self.board.draw(surf)
         surf.blit(self.word_display, self.word_display.get_rect(center=(center.x, SCREEN_HEIGHT / 5)))
         surf.blit(self.title, self.title.get_rect(center=(center.x, SCREEN_HEIGHT / 10)))
-        surf.blit(self.points_display, self.points_display.get_rect(bottomleft=self.board.position))
+        surf.blit(self.points_display, self.points_display.get_rect(bottomleft=self.board.position + pygame.Vector2(0,-Tile.separation_distance)))
index 15e94d4d188c9bc0833da84645f2b84af3574762..f431dff0b2ebc8e782a8733099a7a9e8c971ccdd 100644 (file)
@@ -1,14 +1,15 @@
 from setup import *
 from game import Game
 
-puzzle = f"puzzles/PuzzlePack{5}/puzzle{random.randint(1,4)}.txt"
+puzzle = f"puzzles/PuzzlePack{4}/puzzle{3}.txt"
+print(puzzle)
 scene = Game(puzzle)
 
 is_running = True
 delta = 1000/fps
 
 while is_running:
-    screen.fill(Colour.WHITE)
+    screen.fill(Colour.WHITE)
 
     if pygame.event.peek(pygame.QUIT):
         is_running = False
index 0a2c2f7a0311ce6a77c61270381485ce48b7e8c8..64e9c3ee9994b45b3b15ddf992430df1be0f4fd7 100644 (file)
@@ -36,3 +36,23 @@ class Colour:
     GREEN = (0, 255, 0)
     BLUE = (0, 0, 255)
     YELLOW = (255 / 2, 255 / 2, 0)
+
+
+class Palette:
+    primary_shade0 = (43, 128, 62)
+    primary_shade1 = (128, 193, 143)
+    primary_shade2 = (80, 161, 98)
+    primary_shade3 = (16, 96, 34)
+    primary_shade4 = (4, 80, 21)
+
+    secondary_shade0 = (170, 112, 57)
+    secondary_shade1 = (255, 211, 170)
+    secondary_shade2 = (212, 158, 106)
+    secondary_shade3 = (128, 73, 21)
+    secondary_shade4 = (106, 55, 6)
+
+    tertiary_shade0 = (141, 47, 93)
+    tertiary_shade1 = (211, 141, 175)
+    tertiary_shade2 = (176, 88, 131)
+    tertiary_shade3 = (106, 18, 61)
+    tertiary_shade4 = (88, 5, 46)
index fb21c0aa3598b305bf3bf0335e6e69ef0b03e7b6..4d3ca4f7dd80903dc655b24351c46de207c35dad 100644 (file)
@@ -6,8 +6,12 @@ class Tile:
     side_length = 80
     bezel = 5
     cutoff = 8
+    edge_radius = 15
+    separation_distance = 7.5
+
     font = pygame.font.Font("font/Silkscreen-Regular.ttf", 20)
 
+
     def __init__(self, position, letter):
         self.position = pygame.Vector2(position)
         self.selected = False
@@ -16,7 +20,7 @@ class Tile:
         self.neighbors = []
         for i in range(-1,2):
             for j in range(-1,2):
-                self.neighbors.append(self.position + pygame.Vector2(i * self.side_length, j * self.side_length))
+                self.neighbors.append(self.position + pygame.Vector2(i * (self.side_length + self.separation_distance), j * (self.side_length+ self.separation_distance)))
 
     def update(self, delta, neighbors):
         if not self.selected and pygame.mouse.get_pressed()[0] and self.get_collision_rect().collidepoint(pygame.mouse.get_pos()) and self.position in neighbors:
@@ -35,10 +39,10 @@ class Tile:
 
     def draw(self, surf):
         if self.selected:
-            pygame.draw.rect(surf, Colour.LIGHT_GRAY, self.get_rect())
+            pygame.draw.rect(surf, Palette.secondary_shade2, self.get_rect(),border_radius=self.edge_radius)
         else:
-            pygame.draw.rect(surf, Colour.GRAY, self.get_rect())
-        pygame.draw.rect(surf,Colour.BLACK,self.get_rect(),self.bezel)
+            pygame.draw.rect(surf, Palette.secondary_shade0, self.get_rect(),border_radius=self.edge_radius)
+        pygame.draw.rect(surf,Palette.tertiary_shade4,self.get_rect(),self.bezel,border_radius=self.edge_radius)
 
         # debug
         # pygame.draw.rect(surf, Colour.RED, self.get_collision_rect())
index 5b0cdfa735863898bb51bc78e9c6b52177302b1f..f39aff477451cb2bd77046e1a96449f74c026a73 100644 (file)
@@ -26,7 +26,7 @@ def create_tree():
         word_list = json.load(f)
     root = Tree('')
 
-    # word_list = ['andrew', 'angry', 'awesome']
+    # word_list = ['anger', 'angry', 'awesome']
     for word in word_list:
         branch = root
         for letter in word:
@@ -57,6 +57,6 @@ def create_tree():
 #     return True
 
 
-# print(check_word("andrew"))
+# print(check_word("anger"))
 # print(check_word("awidnawiuohndoa"))
 # print(check_word("awesome"))