# Arup Guha
# 6/19/2024
# Stores a few functions both wordlegame and wordlefile use.

import pygame, sys
from pygame.locals import *

# Useful Constants
SCREEN_W = 480
SCREEN_H = 600
SQ_SIZE = 60
ROWS = 6
COLS = 5

# Returns the point at the top left
def mapTopLeft(r,c):

    myx = 50 + 80*c
    myy = 20 + 80*r
    return (myx, myy)

# Returns the point at the top left
def mapCharTopLeft(r,c):

    myx = 50 + 80*c + 10
    myy = 20 + 80*r + 10
    return (myx, myy)

# Function to put text onto the screen.
def draw(text, font, color, surface, x, y):
    # Draw text on a new Surface. Title, antialias and color are used.
    text = font.render(text, 1, color)

    # Returns a new rectangle covering the entire surface.
    # This rectangle will always start at (0, 0) with a width and height the same size as the image.
    textrect = text.get_rect()

    # Sets location of text.
    textrect.topleft = (x, y)

    # Go ahead and draw it to the surface.
    surface.blit(text, textrect)

# Draws an empty board.    
def drawEmptyBoard():

    # I don't need to pass it in!
    DISPLAYSURF = pygame.display.get_surface()
    DISPLAYSURF.fill("white")

    # Go through each row and column and draw the corresponding square.
    for i in range(ROWS):
        for j in range(COLS):
            pt = mapTopLeft(i,j)
            pygame.draw.rect(DISPLAYSURF, "black", (pt[0], pt[1], SQ_SIZE, SQ_SIZE), 1)
