0% found this document useful (0 votes)
3 views1 page

Tic Tac Toe

This document contains a Python class for a simple Tic-Tac-Toe game using the Pygame library. It initializes a game window, displays a title and a play button, and includes methods to check for user input and run the game loop. However, the switchToGame method is not implemented, and there is an incomplete conditional statement in the run method.

Uploaded by

gobeil.emile
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
3 views1 page

Tic Tac Toe

This document contains a Python class for a simple Tic-Tac-Toe game using the Pygame library. It initializes a game window, displays a title and a play button, and includes methods to check for user input and run the game loop. However, the switchToGame method is not implemented, and there is an incomplete conditional statement in the run method.

Uploaded by

gobeil.emile
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
You are on page 1/ 1

import pygame

class Game:
def __init__(self):
pygame.init()
self.screen = pygame.display.set_mode((600,600))
WHITE = (255,255,255)

self.screen.fill((50,40,255))

font = pygame.font.SysFont(None, 50)


img = font.render('TIC-TAC-TOE', True, WHITE)
self.screen.blit(img, (200, 50))

playButtonImg = pygame.image.load('play.png')
playButtonImg.convert()
self.screen.blit(playButtonImg, (200, 300))
self.playButton = pygame.Rect(200,300,200,200)
pygame.display.flip()

def switchToGame(self):

def checkForInput(self):
mousePosition = pygame.mouse.get_pos()
mouse_buttons = pygame.mouse.get_pressed()

if self.playButton.collidepoint(mousePosition) and any(mouse_buttons):


self.switchToGame()

def run(self):
running = True
while running:
if
self.checkForInput()
for event in pygame.event.get():
if event.type == pygame.QUIT:
pygame.quit()
pygame.init()
game = Game()
game.run()

You might also like