-
Notifications
You must be signed in to change notification settings - Fork 0
/
thing.py
32 lines (22 loc) · 803 Bytes
/
thing.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
import pygame
GREEN = (0,255,0)
BLACK = (0,0,0)
class Thing:
def __init__(self, x, y, width, height, pile_number, color=GREEN):
self.color = color
self.x = x
self.y = y
self.width = width
self.height = height
self.pile_number = pile_number
def draw(self, scr, outline=BLACK):
if outline:
pygame.draw.rect(scr, outline, (self.x-2, self.y-2, self.width+4, self.height+4), 0)
pygame.draw.rect(scr, self.color, (self.x, self.y, self.width, self.height), 0)
def isOver(self, pos):
mouse_x = pos[0]
mouse_y = pos[1]
if mouse_x > self.x and mouse_x < self.x + self.width:
if mouse_y > self.y and mouse_y < self.y + self.height:
return True
return False