-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy paththe matrix.py
More file actions
238 lines (174 loc) · 5.71 KB
/
the matrix.py
File metadata and controls
238 lines (174 loc) · 5.71 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
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
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
import pygame, sys, time, random
from pygame.locals import *
#setup pygame
pygame.init()
mainClock = pygame.time.Clock()
#setup window
WINDOWHEIGHT = 500
WINDOWWIDTH = 500
windowSurface = pygame.display.set_mode((WINDOWWIDTH, WINDOWHEIGHT), 0, 32)
pygame.display.set_caption('the experiment')
MousePos=pygame.mouse.get_pos()
#colors
RED = (255, 0, 0)
TURQUOISE = (0, 255, 255)
GRAY = (128, 128, 128)
BLACK = (0, 0, 0)
YELLOW = (255, 255, 0)
#text
font = pygame.font.SysFont(None, 48)
basicFont = pygame.font.SysFont(None, 48)
def drawText(text, font, surface,x,y):
textobj = font.render(text, 1, textColour)
textrect = textobj.get_rect()
textrect.topleft = (x, y)
surface.blit(textobj, textrect)
sprite1 = pygame.image.load('wheatly.png')
red = pygame.Rect(300,300,100,100)
redImage = sprite1
redStretchedImage = pygame.transform.scale(redImage,(100, 100))
notred = pygame.Rect(300,300,100,100)
notredImage = sprite1
notredStretchedImage = pygame.transform.scale(notredImage,(100, 100))
A = [0, 1, 2, 3, 4]
B = [0, 1, 2, 3, 4]
C = [0, 1, 2, 3, 4]
D = [0, 1, 2, 3, 4]
E = [0, 1, 2, 3, 4]
A[0] = (0,0)
A[1] = (100,0)
A[2] = (200,0)
A[3] = (300,0)
A[4] = (400,0)
B[0] = (0,100)
B[1] = (100,100)
B[2] = (200,100)
B[3] = (300,100)
B[4] = (400,100)
C[0] = (0,200)
C[1] = (100,200)
C[2] = (200,200)
C[3] = (300,200)
C[4] = (400,200)
D[0] = (0,300)
D[1] = (100,300)
D[2] = (200,300)
D[3] = (300,300)
D[4] = (400,300)
E[0] = (0,400)
E[1] = (100,400)
E[2] = (200,400)
E[3] = (300,400)
E[4] = (400,400)
MATRIX = [A, B, C, D, E]
SELECTING = []
MOVESPEED = 100
placement = B[4]
selected = 1
RED = [red]
area = D[1]
D1occupied = False
boop = True
materials = []
gameplay=True
background = pygame.Rect(0, 0, 500, 500)
backgroundImage = pygame.image.load('PURPLE.png')
backgroundStretchedImage = pygame.transform.scale(backgroundImage,(500, 500))
def confirm():
global D1occupied
if D1occupied == True:
print ('holycrapitworked')
if D1occupied == False:
print ('crrraaaaaappppp')
def Gameplay():
global red, D1occupied, placement, area, SELECTING, notred, boop, selected
while gameplay==True:
for event in pygame.event.get():
if event.type == KEYDOWN:
if event.key == ord('p'):
confirm()
if event.key == ord('a'):
SELECTING.append(A)
if event.key == ord('b'):
SELECTING.append(B)
if event.key == ord('c'):
SELECTING.append(C)
if event.key == ord('d'):
SELECTING.append(D)
if event.key == ord('e'):
SELECTING.append(E)
if event.key == ord('1'):
placement = SELECTING[0][0]
if event.key == ord('2'):
placement = SELECTING[0][1]
if event.key == ord('3'):
placement = SELECTING[0][2]
if event.key == ord('4'):
placement = SELECTING[0][3]
if event.key == ord('5'):
placement = SELECTING[0][4]
if event.key == ord('r'):
selected = 1
placement = red
if event.key == ord('n'):
selected = 2
placement = notred
if event.key == ord(' '):
if RED[0] == red:
print ('gsdvhifsivleuvogi')
if RED[0] != red:
print ('fuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuu')
if event.key == K_ESCAPE:
pygame.quit()
sys.exit(0)
if event.type == KEYUP:
if event.key == ord('a'):
SELECTING.remove(A)
if event.key == ord('b'):
SELECTING.remove(B)
if event.key == ord('c'):
SELECTING.remove(C)
if event.key == ord('d'):
SELECTING.remove(D)
if event.key == ord('e'):
SELECTING.remove(E)
if event.type == QUIT:
pygame.quit()
sys.exit()
if selected == 1:
red = pygame.Rect(placement[0], placement[1],100,100)
if selected == 2:
notred = pygame.Rect(placement[0], placement[1],100,100)
if MOVESPEED == 47328564562134120:
MousePos=pygame.mouse.get_pos()
for red in RED:
if 0 > placement[0]:
red.left -= MOVESPEED
if 0 < placement[0]:
red.right += MOVESPEED
if 0 > placement[1]:
red.top -= MOVESPEED
if 0 < placement[1]:
red.bottom += MOVESPEED
for notred in RED:
if 0 > placement[0]:
notred.left -= MOVESPEED
if 0 < placement[0]:
notred.right += MOVESPEED
if 0 > placement[1]:
notred.top -= MOVESPEED
if 0 < placement[1]:
notred.bottom += MOVESPEED
windowSurface.fill(GRAY)
windowSurface.blit(backgroundStretchedImage, background)
if True:
windowSurface.blit(redStretchedImage, red)
if True:
windowSurface.blit(notredStretchedImage, notred)
if red.left == area[0] and red.top == area[1]:
D1occupied = True
if red.left != area[0] and red.top != area[1]:
D1occupied = False
pygame.display.update()
mainClock.tick(50)
Gameplay()