-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.py
305 lines (245 loc) · 8.42 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
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
# ---IMPORT PACKAGE---
from tkinter import *
from tkinter import messagebox
from PIL import ImageTk, Image
import pygame
from pygame import mixer
# ---SETTING TKINTER---
root = Tk()
root.title('A Simple Riddles Game')
root.geometry('500x700')
root.iconbitmap("icon.ico")
# ---IMPORT PYGAME AS BACKSOUND---
pygame.mixer.init()
mixer.music.load('audio.mp3')
mixer.music.play(-1)
# ---CREATE AND EXPORT IMAGE BACKGROUND AS LABEL---
bg1 = PhotoImage(file='1.png')
lbl1 = Label(root, image=bg1)
lbl1.place(x=0, y=0)
# ---CREATE A FUNCTION FOR BUTTON MUSIC---
def music():
music.load('audio.mp3')
music.play(-1)
def music2():
music.load('audio2.mp3')
music.play(-1)
def stopmusic():
mixer.music.stop()
# ---CREATE A FUNCTION FOR BUTTON PILIH---
def pilih():
global img
# ---SET NEW WINDOW---
root2 = Toplevel()
root2.title('A Simple Riddles Game')
root2.geometry('500x700')
# ---SET BACKGROUND---
img = PhotoImage(file='1.png')
lbl2 = Label(root2, image=img)
lbl2.place(x=0, y=0)
# ---FUNCTION---
def soall1():
go = soal1
game = root2.destroy
go()
game()
def soall2():
go = soal2
game = root2.destroy
go()
game()
def soall3():
go = soal3
game = root2.destroy
go()
game()
def soall4():
go = soal4
game = root2.destroy
go()
game()
def kembali():
game = root2.destroy
game()
# ---SET BUTTON---
button1 = Button(root2, text='SOAL 1', bg='brown', fg='white', bd=0, font=('Helevatica 10 bold'), padx=120, pady=10,
command=soall1)
button2 = Button(root2, text='SOAL 2', bg='brown', fg='white', bd=0, font=('Helevatica 10 bold'), padx=120, pady=10,
command=soall2)
button3 = Button(root2, text='SOAL 3', bg='brown', fg='white', bd=0, font=('Helevatica 10 bold'), padx=120, pady=10,
command=soall3)
button4 = Button(root2, text='SOAL 4', bg='brown', fg='white', bd=0, font=('Helevatica 10 bold'), padx=120, pady=10,
command=soall4)
button5 = Button(root2, text="Kembali", padx=20, pady=5, bd=0, command=kembali, bg="aqua", fg="black")
# ---DEFINE BUTTON---
button1.place(x=105, y=280)
button2.place(x=105, y=340)
button3.place(x=105, y=400)
button4.place(x=105, y=460)
button5.place(x=0, y=0)
# ---CREATE A FUNCTION FOR SOAL 1 - 4---
def soal1():
global img1
# ---SET NEW WINDOW---
root1 = Toplevel()
root1.title('A Simple Riddles Game')
root1.geometry('500x700')
# ---SET BACKGROUND---
img1 = PhotoImage(file='2.png')
lbl2 = Label(root1, image=img1)
lbl2.place(x=0, y=0)
# ---SET ENTRY LABEL---
e = Entry(root1, width=50, bg="white")
e.place(x=110, y=340)
e.insert(0, "Masukkan jawaban anda disini ^-^")
def soall1():
hello = e.get().lower()
if hello == 'katak beradik':
messagebox.askokcancel('Info', 'Jawaban anda benar ^-^')
go = pilih
game = root1.destroy
go()
game()
else:
messagebox.askokcancel('Info', 'Jawaban anda salah T_T')
go = soal1
game = root1.destroy
go()
game()
def kembali1():
go = pilih
game = root1.destroy
go()
game()
button1 = Button(root1, text="Cek Jawaban", padx=100, pady=10, bd=0, command=soall1, bg="brown", fg="white")
button2 = Button(root1, text="Kembali", padx=20, pady=5, bd=0, command=kembali1, bg="aqua", fg="black")
button1.place(x=122, y=420)
button2.place(x=0, y=0)
def soal2():
global img2
# ---SET NEW WINDOW---
root2 = Toplevel()
root2.title('A Simple Riddles Game')
root2.geometry('500x700')
# ---SET BACKGROUND---
img2 = PhotoImage(file='3.png')
lbl3 = Label(root2, image=img2)
lbl3.place(x=0, y=0)
# ---SET ENTRY LABEL---
e = Entry(root2, width=50, bg="white")
e.place(x=110, y=340)
e.insert(0, "Masukkan jawaban anda disini ^-^")
def soall2():
hello = e.get().lower()
if hello == 'sabun colek':
messagebox.askokcancel('Info', 'Jawaban anda benar ^-^')
go = pilih
game = root2.destroy
go()
game()
else:
messagebox.askokcancel('Info', 'Jawaban anda salah T_T')
go = soal2
game = root2.destroy
go()
game()
def kembali2():
go = pilih
game = root2.destroy
go()
game()
button1 = Button(root2, text="Cek Jawaban", padx=100, pady=10, bd=0, command=soall2, bg="brown", fg="white")
button2 = Button(root2, text="Kembali", padx=20, pady=5, bd=0, command=kembali2, bg="aqua", fg="black")
button1.place(x=122, y=420)
button2.place(x=0, y=0)
def soal3():
global img3
# ---SET NEW WINDOW---
root3 = Toplevel()
root3.title('A Simple Riddles Game')
root3.geometry('500x700')
# ---SET BACKGROUND---
img3 = PhotoImage(file='4.png')
lbl4 = Label(root3, image=img3)
lbl4.place(x=0, y=0)
# ---SET ENTRY LABEL---
e = Entry(root3, width=50, bg="white")
e.place(x=110, y=340)
e.insert(0, "Masukkan jawaban anda disini ^-^")
def soall3():
hello = e.get().lower()
if hello == '13 gajah':
messagebox.askokcancel('Info', 'Jawaban anda benar ^-^')
go = pilih
game = root3.destroy
go()
game()
else:
messagebox.askokcancel('Info', 'Jawaban anda salah T_T')
go = soal3
game = root3.destroy
go()
game()
def kembali3():
go = pilih
game = root3.destroy
go()
game()
button1 = Button(root3, text="Cek Jawaban", padx=100, pady=10, bd=0, command=soall3, bg="brown", fg="white")
button2 = Button(root3, text="Kembali", padx=20, pady=5, bd=0, command=kembali3, bg="aqua", fg="black")
button1.place(x=122, y=420)
button2.place(x=0, y=0)
def soal4():
global img4
# ---SET NEW WINDOW---
root4 = Toplevel()
root4.title('A Simple Riddles Game')
root4.geometry('500x700')
# ---SET BACKGROUND---
img4 = PhotoImage(file='5.png')
lbl5 = Label(root4, image=img4)
lbl5.place(x=0, y=0)
# ---SET ENTRY LABEL---
e = Entry(root4, width=50, bg="white")
e.place(x=110, y=340)
e.insert(0, "Masukkan jawaban anda disini ^-^")
def soall4():
hello = e.get().lower()
if hello == 'buah naga':
messagebox.askokcancel('Info', 'Jawaban anda benar ^-^')
go = pilih
game = root4.destroy
go()
game()
else:
messagebox.askokcancel('Info', 'Jawaban anda salah T_T')
go = soal4
game = root4.destroy
go()
game()
def kembali4():
go = pilih
game = root4.destroy
go()
game()
button1 = Button(root4, text="Cek Jawaban", padx=100, pady=10, bd=0, command=soall4, bg="brown", fg="white")
button2 = Button(root4, text="Kembali", padx=20, pady=5, bd=0, command=kembali4, bg="aqua", fg="black")
button1.place(x=122, y=420)
button2.place(x=0, y=0)
# ---CREATE A BUTTON---
btn1 = Button(root, text='Start Game', font=('Helevatica 10 bold'), bg='orange', pady=15, padx=100, bd=0, command=pilih)
btn2 = Button(root, text='Exit Game', font=('Helevatica 10 bold'), bg='orange', pady=15, padx=100, bd=0,
command=root.quit)
btn3 = Button(root, text='Ikson Music', font=('Helevatica 7 bold'), bg='aqua', pady=5, padx=20, bd=0, command=music)
btn4 = Button(root, text='Stop Music', font=('Helevatica 7 bold'), bg='aqua', pady=5, padx=20, bd=0, command=stopmusic)
btn5 = Button(root, text='Tiesto Music', font=('Helevatica 7 bold'), bg='aqua', pady=5, padx=20, bd=0, command=music2)
# ---DEFINE THE BUTTON---
btn1.place(x=110, y=340)
btn2.place(x=112, y=420)
btn3.place(x=0, y=0)
btn4.place(x=408, y=0)
btn5.place(x=80, y=0)
# ---MESSAGE BUTTON---
messagebox.askokcancel('Info Permainan', 'Selamat bermain... ^-^')
# ---MAINLOOP---
root.mainloop()