-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathPart1.py
More file actions
53 lines (47 loc) · 1.29 KB
/
Copy pathPart1.py
File metadata and controls
53 lines (47 loc) · 1.29 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
import pygame as p
p.init()
class Square(p.sprite.Sprite):
def __init__(self,x_id,y_id,number):
super().__init__()
self.width = 120
self.height = 120
self.x = x_id * self.width
self.y = y_id * self.height
self.content = ' '
self.number = number
self.image = blank_image
self.image = p.transform.scale(self.image,(self.width,self.height))
self.rect =self.image.get_rect()
def update(self):
self.rect.center=(self.x,self.y)
def Update():
win.blit(background,(0,0))
square_group.draw(win)
square_group.update()
p.display.update()
WIDTH= 500
HEIGHT = 500
win = p.display.set_mode((WIDTH,HEIGHT))
p.display.set_caption('Tic Tac Toe')
clock = p.time.Clock()
blank_image = p.image.load('Blank.png')
x_image = p.image.load('x.png')
o_image = p.image.load('o.png')
background = p.image.load('Background.png')
background = p.transform.scale(background,(WIDTH,HEIGHT))
square_group = p.sprite.Group()
squares = []
num=1
for y in range(1,4):
for x in range(1,4):
sq = Square(x,y,num)
square_group.add(sq)
squares.append(sq)
num+=1
run =True
while run:
clock.tick(60)
for event in p.event.get():
if event.type == p.QUIT:
run = False
Update()