tictactoe.py - import pygame as pg,sys from pygame.locals import import time#initialize global variables XO ='x winner = None draw = False width = 400

tictactoe.py - import pygame as pg,sys from pygame.locals...

This preview shows page 1 - 2 out of 4 pages.

import pygame as pg,sys from pygame.locals import * import time #initialize global variables XO = 'x' winner = None draw = False width = 400 height = 400 white = (255, 255, 255) line_color = (10,10,10) #TicTacToe 3x3 board TTT = [[None]*3,[None]*3,[None]*3] #initializing pygame window pg.init() fps = 30 CLOCK = pg.time.Clock() screen = pg.display.set_mode((width, height+100),0,32) pg.display.set_caption("Tic Tac Toe") #loading the images opening = pg.image.load('tic tac opening.png') x_img = pg.image.load('x.png') o_img = pg.image.load('o.png') #resizing images x_img = pg.transform.scale(x_img, (80,80)) o_img = pg.transform.scale(o_img, (80,80)) opening = pg.transform.scale(opening, (width, height+100)) def game_opening(): screen.blit(opening,(0,0)) pg.display.update() time.sleep(1) screen.fill(white) # Drawing vertical lines pg.draw.line(screen,line_color,(width/3,0),(width/3, height),7) pg.draw.line(screen,line_color,(width/3*2,0),(width/3*2, height),7) # Drawing horizontal lines pg.draw.line(screen,line_color,(0,height/3),(width, height/3),7) pg.draw.line(screen,line_color,(0,height/3*2),(width, height/3*2),7) draw_status() def draw_status():

  • Left Quote Icon

    Student Picture

  • Left Quote Icon

    Student Picture

  • Left Quote Icon

    Student Picture