From: Skullheadx <94652084+Skullheadx@users.noreply.github.com> Date: Tue, 22 Nov 2022 22:14:06 +0000 (-0500) Subject: colour palette X-Git-Url: http://git.skullheadx.com/nixos/static/gitweb.js?a=commitdiff_plain;h=444d82cef4c7944757c6c5b35854beef649f4149;p=word-hunt.git colour palette --- diff --git a/Main/__pycache__/board.cpython-310.pyc b/Main/__pycache__/board.cpython-310.pyc index f25d6f4..cace1e7 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 2633402..0a852c9 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 2c2f107..4a854b8 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 450e962..f9ad3d2 100644 Binary files a/Main/__pycache__/tile.cpython-310.pyc and b/Main/__pycache__/tile.cpython-310.pyc differ diff --git a/Main/board.py b/Main/board.py index 89f5f8b..b3a0473 100644 --- a/Main/board.py +++ b/Main/board.py @@ -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 index 0000000..5610393 Binary files /dev/null and b/Main/colour_palette.pdf differ diff --git a/Main/game.py b/Main/game.py index 4e7caf6..b2a8423 100644 --- a/Main/game.py +++ b/Main/game.py @@ -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))) diff --git a/Main/main.py b/Main/main.py index 15e94d4..f431dff 100644 --- a/Main/main.py +++ b/Main/main.py @@ -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 diff --git a/Main/setup.py b/Main/setup.py index 0a2c2f7..64e9c3e 100644 --- a/Main/setup.py +++ b/Main/setup.py @@ -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) diff --git a/Main/tile.py b/Main/tile.py index fb21c0a..4d3ca4f 100644 --- a/Main/tile.py +++ b/Main/tile.py @@ -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()) diff --git a/Main/tree.py b/Main/tree.py index 5b0cdfa..f39aff4 100644 --- a/Main/tree.py +++ b/Main/tree.py @@ -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"))