-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathRock-Paper-Scissors.py
324 lines (268 loc) · 9.87 KB
/
Rock-Paper-Scissors.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
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
import random as rm
import tkinter as tk
from tkinter import *
root = tk.Tk()
root.title('Rock Paper Scissors')
pic = PhotoImage(file = 'src/PngItem_1219930.png')
root.iconphoto(False,pic)
root.lcount=0
root.rcount=0
root.match=1
img = PhotoImage(file="src/rock.png")
img1 = PhotoImage(file="src/paper.png")
img2 = PhotoImage(file="src/scissors.png")
tb1 = PhotoImage(file="src/1st.png")
tb2 = PhotoImage(file="src/2nd.png")
tb3 = PhotoImage(file="src/3rd.png")
tb4 = PhotoImage(file="src/4th.png")
stone = PhotoImage(file = "src/erock.png")
scissor = PhotoImage(file = "src/escissors.png")
paper = PhotoImage(file = "src/epaper.png")
rstone = PhotoImage(file = "src/grock.png")
rscissor = PhotoImage(file = "src/gscissors.png")
rpaper = PhotoImage(file = "src/gpaper.png")
win = PhotoImage(file = "src/win.png")
loose = PhotoImage(file = "src/loose.png")
draw = PhotoImage(file = "src/draw.png")
poop = PhotoImage(file = "src/poop.png")
pc = PhotoImage(file = "src/pc.png")
up = PhotoImage(file = "src/thumbsup.png")
down = PhotoImage(file = "src/thumbsdown.png")
canvas = Canvas(root,bg="#f5f4f0", width=1600, height=1200)
def create_canvas():
canvas.create_image(20,20, anchor=NW, image=img)
canvas.create_image(400,400, anchor=NW, image=img1)
canvas.create_image(1100,200, anchor=NW, image=img2)
canvas.pack()
def round_rectangle(x1, y1, x2, y2, radius=25, **kwargs):
points = [x1+radius, y1,
x1+radius, y1,
x2-radius, y1,
x2-radius, y1,
x2, y1,
x2, y1+radius,
x2, y1+radius,
x2, y2-radius,
x2, y2-radius,
x2, y2,
x2-radius, y2,
x2-radius, y2,
x1+radius, y2,
x1+radius, y2,
x1, y2,
x1, y2-radius,
x1, y2-radius,
x1, y1+radius,
x1, y1+radius,
x1, y1]
canvas.create_polygon(points, **kwargs, smooth=True)
def final():
def call_main():
root.lcount=0
root.rcount=0
root.match=1
bup.destroy()
bdown.destroy()
main_menu()
def play_aga():
root.lcount=0
root.rcount=0
root.match=1
canvas.delete(ALL)
bup.destroy()
bdown.destroy()
btn1menu()
create_canvas()
bup = tk.Button(canvas,image = up,command = play_aga,bg = "#2980b9")
bup.place(x=330,y=425)
bdown = tk.Button(canvas,image = down,command = call_main,bg = "#2980b9")
bdown.place(x=890,y=425)
round_rectangle(300,200,1000,400,fill="#f8f7f3",outline = "#2980b9")
canvas.create_text(650,250,text = "Final score after "+str(root.match-1)+" rounds is\n"+" You : "+str(root.lcount)+"\t\tMe : "+str(root.rcount),font = ("Comic Sans MS",26))
if root.lcount>root.rcount:
canvas.create_text(650,350,text = "Well I believe you might have heard.... Best of 3",font = ("Comic Sans MS",16))
elif root.lcount<root.rcount:
canvas.create_text(650,350,text = "You can't overpower me. Want to challenge again?",font = ("Comic Sans MS",16))
else:
canvas.create_text(650,350,text = "I guess we have to play another round for the winner",font = ("Comic Sans MS",16))
def btn1menu():
canvas.delete(ALL)
def mmenu():
canvas.delete(ALL)
buttonback.destroy()
buttonfwd.destroy()
bch1.destroy()
bch2.destroy()
bch3.destroy()
root.lcount=0
root.rcount=0
root.match=1
main_menu()
create_canvas()
def btnn():
bch1.configure(state = NORMAL)
bch2.configure(state = NORMAL)
bch3.configure(state = NORMAL)
root.match+=1
canvas.delete(ALL)
if root.match>5 and root.lcount!=root.rcount:
buttonback.destroy()
buttonfwd.destroy()
bch1.destroy()
bch2.destroy()
bch3.destroy()
final()
return
btn1menu()
buttonback.destroy()
buttonfwd.destroy()
bch1.destroy()
bch2.destroy()
bch3.destroy()
buttonback = tk.Button(text = '\U000025c0',
borderwidth = 3,
width = 3,
height = 1,
bg = "#2980b9",
fg = "White",
font = ("Arial",24),
relief = RAISED,
activebackground = "#33B5E5",
command = mmenu
)
buttonback.place(x=25,y=25)
buttonfwd = tk.Button(text = "\U000025b6",
borderwidth = 3,
width = 3,
height = 1,
bg = "#2980b9",
fg = "white",
font = ("Arial",24),
relief = RAISED,
activebackground = "#33B5E5",
command = btnn
)
buttonfwd.place(x=125,y=25)
canvas.create_rectangle(400, 650, 1000, 710, fill="#91ccec",outline = "#2980b9")
canvas.create_image(440,680,image=poop)
canvas.create_image(960,680,image=pc)
def update_count():
canvas.create_text(490,680,text = str(root.lcount),font = ("Comic Sans MS",38,"bold"),fill = "#5f6a6a",tag="lcount")
canvas.create_text(905,680,text = str(root.rcount),font = ("Comic Sans MS",38,"bold"),fill = "#5f6a6a",tag="rcount")
canvas.create_text(690,680,text = "Round:"+str(root.match),font = ("Comic Sans MS",38,"bold"),fill = "#5f6a6a",tag="match")
canvas.update()
update_count()
def res(i):
if i < 0:
canvas.create_image(1010,600,image=loose)
root.lcount+=1
elif i == 0:
canvas.create_image(1020,600,image=draw)
elif i > 0:
canvas.create_image(1070,600,image=win)
root.rcount+=1
canvas.delete("lcount")
canvas.delete("rcount")
canvas.delete("match")
update_count()
def game(i):
ans = rm.randint(1,3)
lst = [rstone,rscissor,rpaper]
canvas.create_image(1290,500,image=lst[ans-1])
if ans == i:
res(0)
elif (i==1 and ans==3) or (i==2 and ans==1) or (i==3 and ans==2):
res(1)
else:
res(-1)
def btn_press1():
bch1.configure(state = DISABLED)
game(1)
def btn_press2():
bch2.configure(state = DISABLED)
game(2)
def btn_press3():
bch3.configure(state = DISABLED)
game(3)
canvas.create_image(1215,70,image=tb1)
canvas.create_image(1195,170,image=tb2)
canvas.create_image(1130,270,image=tb3)
canvas.create_image(190,400,image=tb4)
bch1 = tk.Button(canvas,image = stone,command = btn_press1)
bch1.place(x=70,y=360)
bch2 = tk.Button(canvas,image = scissor,command = btn_press2)
bch2.place(x=160,y=360)
bch3 = tk.Button(canvas,image = paper,command = btn_press3)
bch3.place(x=250,y=360)
def btn2menu():
def mmenu():
canvas.delete(ALL)
buttonback.destroy()
main_menu()
line = "Each match consist of \U0001f590 rounds.\nThe person with the most points wins.Duh.\nAnd as of course you might not be knowing\n\t "+"\U0000270A wins over \U0000270C \n\t "+"\U0000270B wins over \U0000270A \n\t "+"\U0000270C wins over \U0000270B"
round_rectangle(400, 30, 1000, 300, fill="#f8f7f3",outline = "#008080")
canvas.create_text(700,60,text = "SERIOUSLY BRUH!\U0001f632",font = ("Comic Sans MS",20))
canvas.create_text(700,200,text = line,font = ("Comic Sans MS",16))
buttonback = tk.Button(text = '\U000025c0',
borderwidth = 3,
width = 3,
height = 1,
bg = "#008080",
fg = "White",
font = ("Arial",24),
relief = RAISED,
activebackground = "#40a0a0",
command = mmenu
)
buttonback.place(x=25,y=625)
def main_menu():
canvas.delete(ALL)
create_canvas()
def cfunc():
button1.destroy()
button2.destroy()
button3.destroy()
btn2menu()
def callfunc():
button1.destroy()
button2.destroy()
button3.destroy()
btn1menu()
button1 = tk.Button(text = 'Challenge \U0001f60f',
borderwidth = 3,
width = 16,
height = 3,
bg = "#2980b9",
fg = "White",
font = ("Comic Sans MS",24),
relief = RAISED ,
activebackground = "#33B5E5",
command = callfunc
)
button1.place(x=550,y=100)
button2 = tk.Button(text = 'How To Play? \U0001f9d0',
borderwidth = 3,
width = 16,
height = 3,
bg = "#008080",
fg = "White",
font = ("Comic Sans MS",24),
relief = RAISED,
activebackground = "#40a0a0",
command = cfunc
)
button2.place(x=550,y=280)
button3 = tk.Button(text = "I'm going.Byee! \U0001f44b",
borderwidth = 3,
width = 16,
height = 3,
bg = "#3a9fbf",
fg = "White",
font = ("Comic Sans MS",24),
relief = RAISED ,
activebackground = "#5eb3ce",
command = root.destroy
)
button3.place(x=550,y=460)
main_menu()
mainloop()