Skip to content

Commit 644bb8f

Browse files
Add files via upload
The Main Game Files
1 parent 50f34c5 commit 644bb8f

File tree

11 files changed

+340
-0
lines changed

11 files changed

+340
-0
lines changed

Game/Cheese.py

Lines changed: 340 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,340 @@
1+
import pygame
2+
#Start
3+
pygame.init()
4+
#Game Data
5+
Lv1 = [0,0,0,0,0,0,0,0,0,0,0,2,0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,3,1,3,2,0,0,2,1,3,4,0,0,0,0,0,0,0,3,0,0,0,0,0,0,0,2,0,0,0,0,0,0,0,0,0,0,0]
6+
Lv2 = [0,0,0,0,0,0,0,0,0,0,4,1,1,0,0,0,0,0,0,1,3,3,0,0,0,0,0,0,1,3,1,0,0,0,2,0,0,0,0,1,0,0,0,2,0,0,0,0,1,1,1,1,2,0,0,0,1,1,1,0,1,1,0,0,0,1,1,1,0,0,0,0,0,0,0,0,0,0,0,0,0]
7+
Lv3 = [0,0,0,0,0,0,0,0,0,0,0,0,1,1,1,1,1,0,0,0,0,0,3,0,0,0,1,1,1,0,0,1,4,1,3,1,1,3,1,0,0,1,2,2,0,1,3,1,0,0,0,0,2,2,0,1,1,1,0,0,0,0,0,0,0,0,0,0,0,0]
8+
Lv4 = [0,0,0,0,0,0,0,0,0,0,0,0,1,1,2,0,0,1,1,1,3,1,5,0,0,1,3,3,1,3,2,0,0,0,4,0,0,2,2,0,0,0,0,0,0,0,0,0]
9+
Lv5 = [0,0,0,0,0,0,0,0,0,0,4,1,0,0,0,0,0,0,1,3,1,1,0,0,0,0,0,1,0,1,0,0,0,2,0,1,0,1,1,0,0,2,3,1,1,0,1,0,0,2,1,1,1,3,1,0,0,0,0,0,0,0,0,0]
10+
Lv6 = [0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,1,0,1,4,0,0,0,0,1,1,1,0,1,1,0,0,0,0,3,1,3,1,3,1,0,0,0,0,1,3,0,0,1,1,0,0,0,0,1,3,1,0,1,0,0,0,2,2,2,2,2,1,1,0,0,0,0,0,0,0,0,0,0,0,0]
11+
Lv7 = [0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,1,1,1,0,0,0,0,2,1,3,0,0,1,0,0,0,2,2,3,1,3,1,1,4,0,0,2,2,1,3,1,3,1,0,0,0,0,0,0,0,0,1,1,0,0,0,0,0,0,0,0,0,0,0,0]
12+
Lv8 = [0,0,0,0,0,0,0,0,0,0,0,1,1,1,1,0,0,0,0,3,3,3,1,0,0,4,1,3,2,2,1,0,0,1,3,2,2,2,0,0,0,0,0,0,1,1,0,0,0,0,0,0,0,0,0,0]
13+
Lv9 = [0,0,0,0,0,0,0,0,0,0,0,2,2,0,0,0,0,0,0,1,2,0,0,0,0,0,1,1,3,2,0,0,0,0,1,3,1,1,0,0,0,1,1,0,3,3,1,0,0,1,1,4,1,1,1,0,0,0,0,0,0,0,0,0]
14+
Lv10 = [0,0,0,0,0,0,0,0,0,0,0,1,1,4,0,0,0,1,1,3,2,1,0,0,0,1,1,2,3,2,1,0,0,0,0,1,5,3,1,0,0,0,0,1,1,1,0,0,0,0,0,0,0,0,0,0]
15+
Lv11 = [0,0,0,0,0,0,0,0,0,1,1,0,1,1,1,0,0,1,3,2,2,3,1,0,0,4,3,2,5,1,0,0,0,1,3,2,2,3,1,0,0,1,1,0,1,1,1,0,0,0,0,0,0,0,0,0]
16+
#Position/Game variables
17+
X = 400
18+
Y = 400
19+
cheeselist = []
20+
endlist = []
21+
mousepos = 0
22+
mousedir = 0
23+
levelwidth = 0
24+
levelheight = 0
25+
gamelist = []
26+
level = []
27+
emptyblock = [1,2,3,4,5]
28+
paused = True
29+
started = True
30+
reset = False
31+
#Colo(u)r variables
32+
yellow = (255,255,0)
33+
black = (0,0,0)
34+
#Loop variables
35+
running = True
36+
#Screen variables
37+
display_surface = pygame.display.set_mode((X,Y))
38+
main_font = pygame.font.Font('DOS-FONT.ttf', 32)
39+
start_text = main_font.render("Cheese Terminator",True,yellow,black)
40+
next_text = main_font.render("Well Done!",True,yellow,black)
41+
win_text = main_font.render("You Won!!! :D",True,yellow,black)
42+
main_font = pygame.font.Font('DOS-FONT.ttf', 20)
43+
start_text2 = main_font.render("Press Enter To Start",True,yellow,black)
44+
start_text3 = main_font.render("Use Arrow Keys To Move",True,yellow,black)
45+
next_text2 = main_font.render("Press Enter To Continue",True,yellow,black)
46+
win_text2 = main_font.render("Press Enter To Play Again",True,yellow,black)
47+
reset_text = main_font.render("Are You Shure You Want To Restart?",True,yellow,black)
48+
reset_text2 = main_font.render("Press Enter To Continue",True,yellow,black)
49+
reset_text3 = main_font.render("Press The Arrow Keys To Cancel",True,yellow,black)
50+
textRect = start_text.get_rect()
51+
textRect.center = (X // 2, ((Y // 2)-30))
52+
textRect2 = start_text2.get_rect()
53+
textRect2.center = (X // 2, ((Y // 2)-3))
54+
textRect3 = start_text3.get_rect()
55+
textRect3.center = (X // 2, ((Y // 2)+18))
56+
textRectn = next_text.get_rect()
57+
textRectn.center = (X // 2, ((Y // 2)-15))
58+
textRectn2 = next_text2.get_rect()
59+
textRectn2.center = (X // 2, ((Y // 2)+15))
60+
textRectw = win_text.get_rect()
61+
textRectw.center = (X // 2, ((Y // 2)-15))
62+
textRectnw = win_text2.get_rect()
63+
textRectnw.center = (X // 2, ((Y // 2)+15))
64+
textRectr = reset_text.get_rect()
65+
textRectr.center = (X // 2, ((Y // 2)-15))
66+
textRectr2 = reset_text2.get_rect()
67+
textRectr2.center = (X // 2, ((Y // 2)))
68+
textRectr3 = reset_text3.get_rect()
69+
textRectr3.center = (X // 2, ((Y // 2)+15))
70+
M_0 = pygame.image.load("PNG_M_0.png")
71+
M_0 = pygame.transform.scale(M_0,(30,30))
72+
M_1 = pygame.image.load("PNG_M_1.png")
73+
M_1 = pygame.transform.scale(M_1,(30,30))
74+
M_2 = pygame.image.load("PNG_M_2.png")
75+
M_2 = pygame.transform.scale(M_2,(30,30))
76+
M_3 = pygame.image.load("PNG_M_3.png")
77+
M_3 = pygame.transform.scale(M_3,(30,30))
78+
C_0 = pygame.image.load("PNG_C_0.png")
79+
C_0 = pygame.transform.scale(C_0,(30,30))
80+
C_1 = pygame.image.load("PNG_C_1.png")
81+
C_1 = pygame.transform.scale(C_1,(30,30))
82+
P_0 = pygame.image.load("PNG_0.png")
83+
P_0 = pygame.transform.scale(P_0,(30,30))
84+
P_1 = pygame.image.load("PNG_1.png")
85+
P_1 = pygame.transform.scale(P_1,(30,30))
86+
P_2 = pygame.image.load("PNG_2.png")
87+
P_2 = pygame.transform.scale(P_2,(30,30))
88+
#Screen display
89+
pygame.display.set_caption("Cheese Terminator In Python!")
90+
pygame.display.update()
91+
#Functions
92+
def setnewlevel(lvl,width):
93+
global endlist, cheeselist, mousepos, display_surface, levelwidth, levelheight, gamelist, mousedir, level, started
94+
started = False
95+
level = lvl
96+
endlist = []
97+
cheeselist = []
98+
drawx = 0
99+
drawy = 0
100+
drawid = 0
101+
mousedir = 0
102+
height = len(lvl) / width
103+
display_surface = pygame.display.set_mode((round(width*30),round(height*30)))
104+
levelwidth = width
105+
levelheight = height
106+
i = 0
107+
while i < height:
108+
drawx = 0
109+
e = 0
110+
while e < width:
111+
if lvl[drawid] == 2:
112+
endlist.append(drawid)
113+
elif lvl[drawid] == 3:
114+
cheeselist.append(drawid)
115+
elif lvl[drawid] == 4:
116+
mousepos = drawid
117+
elif lvl[drawid] == 5:
118+
cheeselist.append(drawid)
119+
endlist.append(drawid)
120+
drawx = drawx + 30
121+
drawid = drawid + 1
122+
e = e + 1
123+
i = i + 1
124+
drawy = drawy + 30
125+
gamelist = lvl
126+
def drawscreen():
127+
global levelwidth, levelheight, cheeselist, endlist, display_surface, gamelist
128+
if paused or reset:
129+
return
130+
cheese = [2,5]
131+
drawx = 0
132+
drawy = 0
133+
drawid = 0
134+
i = 0
135+
while i < levelheight:
136+
e = 0
137+
drawx = 0
138+
while e < levelwidth:
139+
w = 0
140+
if gamelist[drawid] == 0:
141+
w = 1
142+
display_surface.blit(P_1,(drawx*30,drawy*30))
143+
if gamelist[drawid] == 1:
144+
w = 1
145+
display_surface.blit(P_0,(drawx*30,drawy*30))
146+
if gamelist[drawid] in cheese:
147+
w = 1
148+
if drawid in cheeselist:
149+
display_surface.blit(C_1,(drawx*30,drawy*30))
150+
else:
151+
display_surface.blit(P_2,(drawx*30,drawy*30))
152+
if drawid in cheeselist:
153+
w = 1
154+
if gamelist[drawid] in cheese:
155+
display_surface.blit(C_1,(drawx*30,drawy*30))
156+
else:
157+
display_surface.blit(C_0,(drawx*30,drawy*30))
158+
if mousepos == drawid:
159+
w = 1
160+
if mousedir == 0:
161+
display_surface.blit(M_0,(drawx*30,drawy*30))
162+
elif mousedir == 1:
163+
display_surface.blit(M_1,(drawx*30,drawy*30))
164+
elif mousedir == 2:
165+
display_surface.blit(M_2,(drawx*30,drawy*30))
166+
elif mousedir == 3:
167+
display_surface.blit(M_3,(drawx*30,drawy*30))
168+
else:
169+
display_surface.blit(M_0,(drawx*30,drawy*30))
170+
if w == 0:
171+
display_surface.blit(P_0,(drawx*30,drawy*30))
172+
drawid = drawid + 1
173+
e = e + 1
174+
drawx = drawx + 1
175+
i = i + 1
176+
drawy = drawy + 1
177+
def checblock(dir,pos):
178+
if dir == "u":
179+
try:
180+
return gamelist[pos-levelwidth]
181+
except:
182+
return "error"
183+
elif dir == "d":
184+
try:
185+
return gamelist[pos+levelwidth]
186+
except:
187+
return "error"
188+
elif dir == "l":
189+
if pos % levelwidth == 0:
190+
return "error"
191+
else:
192+
return gamelist[pos-1]
193+
elif dir == "r":
194+
if pos % levelwidth == (levelwidth-1):
195+
return "error"
196+
else:
197+
return gamelist[pos+1]
198+
def checkifwon():
199+
q = 0
200+
a = 0
201+
while q < len(endlist):
202+
if endlist[q] in cheeselist:
203+
a = a + 1
204+
q = q + 1
205+
return a == q
206+
#Main loop
207+
display_surface.blit(start_text, textRect)
208+
display_surface.blit(start_text2, textRect2)
209+
display_surface.blit(start_text3, textRect3)
210+
while running:
211+
for event in pygame.event.get():
212+
if event.type == pygame.QUIT:
213+
running = False
214+
if event.type == pygame.KEYDOWN:
215+
if event.key == pygame.K_UP:
216+
mousedir = 3
217+
if not checblock("u",mousepos) == "error":
218+
if checblock("u",mousepos) in emptyblock:
219+
if mousepos-levelwidth in cheeselist:
220+
if checblock("u",mousepos-levelwidth) in emptyblock:
221+
if not (mousepos-levelwidth-levelwidth in cheeselist):
222+
cheeselist[cheeselist.index(mousepos-levelwidth)] = cheeselist[cheeselist.index(mousepos-levelwidth)]-levelwidth
223+
mousepos = mousepos-levelwidth
224+
else:
225+
mousepos = mousepos-levelwidth
226+
elif mousepos-levelwidth in cheeselist:
227+
if checblock("u",mousepos-levelwidth) in emptyblock:
228+
if not (mousepos-levelwidth-levelwidth in cheeselist):
229+
cheeselist[cheeselist.index(mousepos-levelwidth)] = cheeselist[cheeselist.index(mousepos-levelwidth)]-levelwidth
230+
mousepos = mousepos-levelwidth
231+
if event.key == pygame.K_DOWN:
232+
mousedir = 1
233+
if not checblock("d",mousepos) == "error":
234+
if checblock("d",mousepos) in emptyblock:
235+
if mousepos+levelwidth in cheeselist:
236+
if checblock("d",mousepos+levelwidth) in emptyblock:
237+
if not (mousepos+levelwidth+levelwidth in cheeselist):
238+
cheeselist[cheeselist.index(mousepos+levelwidth)] = cheeselist[cheeselist.index(mousepos+levelwidth)]+levelwidth
239+
mousepos = mousepos+levelwidth
240+
else:
241+
mousepos = mousepos+levelwidth
242+
elif mousepos+levelwidth in cheeselist:
243+
if checblock("d",mousepos+levelwidth) in emptyblock:
244+
if not (mousepos+levelwidth+levelwidth in cheeselist):
245+
cheeselist[cheeselist.index(mousepos+levelwidth)] = cheeselist[cheeselist.index(mousepos+levelwidth)]+levelwidth
246+
mousepos = mousepos+levelwidth
247+
if event.key == pygame.K_LEFT:
248+
mousedir = 2
249+
if not checblock("l",mousepos) == "error":
250+
if checblock("l",mousepos) in emptyblock:
251+
if mousepos-1 in cheeselist:
252+
if checblock("l",mousepos-1) in emptyblock:
253+
if not (mousepos-2 in cheeselist):
254+
cheeselist[cheeselist.index(mousepos-1)] = cheeselist[cheeselist.index(mousepos-1)]-1
255+
mousepos = mousepos-1
256+
else:
257+
mousepos = mousepos-1
258+
elif mousepos-1 in cheeselist:
259+
if checblock("l",mousepos-1) in emptyblock:
260+
if not (mousepos-2 in cheeselist):
261+
cheeselist[cheeselist.index(mousepos-1)] = cheeselist[cheeselist.index(mousepos-1)]-1
262+
mousepos = mousepos-1
263+
if event.key == pygame.K_RIGHT:
264+
if reset:
265+
reset = False
266+
paused = False
267+
started = False
268+
display_surface = pygame.display.set_mode((levelwidth*30,levelheight*30))
269+
else:
270+
mousedir = 0
271+
if not checblock("r",mousepos) == "error":
272+
if checblock("r",mousepos) in emptyblock:
273+
if mousepos+1 in cheeselist:
274+
if checblock("r",mousepos+1) in emptyblock:
275+
if not (mousepos+2 in cheeselist):
276+
cheeselist[cheeselist.index(mousepos+1)] = cheeselist[cheeselist.index(mousepos+1)]+1
277+
mousepos = mousepos+1
278+
else:
279+
mousepos = mousepos+1
280+
elif mousepos+1 in cheeselist:
281+
if checblock("r",mousepos+1) in emptyblock:
282+
if not (mousepos+2 in cheeselist):
283+
cheeselist[cheeselist.index(mousepos+1)] = cheeselist[cheeselist.index(mousepos+1)]+1
284+
mousepos = mousepos+1
285+
if event.key == pygame.K_RETURN:
286+
paused = not paused
287+
if started:
288+
started = False
289+
if level == []:
290+
setnewlevel(Lv11,8)
291+
#setnewlevel(Lv1,8)
292+
elif level == Lv1:
293+
setnewlevel(Lv2,9)
294+
elif level == Lv2:
295+
setnewlevel(Lv3,10)
296+
elif level == Lv3:
297+
setnewlevel(Lv4,8)
298+
elif level == Lv4:
299+
setnewlevel(Lv5,8)
300+
elif level == Lv5:
301+
setnewlevel(Lv6,10)
302+
elif level == Lv6:
303+
setnewlevel(Lv7,10)
304+
elif level == Lv7:
305+
setnewlevel(Lv8,8)
306+
elif level == Lv8:
307+
setnewlevel(Lv9,8)
308+
elif level == Lv9:
309+
setnewlevel(Lv10,8)
310+
elif level == Lv10:
311+
setnewlevel(Lv11,8)
312+
else:
313+
if paused:
314+
reset = True
315+
X = 400
316+
Y = 400
317+
display_surface = pygame.display.set_mode((X,Y))
318+
display_surface.fill(black)
319+
display_surface.blit(reset_text, textRectr)
320+
display_surface.blit(reset_text2, textRectr2)
321+
display_surface.blit(reset_text3, textRectr3)
322+
else:
323+
if reset:
324+
reset = False
325+
paused = False
326+
started = False
327+
setnewlevel(level,levelwidth)
328+
if checkifwon():
329+
reset = False
330+
paused = True
331+
started = True
332+
X = 400
333+
Y = 400
334+
display_surface = pygame.display.set_mode((X,Y))
335+
display_surface.fill(black)
336+
display_surface.blit(next_text, textRectn)
337+
display_surface.blit(next_text2, textRectn2)
338+
X,Y = display_surface.get_size()
339+
drawscreen()
340+
pygame.display.update()

Game/DOS-FONT.ttf

80.7 KB
Binary file not shown.

Game/PNG_0.png

136 Bytes
Loading

Game/PNG_1.png

135 Bytes
Loading

Game/PNG_2.png

170 Bytes
Loading

Game/PNG_C_0.png

239 Bytes
Loading

Game/PNG_C_1.png

239 Bytes
Loading

Game/PNG_M_0.png

264 Bytes
Loading

Game/PNG_M_1.png

276 Bytes
Loading

Game/PNG_M_2.png

274 Bytes
Loading

0 commit comments

Comments
 (0)