파이썬 파일 클릭할시 열리고 바로 닫히는 현상이 일어납니다
조회수 839회
안녕하세요.. 비주얼 스튜디오 코드를 이용하여 파이썬 게임을 제작하고 비주얼 스튜디오 내에서 실행을 하였을때에는 정상적으로 작동을 하였습니다. 그런데 그 파일을 더블클릭하면 잠시 창이 뜨고 바로 닫히는 현상이 일어납니다. 분명 다른 파일은 정상적으로 작동하는데 말이죠... 이 파일은 가위 바위 보 게임을 작성을 한것인데, 왜 이 파일을 더블클릭하면 작동이 되다가 바로 꺼지는지 모르겠습니다. 제가 작성한 코드들 중에서 어떤 오류가 있는 것일까요.......
import random
import pygame
import time
import datetime
import sqlite3
data = sqlite3.connect("Game/resource/userDB.db", isolation_level=None)
cursor = data.cursor()
cursor.execute(
"CREATE TABLE IF NOT EXISTS records(id INTEGER PRIMARY KEY AUTOINCREMENT, win INTEGER, playtime text, date text)"
)
pygame.init()
music = pygame.mixer.Sound("Game\Godmode.wav")
music.play(-1)
rsp = ["가위", "바위", "보"]
user = 0
count = 0
win = 0
input("가위바위보 게임입니다. 시작하려면 Enter를 눌러주세요\n")
start = time.time()
print("가위, 바위, 보 중 하나를 입력해주세요. 종료하시려면 '종료'를 입력해주세요.\n")
while user != "종료":
user = input("가위 바위 보!\n")
random.shuffle(rsp)
com = random.choice(rsp)
if com == "가위":
print("컴퓨터 : 가위")
if user == "가위":
print("유저 : 가위\n")
print("무승부입니다\n")
elif user == "바위":
win = win + 1
print("유저 : 바위\n")
print("당신이 승리하였습니다.\n")
elif user == "보":
print("유저 : 보\n")
print("컴퓨터가 승리하였습니다\n")
elif com == "바위":
print("컴퓨터 : 바위")
if user == "가위":
print("유저 : 가위\n")
print("컴퓨터가 승리하였습니다\n")
elif user == "바위":
print("유저 : 바위\n")
print("무승부 입니다\n")
elif user == "보":
win = win + 1
print("유저 : 보\n")
print("당신이 승리하였습니다\n")
elif com == "보":
print("컴퓨터 : 보")
if user == "가위":
win = win + 1
print("유저 : 가위\n")
print("당신이 승리하였습니다\n")
elif user == "바위":
print("유저 : 바위\n")
print("컴퓨터가 승리하였습니다\n")
elif user == "보":
print("유저 : 보\n")
print("무승부입니다\n")
if user == "종료":
break
count = count + 1
end = time.time()
playtime = end - start
playtime = format(playtime, ".2f")
cursor.execute(
"INSERT INTO records('win', 'playtime', 'date') VALUES (?, ?, ?)",
(win, playtime, datetime.datetime.now().strftime("%Y-%m-%d %H:%M:%S")),
)
print("총 게임 시간 : ", playtime)
print("총 게임 횟수 : ", count)
print("유저가 이깃 횟수 : ", win)
print("가위바위보 게임을 종료합니다. 좋은 하루 보내세요")
time.sleep(30)
music.terminate()
-
(•́ ✖ •̀)
알 수 없는 사용자
댓글 입력