forked from sxijyoti/SaveMe
-
Notifications
You must be signed in to change notification settings - Fork 33
/
tempCodeRunnerFile.python
781 lines (606 loc) · 33.8 KB
/
tempCodeRunnerFile.python
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
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
import tkinter as tk
import turtle
import os
from tkinter import Tk, Label, Button, Entry, END
from PIL import Image, ImageTk
import tkinter.messagebox as messagebox
import random
# main loop starts here
SaveMe = Tk()
SaveMe.geometry("1000x1000")
SaveMe["background"]= "#1C1C1E"
SaveMe.title("SaveMe")
SaveMe.resizable(width=0, height=0)
basedir = os.path.dirname(os.path.abspath(__file__))
#________________IMAGES__________________
sImage = Image.open(os.path.join(basedir, "assets", "sroom.png"))
sImage = sImage.resize((1000, 1000), Image.Resampling.LANCZOS)
sImage = ImageTk.PhotoImage(sImage)
hauntedImage = Image.open(os.path.join(basedir, "assets", "hauntedmansion.png"))
hauntedImage = hauntedImage.resize((1000, 1000), Image.Resampling.LANCZOS)
hauntedImage = ImageTk.PhotoImage(hauntedImage)
room1Image = Image.open(os.path.join(basedir, "assets", "room1.png"))
room1Image = room1Image.resize((1000, 1000), Image.Resampling.LANCZOS)
room1Image = ImageTk.PhotoImage(room1Image)
room2Image = Image.open(os.path.join(basedir, "assets", "room2.png"))
room2Image = room2Image.resize((1000, 1000), Image.Resampling.LANCZOS)
room2Image = ImageTk.PhotoImage(room2Image)
room5Image = Image.open(os.path.join(basedir, "assets", "room5.png"))
room5Image = room5Image.resize((1000, 1000), Image.Resampling.LANCZOS)
room5Image = ImageTk.PhotoImage(room5Image)
room3Image = Image.open(os.path.join(basedir, "assets", "room3.png"))
room3Image = room3Image.resize((1000, 1000), Image.Resampling.LANCZOS)
room3Image = ImageTk.PhotoImage(room3Image)
room4Image = Image.open(os.path.join(basedir, "assets", "room4.png"))
room4Image = room4Image.resize((1000, 1000), Image.Resampling.LANCZOS)
room4Image = ImageTk.PhotoImage(room4Image)
finalImage = Image.open(os.path.join(basedir, "assets", "final.png"))
finalImage = finalImage.resize((1000, 1000), Image.Resampling.LANCZOS)
finalImage = ImageTk.PhotoImage(finalImage)
#___________________MAIN_______________________________
def startscreen():
# start screen
sLabel = Label(SaveMe, image=sImage, background="#1C1C1E", height=1000, width=1000)
sLabel.place(x=0, y=0, relwidth=1, relheight=1)
sbutton = Button(SaveMe, text="BEGIN!", borderwidth=0, highlightthickness=0, command=firstscreen,
bg="#1C1C1E", fg="white", width=25, height=4, font=("Helvetica", 18))
sbutton.place(x=350, y=350)
def firstscreen():
# the story begins
for widget in SaveMe.winfo_children():
widget.destroy()
def yes():
yesbutton.destroy()
nobutton.destroy()
letter.config(text="""The letter reads as follows:
\"Aaron, if you are reading this, you've taken the first step on a journey I've long envisioned.
Hidden within those walls are truths waiting to be uncovered, and the key lies in your ability to decipher the clues....\"""",
font=("Helvetica", 14), fg="white", bg="#1C1C1E", wraplength=800)
conbutton.place(x=400, y=500)
def no():
SaveMe.quit()
sLabel = Label(SaveMe, image=sImage, background="#1C1C1E", height=1000, width=1000)
sLabel.place(x=0, y=0, relwidth=1, relheight=1)
letter = Label(SaveMe, text=""" *You are Aaron*
You have received a letter. Click yes to continue.""",
font=("Helvetica", 18), fg="white", bg="#1C1C1E", wraplength=800)
letter.place(x=100, y=300)
yesbutton = Button(SaveMe, text="Yes", borderwidth=0, highlightthickness=0, command=yes,
bg="#1C1C1E", fg="white", width=10, height=2, font=("Helvetica", 14))
yesbutton.place(x=350, y=400)
nobutton = Button(SaveMe, text="No", borderwidth=0, highlightthickness=0, command=no,
bg="#1C1C1E", fg="white", width=10, height=2, font=("Helvetica", 14))
nobutton.place(x=500, y=400)
conbutton = Button(SaveMe, text="Continue", borderwidth=0, highlightthickness=0, command=secondscreen,
bg="#1C1C1E", fg="white", width=10, height=2, font=("Helvetica", 14))
def secondscreen():
# visiting the mansion and the initial quest is mentioned
for widget in SaveMe.winfo_children():
widget.destroy()
def proceed():
conbutton.place_forget()
quitbutton.place_forget()
secondlabel.config(text="""*You decided to visit the mansion and unravel the mystery surrounding the letter by yourself*
Aaron: This place is very spooky but I must find what awaits me here.
*You see a guard who walks towards you. You are scared but regardless decide to talk to him*
Guard: You must be Aaron. Well, we were waiting for you.
Guard: This place houses secrets, and you must find them if you want to own it all by yourself.
Aaron: What do you mean by that?
Guard: You will find out for yourself. 5 quests await you. Remember, you are not the only one.
Aaron: There...are...others?
Guard: That is all I have to say to you. Good luck. What awaits on the other end is for you to find out.""",
font=("Helvetica", 14), fg="white", bg="#1C1C1E", wraplength=800)
nextbutton.place(x=450, y=500)
def nextinsecond():
nextbutton.place_forget()
secondlabel.config(text="""*While you were looking around the mansion, you stumble across a room which looks familiar.
But before you know it, the door shuts on you and you're stuck there.
You stumble across a message on the wall which reads:
"Solve the riddle if you want to see yourself out. This is your first quest." *""",
font=("Helvetica", 14), fg="white", bg="#1C1C1E", wraplength=800)
nextbutton.config(command=thirdscreen)
nextbutton.place(x=450, y=500)
def quitt():
SaveMe.quit()
secLabel = Label(SaveMe, image=hauntedImage, background="#1C1C1E", height=1000, width=1000)
secLabel.place(x=0, y=0, relwidth=1, relheight=1)
secondlabel = Label(SaveMe, text="*You don't know who the sender was. Do you still want to proceed with it?*", font=("Helvetica", 20), fg="white", bg="#1C1C1E")
secondlabel.place(x=100, y=200)
conbutton = Button(SaveMe, text="Continue", borderwidth=0, highlightthickness=0, command=proceed,
bg="#1C1C1E", fg="white", width=10, height=2, font=("Helvetica", 14))
conbutton.place(x=350, y=400)
quitbutton = Button(SaveMe, text="Quit", borderwidth=0, highlightthickness=0, command=quitt,
bg="#1C1C1E", fg="white", width=10, height=2, font=("Helvetica", 14))
quitbutton.place(x=500, y=400)
nextbutton = Button(SaveMe, text="Next", borderwidth=0, highlightthickness=0, command=nextinsecond,
bg="#1C1C1E", fg="white", width=10, height=2, font=("Helvetica", 14))
nextbutton.place_forget()
def thirdscreen():
# quest 1 : solve the riddle
for widget in SaveMe.winfo_children():
widget.destroy()
thiLabel = Label(SaveMe, image=room4Image, background="#1C1C1E", height=1000, width=1000)
thiLabel.place(x=0, y=0, relwidth=1, relheight=1)
thirdlabel = Label(SaveMe, text="""*You search around the room and come across a paper*
The paper reads:
"Elsa has four daughters, and each of her daughters has a brother.
How many children does Elsa have?" """, font=("Helvetica", 20), fg="white", bg="#1C1C1E", wraplength=800)
thirdlabel.place(x=100, y=200)
nlabel = Label(SaveMe, text="Enter your answer here:", font=("Helvetica", 14), fg="white", bg="#1C1C1E")
nlabel.place(x=350, y=400)
answer = tk.Entry(SaveMe, font=("Helvetica", 14), width=10)
answer.place(x=350, y=450)
def riddlesolver():
userans = answer.get().strip().upper()
if userans == "5" or userans == "FIVE":
messagebox.showinfo("Correct!", "You've solved the riddle!")
correct()
else:
messagebox.showerror("Incorrect", "Incorrect answer. Try again!")
giveup.place(x=500, y=500)
def correct():
for widget in SaveMe.winfo_children():
widget.place_forget()
correctlabel = Label(SaveMe, text="""You have successfully solved this riddle. The door will open for you now.
This journey awaits more such Quests. Can you solve them?""", font=("Helvetica", 20), fg="white", bg="#1C1C1E", wraplength=800)
correctlabel.place(x=100, y=200)
nextbutton = Button(SaveMe, text="Next", borderwidth=0, highlightthickness=0, command=fourthscreen,
bg="#1C1C1E", fg="white", width=10, height=2, font=("Helvetica", 14))
nextbutton.place(x=450, y=500)
def incorrect():
for widget in SaveMe.winfo_children():
widget.place_forget()
incorrectlabel = Label(SaveMe, text="""You have failed to solve this riddle.
We will let you go this time, but better luck next time!""", font=("Helvetica", 20), fg="white", bg="#1C1C1E", wraplength=800)
incorrectlabel.place(x=100, y=200)
nextbutton = Button(SaveMe, text="Next", borderwidth=0, highlightthickness=0, command=fourthscreen,
bg="#1C1C1E", fg="white", width=10, height=2, font=("Helvetica", 14))
nextbutton.place(x=450, y=500)
submitbut = Button(SaveMe, text="Submit", borderwidth=0, highlightthickness=0, command=riddlesolver,
bg="#1C1C1E", fg="white", width=10, height=2, font=("Helvetica", 14))
submitbut.place(x=350, y=500)
giveup = Button(SaveMe, text="Give Up!", borderwidth=0, highlightthickness=0, command=incorrect,
bg="#1C1C1E", fg="white", width=10, height=2, font=("Helvetica", 14))
giveup.place_forget()
def fourthscreen():
# quest 2 : rock, paper and scissors
for widget in SaveMe.winfo_children():
widget.destroy()
four = Label(SaveMe, image=room2Image, background="#1C1C1E", height=1000, width=1000)
four.place(x=0, y=0, relwidth=1, relheight=1)
fourthlabel = Label(SaveMe, text="""* You end in a completely different hallway and realise there is no escaping this.
You will need to solve each quest as it is and each awaits a quest here.
You enter the next room and stumble across a mannequin with a label which goes "Ready for Rock, Paper and Scissors?"*
""", font=("Helvetica", 20), fg="white", bg="#1C1C1E", wraplength=800)
fourthlabel.place(x=100, y=200)
def play(choice):
options = ["Rock", "Paper", "Scissors"]
mannequin = random.choice(options)
if mannequin == choice:
messagebox.showinfo("DRAW!","You and the mannequin made the same choice")
try_Again()
elif (choice == "Rock" and mannequin == "Scissors") or \
(choice == "Scissors" and mannequin == "Paper") or \
(choice == "Paper" and mannequin == "Rock"):
messagebox.showinfo("WIN!","Congrats! You WIN this round!")
nexxt()
else:
messagebox.showwarning("Defeat!","You lost this round. Better luck next time!")
nexxt()
def rockpapsci():
for widget in SaveMe.winfo_children():
widget.place_forget()
four.place(x=0, y=0, relwidth=1, relheight=1)
# def play(choice):
# options = ["Rock", "Paper", "Scissors"]
# mannequin = random.choice(options)
# if mannequin == choice:
# messagebox.showinfo("DRAW!","You and the mannequin made the same choice")
# try_Again()
# elif (choice == "rock" and mannequin == "scissors") or \
# (choice == "scissors" and mannequin == "paper") or \
# (choice == "paper" and mannequin == "rock"):
# messagebox.showinfo("WIN!","Congrats! You WIN this round!")
# else:
# messagebox.showwarning("Defeat!","You lost this round. Better luck next time!")
rock = Button(SaveMe, text="Rock", borderwidth=0, highlightthickness=0, command=lambda: play("Rock"),
bg="#1C1C1E", fg="white", width=10, height=2, font=("Helvetica", 14)).place(x=300, y=400)
paper = Button(SaveMe, text="Paper", borderwidth=0, highlightthickness=0, command=lambda: play("Paper"),
bg="#1C1C1E", fg="white", width=10, height=2, font=("Helvetica", 14)).place(x=450, y=400)
scissors = Button(SaveMe, text="Scissors", borderwidth=0, highlightthickness=0, command=lambda: play("Scissors"),
bg="#1C1C1E", fg="white", width=10, height=2, font=("Helvetica", 14)).place(x=600, y=400)
def try_Again():
for widget in SaveMe.winfo_children():
widget.place_forget()
four.place(x=0, y=0, relwidth=1, relheight=1)
ta = Label(SaveMe, text="It's a draw! Try again!", font=("Helvetica", 20), fg="white", bg="#1C1C1E")
ta.place(x=350, y=300)
rock = Button(SaveMe, text="Rock", borderwidth=0, highlightthickness=0, command=lambda: play("Rock"),
bg="#1C1C1E", fg="white", width=10, height=2, font=("Helvetica", 14))
rock.place(x=300, y=400)
paper = Button(SaveMe, text="Paper", borderwidth=0, highlightthickness=0, command=lambda: play("Paper"),
bg="#1C1C1E", fg="white", width=10, height=2, font=("Helvetica", 14))
paper.place(x=450, y=400)
scissors = Button(SaveMe, text="Scissors", borderwidth=0, highlightthickness=0, command=lambda: play("Scissors"),
bg="#1C1C1E", fg="white", width=10, height=2, font=("Helvetica", 14))
scissors.place(x=600, y=400)
def nexxt():
for widget in SaveMe.winfo_children():
widget.place_forget()
four.place(x=0, y=0, relwidth=1, relheight=1)
fourthlabel = Label(SaveMe, text="""Mannequin: You will now proceed towards the next room where you await another Quest
You will come across a box. That's where your next quest lies.""", font=("Helvetica", 20), fg="white", bg="#1C1C1E", wraplength=800)
fourthlabel.place(x=100, y=200)
nextbutton = Button(SaveMe, text="Next", borderwidth=0, highlightthickness=0, command=fifthscreen,
bg="#1C1C1E", fg="white", width=10, height=2, font=("Helvetica", 14))
nextbutton.place(x=450, y=500)
def skipp():
for widget in SaveMe.winfo_children():
widget.place_forget()
four.place(x=0, y=0, relwidth=1, relheight=1)
skiplabel = Label(SaveMe, text="""You decided to skip this round. :( """, font=("Helvetica", 20), fg="white", bg="#1C1C1E", wraplength=800)
skiplabel.place(x=100, y=200)
nextbutton = Button(SaveMe, text="Next", borderwidth=0, highlightthickness=0, command=fifthscreen,
bg="#1C1C1E", fg="white", width=10, height=2, font=("Helvetica", 14))
nextbutton.place(x=450, y=500)
yesbutton = Button(SaveMe, text="Yes", borderwidth=0, highlightthickness=0, command=rockpapsci,
bg="#1C1C1E", fg="white", width=10, height=2, font=("Helvetica", 14))
yesbutton.place(x=350, y=700)
nobutton = Button(SaveMe, text="No", borderwidth=0, highlightthickness=0, command=skipp,
bg="#1C1C1E", fg="white", width=10, height=2, font=("Helvetica", 14))
nobutton.place(x=500, y=700)
def fifthscreen():
# quest 3 : bulls and cows
for widget in SaveMe.winfo_children():
widget.destroy()
fif = Label(SaveMe, image=room3Image, background="#1C1C1E", height=1000, width=1000)
fif.place(x=0, y=0, relwidth=1, relheight=1)
fifthlabel = Label(SaveMe, text=""" Are you ready to play a round of BULLS AND COWS?
Guess the secret 4 digit code and open the box""",
font=("Helvetica", 20), fg="white", bg="#1C1C1E")
fifthlabel.place(x=100, y=200)
def generate_code():
return ''.join(random.sample('0123456789', 4))
guess = 0
max_guess = 7
guess_history = []
code = generate_code()
# code = ''.join(random.sample('0123456789', 4))
def bullcows():
nonlocal guess, guess_history, code
for widget in SaveMe.winfo_children():
widget.place_forget()
fif.place(x=0, y=0, relwidth=1, relheight=1)
p = Label(SaveMe, text="Guess the 4-digit code:", font=("Helvetica", 20), fg="white", bg="#1C1C1E")
p.place(x=100, y=200)
guessentry = Entry(SaveMe, font=("Helvetica", 20), width=10)
guessentry.place(x=350, y=300)
guessbutton = Button(SaveMe, text="Submit", borderwidth=0, highlightthickness=0,
command=lambda: checkguess(guessentry.get()),
bg="#1C1C1E", fg="white", width=10, height=2, font=("Helvetica", 14))
guessbutton.place(x=350, y=400)
def checkguess(guess_code):
nonlocal guess, guess_history, code
if len(guess_code) != 4 or not guess_code.isdigit():
messagebox.showwarning("Invalid", "Enter a valid 4-digit code.")
return
guess += 1
guess_history.append(guess_code)
bulls, cows = calculate_bullscows(guess_code)
# res = Label(SaveMe, text=f"Bulls: {bulls}, Cows: {cows}", font=("Helvetica", 20), fg="white", bg="#1C1C1E")
# res.place(x=350, y=450)
if bulls == 4:
messagebox.showinfo("GUESSED IT!", f"You guessed the code {code} in {guess} attempts!")
sixthscreen()
elif guess >= max_guess:
messagebox.showwarning("Better Luck :(", f"You've used all your {max_guess} attempts! The code was {code}.")
sixthscreen()
else:
# res.config(text=f"Bulls: {bulls} , Cows: {cows}")
res = Label(SaveMe, text=f"Bulls: {bulls}, Cows: {cows}", font=("Helvetica", 20), fg="white", bg="#1C1C1E")
res.place(x=350, y=450)
giveup.place(x=400,y=500)
def calculate_bullscows(guess_code):
nonlocal code
bulls = sum(1 for i in range(4) if guess_code[i] == code[i])
cows = sum(1 for digit in guess_code if digit in code) - bulls
return bulls, cows
def skipp():
for widget in SaveMe.winfo_children():
widget.place_forget()
fif.place(x=0, y=0, relwidth=1, relheight=1)
skiplabel = Label(SaveMe, text="""You decided to skip this round. :( """, font=("Helvetica", 20), fg="white", bg="#1C1C1E", wraplength=800)
skiplabel.place(x=100, y=200)
nextbutton = Button(SaveMe, text="Next", borderwidth=0, highlightthickness=0, command=sixthscreen,
bg="#1C1C1E", fg="white", width=10, height=2, font=("Helvetica", 14))
nextbutton.place(x=450, y=500)
yesbutton = Button(SaveMe, text="Yes", borderwidth=0, highlightthickness=0, command=bullcows,
bg="#1C1C1E", fg="white", width=10, height=2, font=("Helvetica", 14))
yesbutton.place(x=350, y=700)
nobutton = Button(SaveMe, text="No", borderwidth=0, highlightthickness=0, command=skipp,
bg="#1C1C1E", fg="white", width=10, height=2, font=("Helvetica", 14))
nobutton.place(x=500, y=700)
giveup = Button(SaveMe, text="Give Up!", borderwidth=0, highlightthickness=0, command=skipp,
bg="#1C1C1E", fg="white", width=10, height=2, font=("Helvetica", 14))
giveup.place_forget()
def sixthscreen():
# quest 4 : hangman
for widget in SaveMe.winfo_children():
widget.destroy()
six = Label(SaveMe, image=room1Image, background="#1C1C1E", height=1000, width=1000)
six.place(x=0, y=0, relwidth=1, relheight=1)
sixlabel = Label(SaveMe, text="""*You find a key inside the box and figure out it unlocks a door in this room.
You open the door and you find a letter hanging from the ceiling near a candle. You hear a voice*
Voice:"So you have made it until here. Congrats."
Voice:"Your next QUEST is to guess the word.
If you fail to guess it, the letter will burn before you get to read the contents "
Aaron: "Is it sort of a HANGMAN game."
Voice: "Smart guess! Now Goodluck." """, font=("Helvetica", 20), fg="white", bg="#1C1C1E", wraplength=800)
sixlabel.place(x=100, y=200)
word_list = ["HACKNIGHT" , "ACM" , "MAAYA" , "QUADRANGLE" , "RIYAL" , "PAIN" ,"HACKTOBERFEST", "BUNSAMOSA"]
secret_word = random.choice(word_list)
secret_word = secret_word.upper()
guessed = []
incorrect = 0
max = 6
display = list("_" * len(secret_word))
def hangman():
for widget in SaveMe.winfo_children():
widget.place_forget()
six.place(x=0, y=0, relwidth=1, relheight=1)
displaylabel = Label(SaveMe, text=" ".join(display), font=("Helvetica", 40), fg="white", bg="#1C1C1E")
displaylabel.place(x=350, y=300)
guessdisplay = Label(SaveMe, text="Guessed Letters: ", font=("Helvetica", 20), fg="white", bg="#1C1C1E")
guessdisplay.place(x=350, y=500)
guesslabel = Label(SaveMe, text=f"Guess Remaining: {max - incorrect}", font=("Helvetica", 20), fg="white", bg="#1C1C1E")
guesslabel.place(x=350, y=550)
def update():
displaylabel.config(text=" ".join(display))
if "_" not in display:
messagebox.showinfo("CONGRATS!", "You guessed the word. Now you can read the Letter!")
finalscreen()
if incorrect >= max:
messagebox.showwarning("OOPS!", f"You will never know the contents of the letter! The word was '{secret_word}'.")
finalscreen()
guessdisplay.config(text="Guessed Letters: " + ", ".join(guessed))
guesslabel.config(text=f"Guess Remaining: {max - incorrect}")
def guess_letter():
nonlocal incorrect
try:
letter = guessentry.get().upper()
guessentry.delete(0, END)
if len(letter) != 1 or not letter.isalpha():
messagebox.showwarning("Invalid", "Enter a single alphabet.")
return
if letter in guessed:
messagebox.showwarning("Guessed Before", f"You have guessed {letter} before.")
return
guessed.append(letter)
if letter in secret_word:
for i, char in enumerate(secret_word):
if char == letter:
display[i] = letter
update()
else:
incorrect += 1
update()
except Exception:
print( f"An error occurred while processing your guess")
guessentry = Entry(SaveMe, font=("Helvetica", 20), width=5)
guessentry.place(x=350, y=400)
guessbutton = Button(SaveMe, text="Submit", borderwidth=0, highlightthickness=0,
command=guess_letter, bg="#1C1C1E", fg="white", width=10, height=2, font=("Helvetica", 14))
guessbutton.place(x=350, y=450)
def skipp():
for widget in SaveMe.winfo_children():
widget.place_forget()
six.place(x=0, y=0, relwidth=1, relheight=1)
skiplabel = Label(SaveMe, text="""You decided to skip this round. :( """, font=("Helvetica", 20), fg="white", bg="#1C1C1E", wraplength=800)
skiplabel.place(x=100, y=200)
nextbutton = Button(SaveMe, text="Next", borderwidth=0, highlightthickness=0, command=finalscreen,
bg="#1C1C1E", fg="white", width=10, height=2, font=("Helvetica", 14))
nextbutton.place(x=450, y=500)
yesbutton = Button(SaveMe, text="Yes", borderwidth=0, highlightthickness=0, command=hangman,
bg="#1C1C1E", fg="white", width=10, height=2, font=("Helvetica", 14))
yesbutton.place(x=350, y=700)
nobutton = Button(SaveMe, text="No", borderwidth=0, highlightthickness=0, command=skipp,
bg="#1C1C1E", fg="white", width=10, height=2, font=("Helvetica", 14))
nobutton.place(x=500, y=700)
## Add the seventh scene here!
def seventhscreen():
# quest 5: snake game
for widget in SaveMe.winfo_children():
widget.destroy()
seven = Label(SaveMe, image=room2Image, background="#1C1C1E", height=1000, width=1000)
seven.place(x=0, y=0, relwidth=1, relheight=1)
sixlabel = Label(SaveMe, text="""*You find a key inside the box and figure out it unlocks a door in this room.
You open the door and you find a letter hanging from the ceiling near a candle. You hear a voice*
Voice:"So you have made it until here. Congrats."
Voice:"Your next QUEST is to guess the word.
If you fail to guess it, the letter will burn before you get to read the contents "
Aaron: "Is it sort of a HANGMAN game."
Voice: "Smart guess! Now Goodluck." """, font=("Helvetica", 20), fg="white", bg="#1C1C1E", wraplength=800)
sixlabel.place(x=100, y=200)
word_list = ["HACKNIGHT" , "ACM" , "MAAYA" , "QUADRANGLE" , "RIYAL" , "PAIN" ,"HACKTOBERFEST", "BUNSAMOSA"]
secret_word = random.choice(word_list)
secret_word = secret_word.upper()
guessed = []
incorrect = 0
max = 6
display = list("_" * len(secret_word))
def snake_game():
w = 500
h = 500
fs = 10 # Food size
d = 100 # milliseconds, delay between movements
offsets = {
"up": (0, 20),
"down": (0, -20),
"left": (-20, 0),
"right": (20, 0)
}
def r():
global saap, kata, khanaT
saap = [[0, 0], [0, 20], [0, 40], [0, 60], [0, 80]]
kata = "up"
khanaT = nun() # Get new food position
food.goto(khanaT) # Move food turtle to the new position
hall()
def hall():
global kata
new_head = saap[-1].copy()
new_head[0] = saap[-1][0] + offsets[kata][0]
new_head[1] = saap[-1][1] + offsets[kata][1]
# Check if snake collides with itself
if new_head in saap[:-1]:
r() # Restart the game
else:
saap.append(new_head)
# Check if snake has eaten food
if not khana():
saap.pop(0) # Remove tail if no food was eaten
# Screen wrapping (snake reappears on the opposite side)
if saap[-1][0] > w / 2:
saap[-1][0] -= w
elif saap[-1][0] < - w / 2:
saap[-1][0] += w
elif saap[-1][1] > h / 2:
saap[-1][1] -= h
elif saap[-1][1] < -h / 2:
saap[-1][1] += h
pen.clearstamps() # Clears all the stamps
# Draw the snake
for segment in saap:
pen.goto(segment[0], segment[1])
pen.stamp()
screen.update() # Updates the screen
turtle.ontimer(hall, d) # Repeats hall() after delay d
def khana():
global khanaT
if dist(saap[-1], khanaT) < 20: # Check if the snake is close enough to the food
khanaT = nun() # Generate new food location
food.goto(khanaT) # Move food to new location
return True
return False
def nun():
# Correcting the float to int issue
x = random.randint(- int(w / 2) + fs, int(w / 2) - fs)
y = random.randint(- int(h / 2) + fs, int(h / 2) - fs)
return (x, y)
def dist(poos1, poos2):
x1, y1 = poos1
x2, y2 = poos2
distance = ((y2 - y1) ** 2 + (x2 - x1) ** 2) ** 0.5
return distance
# Movement control functions
def mathi():
global kata
if kata != "down": # Prevent 180-degree turns
kata = "up"
def go_right():
global kata
if kata != "left":
kata = "right"
def go_down():
global kata
if kata != "up":
kata = "down"
def go_left():
global kata
if kata != "right":
kata = "left"
# Screen setup
screen = turtle.Screen()
screen.setup(w, h)
screen.title("Snake Game")
screen.bgcolor("green")
screen.tracer(0) # Disable automatic screen updates
# Snake's body pen
pen = turtle.Turtle("square")
pen.penup()
# Food pen
food = turtle.Turtle()
food.shape("circle")
food.color("white")
food.shapesize(fs / 20) # Set the size of the food
food.penup()
# Keyboard controls
screen.listen()
screen.onkey(mathi, "Up")
screen.onkey(go_right, "Right")
screen.onkey(go_down, "Down")
screen.onkey(go_left, "Left")
r() # Start the game
turtle.done()
def hangman():
for widget in SaveMe.winfo_children():
widget.place_forget()
six.place(x=0, y=0, relwidth=1, relheight=1)
displaylabel = Label(SaveMe, text=" ".join(display), font=("Helvetica", 40), fg="white", bg="#1C1C1E")
displaylabel.place(x=350, y=300)
guessdisplay = Label(SaveMe, text="Guessed Letters: ", font=("Helvetica", 20), fg="white", bg="#1C1C1E")
guessdisplay.place(x=350, y=500)
guesslabel = Label(SaveMe, text=f"Guess Remaining: {max - incorrect}", font=("Helvetica", 20), fg="white", bg="#1C1C1E")
guesslabel.place(x=350, y=550)
def update():
displaylabel.config(text=" ".join(display))
if "_" not in display:
messagebox.showinfo("CONGRATS!", "You guessed the word. Now you can read the Letter!")
finalscreen()
if incorrect >= max:
messagebox.showwarning("OOPS!", f"You will never know the contents of the letter! The word was '{secret_word}'.")
finalscreen()
guessdisplay.config(text="Guessed Letters: " + ", ".join(guessed))
guesslabel.config(text=f"Guess Remaining: {max - incorrect}")
def guess_letter():
nonlocal incorrect
try:
letter = guessentry.get().upper()
guessentry.delete(0, END)
if len(letter) != 1 or not letter.isalpha():
messagebox.showwarning("Invalid", "Enter a single alphabet.")
return
if letter in guessed:
messagebox.showwarning("Guessed Before", f"You have guessed {letter} before.")
return
guessed.append(letter)
if letter in secret_word:
for i, char in enumerate(secret_word):
if char == letter:
display[i] = letter
update()
else:
incorrect += 1
update()
except Exception:
print( f"An error occurred while processing your guess")
guessentry = Entry(SaveMe, font=("Helvetica", 20), width=5)
guessentry.place(x=350, y=400)
guessbutton = Button(SaveMe, text="Submit", borderwidth=0, highlightthickness=0,
command=guess_letter, bg="#1C1C1E", fg="white", width=10, height=2, font=("Helvetica", 14))
guessbutton.place(x=350, y=450)
def skipp():
for widget in SaveMe.winfo_children():
widget.place_forget()
six.place(x=0, y=0, relwidth=1, relheight=1)
skiplabel = Label(SaveMe, text="""You decided to skip this round. :( """, font=("Helvetica", 20), fg="white", bg="#1C1C1E", wraplength=800)
skiplabel.place(x=100, y=200)
nextbutton = Button(SaveMe, text="Next", borderwidth=0, highlightthickness=0, command=finalscreen,
bg="#1C1C1E", fg="white", width=10, height=2, font=("Helvetica", 14))
nextbutton.place(x=450, y=500)
yesbutton = Button(SaveMe, text="Yes", borderwidth=0, highlightthickness=0, command=snake_game,
bg="#1C1C1E", fg="white", width=10, height=2, font=("Helvetica", 14))
yesbutton.place(x=350, y=700)
nobutton = Button(SaveMe, text="No", borderwidth=0, highlightthickness=0, command=skipp,
bg="#1C1C1E", fg="white", width=10, height=2, font=("Helvetica", 14))
nobutton.place(x=500, y=700)
def finalscreen():
# the ending which depends on the number of quests completed.. <2: bad ending , 2-3 : okay ending, >3: good ending
for widget in SaveMe.winfo_children():
widget.destroy()
fLabel = Label(SaveMe, image=finalImage, background="#1C1C1E", height=1000, width=1000)
fLabel.place(x=0, y=0, relwidth=1, relheight=1)
final = Label(SaveMe, text="""THE FINAL SCREEN. YOUR ENDING IS DECIDED HERE. """, font=("Helvetica", 20), fg="white", bg="#1C1C1E")
final.place(x=100, y=200)
startscreen()
SaveMe.mainloop()