Skip to content

Commit 73095d1

Browse files
committed
Added Word Search Game in Pygames Scripts
1 parent d3d975d commit 73095d1

18 files changed

+259
-0
lines changed

Diff for: PyGamesScripts/Word Search Game/Images/1.gif

473 KB
Loading

Diff for: PyGamesScripts/Word Search Game/Images/10.gif

339 KB
Loading

Diff for: PyGamesScripts/Word Search Game/Images/2.gif

434 KB
Loading

Diff for: PyGamesScripts/Word Search Game/Images/3.gif

377 KB
Loading

Diff for: PyGamesScripts/Word Search Game/Images/4.gif

374 KB
Loading

Diff for: PyGamesScripts/Word Search Game/Images/5.gif

374 KB
Loading

Diff for: PyGamesScripts/Word Search Game/Images/6.gif

374 KB
Loading

Diff for: PyGamesScripts/Word Search Game/Images/7.gif

372 KB
Loading

Diff for: PyGamesScripts/Word Search Game/Images/8.gif

374 KB
Loading

Diff for: PyGamesScripts/Word Search Game/Images/9.gif

128 KB
Loading

Diff for: PyGamesScripts/Word Search Game/Images/final_ans.gif

170 KB
Loading
128 KB
Loading

Diff for: PyGamesScripts/Word Search Game/Images/front.gif

185 KB
Loading
31 MB
Loading

Diff for: PyGamesScripts/Word Search Game/Images/score1.gif

36.8 KB
Loading

Diff for: PyGamesScripts/Word Search Game/README.md

+58
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,58 @@
1+
# ✔ WORD SEARCH GAME
2+
- ### An "Word Search Game" is a game created in python with tkinter gui.
3+
- ### In this game player will be given a board with Engliah alphabets in each cell of the board.
4+
- ### And there will be 15 words given to player one by one, and for each word, player need to select YES if word is there in the board other wise NO.
5+
- ### Also the word can be present in the board, either horizontally, vertically or cana be on any diagonal also.
6+
- ### The points each level will be shown at the top right corner.
7+
- ### At last, final score will be shown along with count of correct and wrong answer.
8+
- ### At last player can also see the final answer, in which a board will be shown in which all searchable words will be highlighted with different colour.
9+
10+
****
11+
12+
# REQUIREMENTS :
13+
- ### python 3
14+
- ### tkinter module
15+
- ### from tkinter messagebox module
16+
17+
****
18+
19+
# How this Script works :
20+
- ### User just need to download the file and run the word_search_game.py on their local system.
21+
- ### Now on the main window of the game, the player can start playing the game using START button.
22+
- ### Before starting, player should see the rules for this game by clicking on RULES button.
23+
- ### And after that player can start playing, and check whether his answer is correct or not by clicking on the CHECK button.
24+
- ### Also player will be shown the final score at the end of the game, and also the final answer in which a board will be shown in which all searchable words will be highlighted with different colour.
25+
- ### Also there is an exit button, clicking on which exit dialog box appears asking for the permission of the user for closing the window.
26+
27+
# Purpose :
28+
- ### The basic purpose of this game is for playing and it also checks how fastly player can search any word.
29+
30+
# Compilation Steps :
31+
- ### Install tkinter, pandas
32+
- ### After that download the code file, and run word_search_game.py on local system.
33+
- ### Then the game will start running and player can play the game and watch the final score at last, and also can watch the final answer also.
34+
35+
# SCREENSHOTS :
36+
37+
****
38+
39+
<p align="center">
40+
<img width = 1000 src="Images/1.jpg" /><br>
41+
<img width = 1000 src="Images/2.jpg" /><br>
42+
<img width = 1000 src="Images/3.jpg" /><br>
43+
<img width = 1000 src="Images/4.jpg" /><br>
44+
<img width = 1000 src="Images/5.jpg" /><br>
45+
<img width = 1000 src="Images/6.jpg" /><br>
46+
<img width = 1000 src="Images/7.jpg" /><br>
47+
<img width = 1000 src="Images/8.jpg" /><br>
48+
<img width = 1000 src="Images/9.jpg" /><br>
49+
<img width = 1000 src="Images/10.jpg" /><br>
50+
</p>
51+
52+
****
53+
54+
# Below is link to video of how game is to be played :
55+
<p align="center">
56+
<img src="Images/sample_video.gif" /><br>
57+
</p>
58+

Diff for: PyGamesScripts/Word Search Game/requirements.txt

+2
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
libraries used : tkinter
2+
messagebox

