Skip to content
This repository has been archived by the owner on May 25, 2022. It is now read-only.

update Readme.md and update Speed_Game #545

Open
wants to merge 6 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -198,3 +198,4 @@ SR No | Project | Author
101 | [Whatsapp Bot](https://github.com/Python-World/python-mini-projects/tree/master/projects/whatsapp_Bot)| [urmil89](https://github.com/urmil89)
102 | [Zip Bruter](https://github.com/Python-World/python-mini-projects/tree/master/projects/Zip_Bruter) | [Erdoğan YOKSUL](https://www.github.com/eredotpkfr)
103 | [CountDown Timer](https://github.com/Python-World/python-mini-projects/tree/master/projects/Countdown_timer) | [Japneet Kalra](https://github.com/japneetsingh035)
104 | [Speed Game](https://github.com/Python-World/python-mini-projects/tree/master/projects/Speed_Game) | [CNU CSE](https://github.com/songyi00/Speed_Game)
2 changes: 1 addition & 1 deletion projects/Speed_Game/macOS/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -206,7 +206,7 @@ def passBtn_click(self, tk, canv, check_img):
global country_img, answer
pass_count = pass_count - 1
if (pass_count < 0):
print("패스 그만")
print("Don't pass")
pass_count = 0
tk.messagebox.showerror('Pass', 'You Don\'t have pass ticket!')
else:
Expand Down
52 changes: 29 additions & 23 deletions projects/Speed_Game/windows/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,6 @@ def __init__(self, master):
filename = random.choice(os.listdir("./images"))
code = filename.split(".")[0]

# 엑셀에 없는 이미지일 경우 예외처리
while code.upper() not in df.index:
filename = random.choice(os.listdir("./images"))
code = filename.split(".")[0]
Expand Down Expand Up @@ -171,18 +170,22 @@ def checkBtn_click(self, master, user_text, check_answer, canv, check_img):

if (user_text == check_answer):
# correct
print('맞았습돠')
print('correct')
ImagePath = 'correct.png'
self.img3 = ImageTk.PhotoImage(Image.open(ImagePath).resize((100, 100), Image.ANTIALIAS))
resultImage = canv.create_image(450, 30, anchor="nw", image=self.img3)
self.img3 = ImageTk.PhotoImage(
Image.open(ImagePath).resize((100, 100), Image.ANTIALIAS))
resultImage = canv.create_image(
450, 30, anchor="nw", image=self.img3)
correct_count += 1
else:
# wrong
print('틀렸슴돠')
print('wrong')
ImagePath = 'wrong.png'
self.img4 = ImageTk.PhotoImage(Image.open(ImagePath).resize((100, 100), Image.ANTIALIAS))
self.img4 = ImageTk.PhotoImage(
Image.open(ImagePath).resize((100, 100), Image.ANTIALIAS))

resultImage = canv.create_image(450, 30, anchor="nw", image=self.img4)
resultImage = canv.create_image(
450, 30, anchor="nw", image=self.img4)

# resolve 15 problems
if problem_count <= 0:
Expand All @@ -191,55 +194,58 @@ def checkBtn_click(self, master, user_text, check_answer, canv, check_img):
filename = random.choice(os.listdir("./images"))
code = filename.split(".")[0]

# 엑셀에 없는 이미지일 경우 예외처리
# no entry in excel, Exception
while code.upper() not in df.index:
filename = random.choice(os.listdir("./images"))
code = filename.split(".")[0]

countryPath = "./images/" + filename
canv.after(1000,self.delete_img, canv, check_img)
self.img2 = ImageTk.PhotoImage(Image.open(countryPath).resize((180, 130), Image.ANTIALIAS))
self.img2 = ImageTk.PhotoImage(Image.open(countryPath)
.resize((180, 130), Image.ANTIALIAS))
country_img = canv.create_image(210, 130, anchor="nw", image=self.img2)
answer = df["country"][code.upper()]

print(answer)

def passBtn_click(self, tk, canv, check_img):
global pass_count, pass_window
global country_img, answer
pass_count = pass_count - 1
if (pass_count < 0):
print("패스 그만")
print("Don't pass")
pass_count = 0
tk.messagebox.showerror('Pass', 'You Don\'t have pass ticket!')
else:
filename = random.choice(os.listdir("./images"))
code = filename.split(".")[0]

# 엑셀에 없는 이미지일 경우 예외처리

while code.upper() not in df.index:
filename = random.choice(os.listdir("./images"))
code = filename.split(".")[0]

countryPath = "./images/" + filename
canv.after(1000, self.delete_img, canv, check_img)
self.img2 = ImageTk.PhotoImage(Image.open(countryPath).resize((180, 130), Image.ANTIALIAS))
self.img2 = ImageTk.PhotoImage(Image.open(countryPath)
.resize((180, 130), Image.ANTIALIAS))
country_img = canv.create_image(210, 130, anchor="nw", image=self.img2)
answer = df["country"][code.upper()]

self.delete_img(canv, pass_window)
BtnFont = tkFont.Font(family="Consolas", size=15)
pass_btn = tk.Button(self, text="pass: " + str(pass_count) + "/3",
width=10, height=1, font=BtnFont, foreground="yellow",
background="black", relief="ridge",
activebackground="yellow", activeforeground="black",
command=lambda: self.passBtn_click(tk, canv, country_img))
pass_window = canv.create_window((600 // 2) + 80, (500 // 2) + 140, window=pass_btn)
pass_btn = tk.Button(
self, text="pass: " + str(pass_count) + "/3",
width=10, height=1, font=BtnFont, foreground="yellow",
background="black", relief="ridge",
activebackground="yellow", activeforeground="black",
command=lambda: self.passBtn_click(tk, canv, country_img))
pass_window = canv.create_window(
(600 // 2) + 80, (500 // 2) + 140, window=pass_btn)

def delete_img(self, canv, dele_img_name):
canv.delete(dele_img_name)


class FinishPage(tk.Frame):
def __init__(self, master):
tk.Frame.__init__(self, master)
Expand All @@ -253,7 +259,6 @@ def __init__(self, master):
canv.create_text((600 // 2), (500 // 2) - 50, fill="white", text="total score : " + str(correct_count)+ "/15", font=labelFont)
canv.create_text((600 // 2), (500 // 2) + 50, fill="white", text="Good Job!", font=labelFont)


if __name__ == "__main__":
pygame.init()
mySound = pygame.mixer.Sound("SpeedGameBgm.mp3")
Expand All @@ -265,11 +270,12 @@ def __init__(self, master):
country_img = 0
pass_window = 0

df = pd.read_excel("./CountryCodeData.xlsx", index_col=0, names=["code", "country"])
df = pd.read_excel(
"./CountryCodeData.xlsx", index_col=0, names=["code", "country"])
print(df["country"]["KR"])

app = SampleApp()
app.title("Speed Game")

app.geometry('600x500+100+100')
app.mainloop()
app.mainloop()