-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathmain.py
236 lines (197 loc) · 7.44 KB
/
main.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
import pygame
from pygame import mixer
from gamelib import peranaichill_running
from gamelib import runMaze
from gamelib import animal_hunt
from gamelib import puzzler
#peranaichill_running.main()
#runMaze.main()
#animal_hunt.main()
pygame.init()
# size of the game window
win_width, win_height = 800, 480
# Font for game over window
FONT = "freesandsbold.ttf"
win_size = win_width, win_height
window = pygame.display.set_mode(win_size)
fade = pygame.Surface((win_width, win_height))
fade.fill((0,0,0))
# set_caption(title, icontitle=None) -> None
#If the display has a window title, this function will change the name on the window
pygame.display.set_caption("PeraNaiChill")
start = 1
map = 0
level1screen = 0
level2screen = 0
level3screen = 0
level4screen = 0
level1 = 0
level2 = 0
level3 = 0
level4 = 0
font1 = pygame.font.SysFont('Calibri',24,True,True)
# Sound
mixer.music.load("data/audios/bgmusic.wav")
mixer.music.play(-1)
player_image = pygame.image.load('data/Image/player.png').convert_alpha()
bg = pygame.image.load('data/tileset_1(main)/BG/BG1.jpg').convert_alpha()
running = True
GameEnd = 0
score = 0
while running:
for event in pygame.event.get():
if (event.type == pygame.QUIT) or \
(event.type == pygame.KEYDOWN \
and (event.key == pygame.K_ESCAPE or event.key == pygame.K_q)):
running = False
if start == 1:
breakLoop = True
window.fill((255,255,255))
while breakLoop:
startimg = pygame.image.load('data/game_name.png').convert_alpha()
startimg = pygame.transform.scale(startimg, (800, 480))
window.blit(startimg, (0, 0))
#window.blit(player_image, (50, 150))
StartText = font1.render('Press any key to start ', 1, (0, 0, 0))
window.blit(StartText, (450, 50))
if GameEnd == 1:
scoreText = font1.render('Score: ' + score, 1, (0, 0, 0))
gameover = font1.render('Game Over', 1, (0, 0, 0))
window.blit(gameover,(400,250))
window.blit(scoreText, (400, 300))
pygame.display.flip()
for event in pygame.event.get():
if (event.type == pygame.QUIT) or \
(event.type == pygame.KEYDOWN \
and (event.key == pygame.K_ESCAPE or event.key == pygame.K_q)):
running = False
start = 0
breakLoop = False
if event.type == pygame.KEYDOWN:
score = 0
start = 0
breakLoop = False
map = 1
if map == 1:
breakLoop = True
window.fill((255,255,255))
while breakLoop:
startimg = pygame.image.load('data/Level1.png').convert_alpha()
startimg = pygame.transform.scale(startimg, (800, 480))
window.blit(startimg, (0, 0))
#window.blit(player_image, (50, 150))
StartText = font1.render('Press any key to start', 1, (0, 0, 0))
window.blit(StartText, (450, 50))
pygame.display.flip()
for event in pygame.event.get():
if (event.type == pygame.QUIT) or \
(event.type == pygame.KEYDOWN \
and (event.key == pygame.K_ESCAPE or event.key == pygame.K_q)):
running = False
start = 0
breakLoop = False
if event.type == pygame.KEYDOWN:
score = 0
map = 0
breakLoop = False
level1 = 1
elif level1 == 1:
level1end = peranaichill_running.main()
if level1end == True:
level1 = 0
level2screen = 1
else:
level1 = 0
start = 1
if level2screen == 1:
breakLoop = True
window.fill((255,255,255))
while breakLoop:
startimg = pygame.image.load('data/Level2.png').convert_alpha()
startimg = pygame.transform.scale(startimg, (800, 480))
window.blit(startimg, (0, 0))
#window.blit(player_image, (50, 150))
StartText = font1.render('Press any key to start', 1, (0, 0, 0))
window.blit(StartText, (450, 50))
pygame.display.flip()
for event in pygame.event.get():
if (event.type == pygame.QUIT) or \
(event.type == pygame.KEYDOWN \
and (event.key == pygame.K_ESCAPE or event.key == pygame.K_q)):
running = False
start = 0
breakLoop = False
if event.type == pygame.KEYDOWN:
score = 0
level2screen = 0
breakLoop = False
level2 = 1
elif level2 == 1:
level2end = puzzler.main()
if level2end == True:
level2 = 0
level3screen = 1
else:
level2 = 0
start = 1
if level3screen == 1:
breakLoop = True
window.fill((255,255,255))
while breakLoop:
startimg = pygame.image.load('data/Level3.png').convert_alpha()
startimg = pygame.transform.scale(startimg, (800, 480))
window.blit(startimg, (0, 0))
#window.blit(player_image, (50, 150))
StartText = font1.render('Press any key to start', 1, (0, 0, 0))
window.blit(StartText, (450, 50))
pygame.display.flip()
for event in pygame.event.get():
if (event.type == pygame.QUIT) or \
(event.type == pygame.KEYDOWN \
and (event.key == pygame.K_ESCAPE or event.key == pygame.K_q)):
running = False
start = 0
breakLoop = False
if event.type == pygame.KEYDOWN:
score = 0
level3screen = 0
breakLoop = False
level3 = 1
elif level3 == 1:
level3end = runMaze.main()
if level3end == True:
level3 = 0
level4screen = 1
else:
level3 = 0
start = 1
if level4screen == 1:
breakLoop = True
window.fill((255,255,255))
while breakLoop:
startimg = pygame.image.load('data/Level4.png').convert_alpha()
startimg = pygame.transform.scale(startimg, (800, 480))
window.blit(startimg, (0, 0))
#window.blit(player_image, (50, 150))
StartText = font1.render('Press any key to start', 1, (0, 0, 0))
window.blit(StartText, (450, 50))
pygame.display.flip()
for event in pygame.event.get():
if (event.type == pygame.QUIT) or \
(event.type == pygame.KEYDOWN \
and (event.key == pygame.K_ESCAPE or event.key == pygame.K_q)):
running = False
start = 0
breakLoop = False
if event.type == pygame.KEYDOWN:
score = 0
level4screen = 0
breakLoop = False
level4 = 1
elif level4 == 1:
level4end,score = animal_hunt.main()
print(score)
if level4end == True:
start = 1
GameEnd = 1
level4 = 0