import pygame class Board: #a class to manage the board #it's basically a package to store all #attributes/methods for the board #the game parameter is an instance #of the TicTacToe class def __init__(self, game): #Create the board and its attributes self.screen = game.screen self.screen_rect = game.screen.get_rect() #load the board image onto screen #and also get its "rect" self.image = pygame.image.load("tictactoeImage.png") self.rect = self.image.get_rect() #Center the board #positions image in horizontal center of screen self.rect.centerx = self.screen_rect.centerx #positions image at the top of the screen self.rect.top = self.screen_rect.top #blitme is going to draw the board to the screen def blitme(self): self.screen.blit(self.image, self.rect)
Preview:
downloadDownload PNG
downloadDownload JPEG
downloadDownload SVG
Tip: You can change the style, width & colours of the snippet with the inspect tool before clicking Download!
Click to optimize width for Twitter