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 = []
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
+import pygame
+
from setup import *
from tile import Tile
from board import Board
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
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)
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)))
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
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)
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
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:
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())
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:
# return True
-# print(check_word("andrew"))
+# print(check_word("anger"))
# print(check_word("awidnawiuohndoa"))
# print(check_word("awesome"))