mainGame.py

PHOTO EMBED

Mon Aug 08 2022 20:06:51 GMT+0000 (Coordinated Universal Time)

Saved by @projectpython

# mainGame will store the class/functions
# used to run/monitor the main game

import pygame
import sys
from board import Board

# create a class called TicTacToe
# the overall code to manage game behaviors
class TicTacToe:
  
  def __init__(self):
    # Initialize game/resources
    pygame.init()
    
    # Create a screen attribute, which
    # controls the screen using pygame's
    # built-in screen method
    # add a title (Tic-Tac-Toe)
    
    self.screen = pygame.display.set_mode((800, 800))
    pygame.display.set_caption("Tic-Tac-Toe")
    
    # Create an attribute that stores the board object
    self.board = Board(self)
    
    # Draw board to screen
    self.board.blitme()
  
  # stores the instructions to run the main game
  def run_game(self):
    # Create a while loop for the main game
    # that runs until we need the game to stop
    
    while True:
      # Check all keyboard events that the user inputs
      for event in pygame.event.get():
        if event.type == pygame.QUIT:
          sys.exit()
      
      # Update the screen
      pygame.display.flip()
      
      
    
  

    
    
    
    
    
    
    
    
    
    
  
  
  
content_copyCOPY