Commit bb7c00cd authored by Anurag Kumar's avatar Anurag Kumar

Upload new file

parent df3aafc2
import pygame
# Color used
BLUE = (0, 0, 255)
WHITE = (255, 255, 255)
BLACK = (0, 0, 0)
RED = (255, 0, 0)
YELLOW = (255, 255, 0)
LIGHTWOOD = (249, 248, 246)
WOOD=(202,164,114)
DARKWOOD=(184,134,69)
BLOODRED = (238,75,43)
#Constants
SQUARESIZE = 70
ROW = 6
COLUMN = 7
WIDTH, HEIGHT = COLUMN*SQUARESIZE, (ROW+2)*SQUARESIZE
FPS = 60
class Gui:
def __init__(self,WINDOW):
self.WINDOW = WINDOW
# pygame.init()
def draw_window(self,board):
for j in range(COLUMN):
for i in range(ROW):
pygame.draw.rect(self.WINDOW, LIGHTWOOD, (j * SQUARESIZE, (i + 2) * SQUARESIZE, SQUARESIZE, SQUARESIZE))
#Score board Row
pygame.draw.rect(self.WINDOW, WOOD, (0, 0, WIDTH, SQUARESIZE))
#Horizontal line saparate Navigation row and score board row
pygame.draw.line(self.WINDOW, WHITE, (0, SQUARESIZE), (WIDTH, SQUARESIZE), width=1)
# Horizontal line that spararate Score board row and Moving square row
pygame.draw.line(self.WINDOW, WHITE, (0, 2 * SQUARESIZE), (WIDTH, 2 * SQUARESIZE), width=1)
# verticle line
for i in range(COLUMN):
pygame.draw.line(self.WINDOW, BLACK, (SQUARESIZE + i * SQUARESIZE, 2 * SQUARESIZE),
((i + 1) * SQUARESIZE, COLUMN * SQUARESIZE + 2 * SQUARESIZE), width=3)
# Horizontal Line
for i in range(ROW + 3):
pygame.draw.line(self.WINDOW, BLACK, (0, (i + 3) * SQUARESIZE), (WIDTH, (i + 3) * SQUARESIZE), width=3)
#Square filling when mouse clicked
for j in range(COLUMN):
for i in range(ROW):
if (board[i][j] == 1):
pygame.draw.rect(self.WINDOW, BLUE, (
int(j * (SQUARESIZE)), HEIGHT - int((i + 1) * SQUARESIZE), SQUARESIZE - 1,
SQUARESIZE - 1))
if (board[i][j] == 2):
pygame.draw.rect(self.WINDOW, YELLOW, (
int(j * (SQUARESIZE)), HEIGHT - int((i + 1) * (SQUARESIZE)), SQUARESIZE - 1,
SQUARESIZE - 1))
pygame.display.update()
def show_score(self, SCORE_PLAYER1_X, SCORE_PLAYER1_Y, SCORE_PLAYER2_X, SCORE_PLAYER2_Y, player1_score,
player2_score,player1_name,player2_name):
font_player1 = pygame.font.SysFont("arial", 20)
font_player2 = pygame.font.SysFont("arial", 20)
score1 = font_player1.render(" {} score: ".format(player1_name) + str(player1_score), True, WHITE)
self.WINDOW.blit(score1, (SCORE_PLAYER1_X, SCORE_PLAYER1_Y))
score2 = font_player2.render("{} score: ".format(player2_name) + str(player2_score), True, WHITE)
self.WINDOW.blit(score2, (SCORE_PLAYER2_X, SCORE_PLAYER2_Y))
pygame.display.update()
\ No newline at end of file
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment