-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathATM.py
257 lines (216 loc) · 11.1 KB
/
ATM.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
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
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
import pygame
import sys
# initializing the constructor
pygame.init()
# screen resolution
res = (720, 720)
# opens up a window
screen = pygame.display.set_mode(res)
# white color
color = (255, 255, 255)
# light shade of the button
color_light = (170, 170, 170)
# dark shade of the button
color_dark = (100, 100, 100)
# stores the width of the
# screen into a variable
width = screen.get_width()
# stores the height of the
# screen into a variable
height = screen.get_height()
# defining a font
smallfont = pygame.font.SysFont('Corbel', 35)
# rendering a text written in
# this font
text = smallfont.render('quit', True, color)
# used to determine which screen to display
menu = "PIN"
def draw_numpad(pos):
#if statement changes with eye tracker
if (width / 4) + 200 <= pos[0] <= (width / 4) + 299 and (height / 4) + 300 <= pos[1] <= (height / 4) + 399:
pygame.draw.rect(screen, color_light, [(width / 4) + 200, (height / 4) + 300, 99, 99])
count = 1
for i in range(3):
for j in range(3):
pygame.draw.rect(screen, color_dark, [(width / 4) + (j * 100), (height / 4) + (i * 100), 99, 99])
if count == 1:
text = smallfont.render('1', True, color)
count += 1
elif count == 2:
text = smallfont.render('2', True, color)
count += 1
elif count == 3:
text = smallfont.render('3', True, color)
count += 1
elif count == 4:
text = smallfont.render('4', True, color)
count += 1
elif count == 5:
text = smallfont.render('5', True, color)
count += 1
elif count == 6:
text = smallfont.render('6', True, color)
count += 1
elif count == 7:
text = smallfont.render('7', True, color)
count += 1
elif count == 8:
text = smallfont.render('8', True, color)
count += 1
elif count == 9:
text = smallfont.render('9', True, color)
count += 1
screen.blit(text, ((width / 4) + (j * 100) + 50, (height / 4) + (i * 100) + 50))
pygame.draw.rect(screen, color_dark, [(width / 4) + (100), (height / 4) + (300), 99, 99])
text = smallfont.render('0', True, color)
screen.blit(text, ((width / 4) + (150), (height / 4) + (350)))
text = smallfont.render('Enter', True, color)
screen.blit(text, ((width / 4) + (210), (height / 4) + (350)))
else:
count = 1
for i in range(3):
for j in range(3):
pygame.draw.rect(screen, color_dark, [(width / 4) + (j * 100), (height / 4) + (i * 100), 99, 99])
if count == 1:
text = smallfont.render('1', True, color)
count += 1
elif count == 2:
text = smallfont.render('2', True, color)
count += 1
elif count == 3:
text = smallfont.render('3', True, color)
count += 1
elif count == 4:
text = smallfont.render('4', True, color)
count += 1
elif count == 5:
text = smallfont.render('5', True, color)
count += 1
elif count == 6:
text = smallfont.render('6', True, color)
count += 1
elif count == 7:
text = smallfont.render('7', True, color)
count += 1
elif count == 8:
text = smallfont.render('8', True, color)
count += 1
elif count == 9:
text = smallfont.render('9', True, color)
count += 1
screen.blit(text, ((width / 4) + (j * 100) + 50, (height / 4) + (i * 100) + 50))
pygame.draw.rect(screen, color_dark, [(width / 4) + (100), (height / 4) + (300), 99, 99])
text = smallfont.render('0', True, color)
screen.blit(text, ((width / 4) + (150), (height / 4) + (350)))
pygame.draw.rect(screen, color_dark, [(width / 4) + (200), (height / 4) + (300), 99, 99])
text = smallfont.render('Enter', True, color)
screen.blit(text, ((width / 4) + (210), (height / 4) + (350)))
while True:
for ev in pygame.event.get():
if ev.type == pygame.QUIT:
pygame.quit()
# checks if a mouse is clicked
#this can all be changed to track inputs from eye tracker
if ev.type == pygame.MOUSEBUTTONDOWN:
# if the mouse is clicked on the
# button the game is terminated
if menu == "DorW" and width / 3 <= mouse[0] <= width / 3 + 140 and height / 2 <= mouse[
1] <= height / 2 + 40:
menu = "Deposit"
elif menu == "DorW" and width / 1.5 <= mouse[0] <= width / 1.5 + 180 and height / 2 <= mouse[1] <= height / 2 + 40:
menu = "Withdrawal"
elif menu == "PIN" and (width / 4) + 200 <= mouse[0] <= (width / 4) + 299 and (height / 4) + 300 <= mouse[1] <= (height / 4) + 399:
menu = "DorW"
elif menu == "Deposit" and (width / 4) + 200 <= mouse[0] <= (width / 4) + 299 and (height / 4) + 300 <= mouse[1] <= (height / 4) + 399:
menu = "PostD"
elif menu == "Withdrawal" and (width / 4) + 200 <= mouse[0] <= (width / 4) + 299 and (height / 4) + 300 <= mouse[1] <= (height / 4) + 399:
menu = "PostW"
elif (menu == "PostD" or menu == "PostW") and width / 3 <= mouse[0] <= width / 3 + 140 and height / 2 <= mouse[1] <= height / 2 + 40:
menu = "DorW"
elif (menu == "PostD" or menu == "PostW") and width / 1.5 <= mouse[0] <= width / 1.5 + 180 and height / 2 <= mouse[1] <= height / 2 + 40:
pygame.quit()
# fills the screen with a color
screen.fill((60, 25, 60))
if menu == "DorW":
# stores the (x,y) coordinates into
# the variable as a tuple
mouse = pygame.mouse.get_pos()
text = smallfont.render("Deposit or Withdrawal?", True, color)
screen.blit(text, (width / 4, 50))
# if mouse is hovered on a button it
# changes to lighter shade
# if statement changes with eye tracker
if width / 3 <= mouse[0] <= width / 3 + 140 and height / 2 <= mouse[1] <= height / 2 + 40:
pygame.draw.rect(screen, color_light, [width / 3, height / 2, 140, 40])
pygame.draw.rect(screen, color_dark, [width / 1.5, height / 2, 180, 40])
elif width / 1.5 <= mouse[0] <= width / 1.5 + 180 and height / 2 <= mouse[1] <= height / 2 + 40:
pygame.draw.rect(screen, color_light, [width / 1.5, height / 2, 180, 40])
pygame.draw.rect(screen, color_dark, [width / 3, height / 2, 140, 40])
else:
pygame.draw.rect(screen, color_dark, [width / 3, height / 2, 140, 40])
pygame.draw.rect(screen, color_dark, [width / 1.5, height / 2, 180, 40])
# superimposing the text onto our button
text = smallfont.render('Deposit', True, color)
screen.blit(text, (width / 3, height / 2))
text = smallfont.render('Withdrawal', True, color)
screen.blit(text, (width / 1.5, height / 2))
elif menu == "PIN":
mouse = pygame.mouse.get_pos()
text = smallfont.render("Please enter your PIN", True, color)
screen.blit(text, (width / 4, 50))
draw_numpad(mouse)
elif menu == "Deposit":
mouse = pygame.mouse.get_pos()
text = smallfont.render("Input Deposit amount:", True, color)
screen.blit(text, (width / 4, 50))
draw_numpad(mouse)
elif menu == "Withdrawal":
mouse = pygame.mouse.get_pos()
text = smallfont.render("Input Withdrawal amount:", True, color)
screen.blit(text, (width / 4, 50))
draw_numpad(mouse)
elif menu == "PostD":
#This can be taken out when we get the eye tracker working
mouse = pygame.mouse.get_pos()
text = smallfont.render("Your money has been deposited.", True, color)
screen.blit(text, (width / 4, 50))
text = smallfont.render("Would you like to make another transaction?", True, color)
screen.blit(text, (width / 8, 100))
#if statements will change with eye tracker
if width / 3 <= mouse[0] <= width / 3 + 100 and height / 2 <= mouse[1] <= height / 2 + 40:
pygame.draw.rect(screen, color_light, [width / 3, height / 2, 100, 40])
pygame.draw.rect(screen, color_dark, [width / 1.5, height / 2, 100, 40])
elif width / 1.5 <= mouse[0] <= width / 1.5 + 100 and height / 2 <= mouse[1] <= height / 2 + 40:
pygame.draw.rect(screen, color_light, [width / 1.5, height / 2, 100, 40])
pygame.draw.rect(screen, color_dark, [width / 3, height / 2, 100, 40])
else:
pygame.draw.rect(screen, color_dark, [width / 3, height / 2, 100, 40])
pygame.draw.rect(screen, color_dark, [width / 1.5, height / 2, 100, 40])
# superimposing the text onto our button
text = smallfont.render('Yes', True, color)
screen.blit(text, (width / 3, height / 2))
text = smallfont.render('No', True, color)
screen.blit(text, (width / 1.5, height / 2))
elif menu == "PostW":
mouse = pygame.mouse.get_pos()
text = smallfont.render("Please take your withdrawal.", True, color)
screen.blit(text, (width / 4, 50))
text = smallfont.render("Would you like to make another transaction?", True, color)
screen.blit(text, (width / 8, 100))
#if statements change with eye tracker
if width / 3 <= mouse[0] <= width / 3 + 100 and height / 2 <= mouse[1] <= height / 2 + 40:
pygame.draw.rect(screen, color_light, [width / 3, height / 2, 100, 40])
pygame.draw.rect(screen, color_dark, [width / 1.5, height / 2, 100, 40])
elif width / 1.5 <= mouse[0] <= width / 1.5 + 180 and height / 2 <= mouse[1] <= height / 2 + 40:
pygame.draw.rect(screen, color_light, [width / 1.5, height / 2, 100, 40])
pygame.draw.rect(screen, color_dark, [width / 3, height / 2, 100, 40])
else:
pygame.draw.rect(screen, color_dark, [width / 3, height / 2, 100, 40])
pygame.draw.rect(screen, color_dark, [width / 1.5, height / 2, 100, 40])
# superimposing the text onto our button
text = smallfont.render('Yes', True, color)
screen.blit(text, (width / 3, height / 2))
text = smallfont.render('No', True, color)
screen.blit(text, (width / 1.5, height / 2))
# updates the frames of the game
pygame.display.update()