-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathAlgoTeach.py
146 lines (129 loc) · 5.76 KB
/
AlgoTeach.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
#!/usr/bin/python
#-*- coding: utf-8 -*-
try:
import pygame
from pygame.locals import *
from files import *
from image import *
from box_1 import Box_1
from box_2 import Box_2
except:
print 'Error importing modules required.'
exit(0)
class Game():
def __init__(self):
pygame.init()
self.run = True
self.history = [[False, False, False],[False, False, False]]
self.current = 0
self.current_1 = 0
self.current2 = 0
self.current_2 = 0
self.surface = pygame.display.set_mode((800,600))
pygame.display.set_caption('JOED - Jogos Educacionais - ALGOTEACH')
#Images
self.background = Image(self.surface, background)
self.button_main= Image(self.surface, button_main)
self.map = Image(self.surface, map)
self.right_box_0 = Image(self.surface, right_box_0)
self.selection = Image(self.surface, selection)
self.selection_1 = Image(self.surface, selection_1)
self.mouse = pygame.image.load(ball)
def back_menu(self, event):
if self.xy[0] > 25 and self.xy[0] < 110 and self.xy[1] > 480 and self.xy[1] < 520:
if event.type == MOUSEBUTTONDOWN:
if event.button == 1:
try:
self.box_1.exit()
except:
pass
try:
self.box_2.exit()
except:
pass
self.current = 0
self.current_1 = 0
self.current2 = 0
self.current_2 = 0
def loop(self):
while self.run:
for event in pygame.event.get():
if event.type == QUIT or (event.type == KEYDOWN and event.key == K_ESCAPE):
self.run = False
self.xy = pygame.mouse.get_pos()
self.background.show()
self.right_box_0.show()
self.button_main.show((25, 480))
self.map.show()
#BICICLETARIO
if self.current == 0 and self.current2 == 0 and self.xy[0] > 401 and self.xy[0] < 496 and self.xy[1] > 486 and self.xy[1] < 557:
self.selection.show((398, 467))
for event in pygame.event.get():
if event.type == MOUSEBUTTONDOWN:
if event.button == 1:
self.box_1 = Box_1(self.map, self.background, self.surface, self.right_box_0)
self.current = 1
#ESTACIONAMENTO
if self.current == 0 and self.current2 == 0 and self.xy[0] > 415 and self.xy[0] < 496 and self.xy[1] > 122 and self.xy[1] < 385:
self.selection_1.show((415, 112))
for event in pygame.event.get():
if event.type == MOUSEBUTTONDOWN:
if event.button == 1:
self.box_2 = Box_2(self.map, self.background, self.surface, self.right_box_0)
self.current2 = 1
#VOLTAR
if self.current == 1:# or self.current2 == 1:
self.back_menu(event)
if self.current_1 == 1:
self.box_1.show_help(self.xy, event)
self.box_1.show_exe_1()
elif self.xy[0] > 650 and self.xy[0] < 754 and self.xy[1] > 390 and self.xy[1] < 408:
if event.type == MOUSEBUTTONDOWN:
if event.button == 1:
try:
self.box_1.exe_1()
self.current_1 = 1
except:
pass
if (self.current_1 == 1):
if self.box_1.back_box_1(self.xy, event):
self.current_1 = 0
else:
self.box_1.choice(self.xy, event)
self.box_1.check(self.xy, event)
if self.xy[0] > 650 and self.xy[0] < 754 and self.xy[1] > 438 and self.xy[1] < 456:
if event.type == MOUSEBUTTONDOWN:
if event.button == 1:
self.box_1.exe_1()
if self.current2 == 1:
self.back_menu(event)
if self.current_2 == 1:
self.box_2.show_help(self.xy, event)
self.box_2.show_exe_1()
elif self.xy[0] > 650 and self.xy[0] < 754 and self.xy[1] > 390 and self.xy[1] < 408:
if event.type == MOUSEBUTTONDOWN:
if event.button == 1:
try:
self.box_2.exe_1()
self.current_2 = 1
except:
pass
if (self.current_2 == 1):
if self.box_2.back_box_1(self.xy, event):
self.current_2 = 0
else:
self.box_2.choice(self.xy, event)
self.box_2.check(self.xy, event)
if self.xy[0] > 650 and self.xy[0] < 754 and self.xy[1] > 438 and self.xy[1] < 456:
if event.type == MOUSEBUTTONDOWN:
if event.button == 1:
self.box_2.exe_1()
if (event.type == KEYDOWN and event.key == K_F4):
self.surface = pygame.display.set_mode((800, 600), pygame.FULLSCREEN)
elif (event.type == KEYDOWN and event.key == K_F3):
self.surface = pygame.display.set_mode((800,600))
pygame.display.update()
game = Game()
game.loop()
pygame.quit()
exit()