-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathhue.py
82 lines (67 loc) · 2.3 KB
/
hue.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
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
import pygame,pygame.freetype, sys
from levelSetup import genRandomLevel, genMenuMatrix, genLevel
from helperFunctions import draw_circle, checkSorted, darkenColor
from areaselect import AreaSelect
pygame.init()
pygame.font.init()
ELVETICA = pygame.freetype.Font('assets/Elvetica-Regular.otf',50)
width = 600
height = 900
screen = pygame.display.set_mode((width,height))
pygame.display.set_caption("Hue")
icon = pygame.image.load("assets/icon.png").convert_alpha()
pygame.display.set_icon(icon)
class MainMenu(object):
def __init__(self):
self.width, self.height = pygame.display.get_surface().get_size()
self.buttonStart = pygame.Rect(300,800,300,100)
self.click = False
self.colorMatrix = self.matrix()
self.boxWidth = int(width/len(self.colorMatrix))
self.boxHeight = int(height/len(self.colorMatrix[0])*0.6)
self.main()
def matrix(self):
matrix = genMenuMatrix(6,5)
temp = matrix[1][1]
matrix[1][1] = matrix[4][3]
matrix[4][3] = temp
return matrix
def main(self):
running = True
while running:
self.eventHandling()
self.buttonHandling()
self.draw()
def eventHandling(self):
self.click = False
for event in pygame.event.get():
if event.type == pygame.QUIT:
running = False
pygame.quit()
sys.exit()
if event.type == pygame.KEYDOWN:
if event.key == pygame.K_ESCAPE:
running = False
pygame.quit()
sys.exit()
if event.key == pygame.K_r:
self.colorMatrix = self.matrix()
if event.type == pygame.MOUSEBUTTONDOWN:
self.click = True
def buttonHandling(self):
mx, my = pygame.mouse.get_pos()
if self.buttonStart.collidepoint((mx,my)):
if self.click:
pygame.time.delay(100)
AreaSelect()
def draw(self):
screen.fill((255,255,230))
for x,row in enumerate(self.colorMatrix):
for y,element in enumerate(row):
boxPosX = self.boxWidth * x
boxPosY = self.boxHeight * y
pygame.draw.rect(screen, element, pygame.Rect(boxPosX,boxPosY,self.boxWidth,self.boxHeight))
ELVETICA.render_to(screen,(320,820),"Start Game",(30,30,30))
pygame.display.update()
if __name__ == "__main__":
MainMenu()