-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathspot.py
56 lines (44 loc) · 1.32 KB
/
spot.py
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
54
55
56
import pygame
import random
import math
WIDTH, HEIGHT = 800, 800
RED = (255, 0, 0)
GREEN = (0, 255, 0)
BLUE = (0, 0, 255)
YELLOW = (255, 255, 0)
WHITE = (255, 255, 255)
BLACK = (0, 0, 0)
PURPLE = (128, 0, 128)
ORANGE = (255, 165, 0)
GREY = (128, 128, 128)
CYAN = (0, 255, 255)
class Spot:
def __init__(self, index, WIDTH):
self.val = 0
self.row = index[0]
self.col = index[1]
self.x = self.row *225 + 25
self.y = self.col*225 + 25
self.width = 200
def isEmpty(self):
return self.val == 0
def isCross(self):
return self.val == 1
def isDot(self):
return self.val == -1
def makeEmpty(self):
self.val = 0
def makeCross(self):
self.val = 1
def makeDot(self):
self.val = -1
def draw(self, window):
pygame.draw.rect(window, WHITE, (self.x, self.y, self.width, self.width), 0)
if self.val == 1:
img = pygame.image.load("cross.png")
img = pygame.transform.scale(img, (150, 150))
window.blit(img, (self.x + 25, self.y + 25))
if self.val == -1:
img = pygame.image.load("dot.png")
img = pygame.transform.scale(img, (150, 150))
window.blit(img, (self.x + 25, self.y + 25))