-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathGridSquare.py
More file actions
32 lines (25 loc) · 944 Bytes
/
GridSquare.py
File metadata and controls
32 lines (25 loc) · 944 Bytes
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
import pygame
class GridSquare:
def __init__(self,col,row,width=50,color=(0,255,0)):
self.width=width
self.row = row
self.col = col
self.y = self.row * self.width
self.x = self.col * self.width
self.color=color
def add(self, other):
self.row = self.row + other[1]
self.col = self.col + other[0]
self.y = self.row * self.width
self.x = self.col * self.width
return self
def sub(self, other):
self.row = self.row - other[1]
self.col = self.col - other[0]
self.y = self.row * self.width
self.x = self.col * self.width
return self
def draw(self,win):
pygame.draw.rect(win,self.color,(self.x,self.y,self.width,self.width))
for i in range(4):
pygame.draw.rect(win, (255, 255, 255), (self.x - i/10, self.y - i/10, self.width, self.width), 1)