Diff for: PyGamesScripts/Word Search Game/word_search_game.py

+199
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,199 @@
1+
2+
from tkinter import *
3+
from tkinter import messagebox
4+
import tkinter.messagebox as mbox
5+
import tkinter as tk
6+
7+
8+
# created a main window
9+
root = Tk()
10+
root.title("Word Search Game")
11+
root.geometry('1100x750')
12+
13+
14+
# ------------------------------------- frame0 -------------------------------------
15+
def des_f0():
16+
f0.destroy()
17+
18+
# function defined to show rules
19+
def show_rules():
20+
mbox.showinfo("RULES", "1.) Player will be given word board with alphabets in it.\n\n2.) There will 15 words will be displayed on screen one by one and player need to YES or NO for that word is present in word board or not respectively.\n\n3.) The points each word will be shown at the top right corner.\n\n4.) At last, final score will be shown along with count of correct and wrong answer, and also user can see the words that are present in it at the end.")
21+
22+
# created first main frame
23+
f0 = Frame(root, height=750, width=1100)
24+
f0.propagate(0)
25+
f0.pack(side='top')
26+
27+
# function for adding image in frame 1
28+
c = Canvas(f0, width=1100, height=750)
29+
c.pack()
30+
p = PhotoImage(file='Images/front.gif')
31+
c.create_image(130, 50, image=p, anchor=NW)
32+
33+
# created start button
34+
startb = Button(f0, text="START",command=des_f0,font=("Arial", 20), bg = "light green", fg = "blue", borderwidth=3, relief="raised")
35+
startb.place(x = 120 , y =600 )
36+
37+
# created start button
38+
rulesb = Button(f0, text="RULES",command=show_rules,font=("Arial", 20), bg = "light green", fg = "blue", borderwidth=3, relief="raised")
39+
rulesb.place(x = 480 , y =600 )
40+
41+
# ------------------------- frame1 - level1 --------------------------------------
42+
word_ques = ["MOUSE","JAGUAR","LION", "FERRET","GIBREL","FISH","PEACOCK","CHINCHILLA","GUINEA","PIGEON","CHICKEN", "SNAKE","FLAMINGO","TURTLE","LIZARD"]
43+
word_ans = ["YES","NO","NO", "YES","YES","YES","NO","YES","YES","NO","YES", "YES","NO","YES","YES"]
44+
45+
ind = -1
46+
cr = 0
47+
wr = 0
48+
cnt = 15
49+
def initial():
50+
global ind
51+
52+
ind = ind + 1
53+
word.configure(text=word_ques[ind])
54+
55+
def see_ans():
56+
f2.destroy()
57+
58+
f3 = Frame(root, width=1100, height=750)
59+
f3.propagate(0)
60+
f3.pack(side='top')
61+
62+
c3 = Canvas(f3, width=1100, height=750, bg="white") # blue
63+
c3.pack()
64+
p3 = PhotoImage(file="Images/score1.gif")
65+
c3.create_image(150, 10, image=p3, anchor="nw")
66+
w3 = Canvas(root)
67+
w3.p3 = p3
68+
69+
70+
def next_switch():
71+
global ind, cnt
72+
cnt = cnt - 1
73+
if (cnt >= 0):
74+
lives_cnt1 = tk.Label(text=" ", font=("Arial", 30), fg="brown")
75+
lives_cnt1.place(x=940, y=20)
76+
lives_cnt = tk.Label(text=cnt, font=("Arial", 30), fg="brown") # same way bg
77+
lives_cnt.place(x=940, y=20)
78+
if (cnt == -1):
79+
mbox.showinfo("GAME OVER", "GAME OVER !")
80+
f1.destroy()
81+
82+
f2 = Frame(root, width=1100, height=750)
83+
f2.propagate(0)
84+
f2.pack(side='top')
85+
86+
c2 = Canvas(f2, width=1100, height=750, bg="white") # blue
87+
c2.pack()
88+
p2 = PhotoImage(file="Images/score1.gif")
89+
c2.create_image(350, 10, image=p2, anchor="nw")
90+
w2 = Canvas(root)
91+
w2.p2 = p2
92+
93+
score1 = Label(f2, text=str(cr * 10) + "/150", font=("Arial", 100), fg="green", bg="white")
94+
score1.place(x=350, y=250)
95+
96+
see1 = Label(f2, text="SEE HOW WELL YOU CAN SEARCH WORDS", font=("Arial", 30), fg="brown", bg="light yellow")
97+
see1.place(x=150, y=500)
98+
see2 = Label(f2, text="Correct Answer :" + str(cr) + "/15", font=("Arial", 30), fg="orange",
99+
bg="white")
100+
see2.place(x=350, y=580)
101+
see3 = Label(f2, text="Wrong Answer :" + str(wr) + "/15", font=("Arial", 30), fg="blue", bg="white")
102+
see3.place(x=350, y=650)
103+
# # keyboard button created for opening keyboard
104+
# seeansb = Button(f2, text="SEE ANS", command=see_ans, font=("Arial", 20), bg="light green", fg="blue",borderwidth=3, relief="raised")
105+
# seeansb.place(x=860, y=650)
106+
107+
m1 = mbox.askokcancel("Final Answer", "Do You want to see Final Answer")
108+
if(m1):
109+
f2.destroy()
110+
111+
f3 = Frame(root, width=1100, height=750)
112+
f3.propagate(0)
113+
f3.pack(side='top')
114+
115+
c3 = Canvas(f3, width=1100, height=750, bg="white") # blue
116+
c3.pack()
117+
p3 = PhotoImage(file="Images/final_ans.gif")
118+
c3.create_image(150, 10, image=p3, anchor="nw")
119+
w3 = Canvas(root)
120+
w3.p3 = p3
121+
122+
123+
ind = ind + 1
124+
if(ind<=14):
125+
word.configure(text=word_ques[ind])
126+
127+
def answer_check():
128+
global cr, wr
129+
selected_ans = word1_var.get()
130+
if(ind<=14):
131+
if(selected_ans == word_ans[ind]):
132+
mbox.showinfo('Success', 'Your answer is correct')
133+
cr = cr + 1
134+
next_switch()
135+
else:
136+
mbox.showerror('Error','Your answer is wrong')
137+
wr = wr + 1
138+
next_switch()
139+
else:
140+
next_switch()
141+
142+
143+
# created frame 1
144+
f1 = Frame(root, height=750, width=1100)
145+
f1.propagate(0)
146+
f1.pack(side='top')
147+
148+
# function for adding image in frame 1
149+
c1 = Canvas(f1, width=1100, height=750)
150+
c1.pack()
151+
p1 = PhotoImage(file='Images/final_ques.gif')
152+
c1.create_image(20, 10, image=p1, anchor=NW)
153+
154+
lives = tk.Label(f1,text = "Lives : ", font=("Arial", 30), fg="brown") # same way bg
155+
lives.place(x = 800, y = 20)
156+
157+
lives_cnt = tk.Label(f1,text = 15, font=("Arial", 30), fg="brown") # same way bg
158+
lives_cnt.place(x = 940, y = 20)
159+
160+
# label for showing points on tp right corner
161+
points1 = Label(f1, text="Points : " + str(10), font=("Arial", 35), fg="magenta")
162+
points1.place(x = 800, y = 80)
163+
164+
# for starting top label
165+
word = Label(f1, font=("Arial", 30), fg="brown")
166+
word.place(x=800, y=250)
167+
168+
# for starting top label
169+
select = Label(f1, text='Select Ans : ', font=("Arial", 30), fg="green")
170+
select.place(x=750, y=320)
171+
172+
word1_var = tk.StringVar()
173+
word1_choices = ["YES", "NO"]
174+
word1_menu = OptionMenu(f1, word1_var, *word1_choices)
175+
word1_menu.config(font=("Arial", 20), bg="light green", fg="blue", borderwidth=3)
176+
word1_menu["menu"].config(font=("Arial", 15), bg="light yellow", fg="blue")
177+
word1_menu.place(x=980, y=320)
178+
word1_var.set("NO")
179+
180+
# keyboard button created for opening keyboard
181+
checkb = Button(f1, text="CHECK",command=answer_check,font=("Arial", 20), bg = "light green", fg = "blue", borderwidth=3, relief="raised")
182+
checkb.place(x =840 , y =480 )
183+
184+
initial()
185+
# -------------------------------------------------------------------------------------
186+
187+
188+
# function for exiting
189+
def exit_win():
190+
if messagebox.askokcancel("Exit", "Do you want to exit?"):
191+
root.destroy()
192+
193+
# created exit button
194+
exitb = Button(root, text="EXIT",command=exit_win,font=("Arial", 20), bg = "red", fg = "blue", borderwidth=3, relief="raised")
195+
exitb.place(x =860 , y =600 )
196+
197+
198+
root.protocol("WM_DELETE_WINDOW", exit_win)
199+
root.mainloop()

0 commit comments

Comments
 (0)