그럼 내 게임() 함수는 내 firstlevel() 함수로 이동하지 않고 단지 종료 코드가 0 인 프로세스가 종료되었다고 말합니다. 그리고 나는 왜 내가 함수 이름을 변경하려고했는지 전혀 모르겠습니다. 그리고 아직도 행운 나는 정말 난 그냥 초보가 무엇을해야 하는지를 단서 ...이없는내 게임이 내 기능에 간다
코드 :
import winsound
import random as ran
import pickle
profile = {}
def fightsound():
winsound.PlaySound('fight2.wav', winsound.SND_FILENAME | winsound.SND_ASYNC)
def ranking():
if profile['xp'] >= 20:
profile['level'] += 1
if profile['xp'] >= 50:
profile['level'] += 1
if profile['xp'] >= 100:
profile['level'] += 1
game()
else:
game()
else:
game()
else:
game()
def play_bgmusic():
winsound.PlaySound('mk.wav', winsound.SND_FILENAME | winsound.SND_ASYNC)
def load_game():
global profile
profile = pickle.load(open("save.txt", "rb"))
game()
def fatality():
winsound.PlaySound('fatal2.wav', winsound.SND_FILENAME | winsound.SND_ASYNC)
def game():
global profile
print("Player: " + profile['player'])
print("XP: ", profile['xp'])
print("Level: ", profile['level'])
print("win: ", profile['win'])
print("loss: ", profile['loss'])
if profile['level'] >= 1:
print("1.) The ogre king...")
if profile['level'] >= 2:
print("2.) The realm of the witch!")
y = input("Select an option -> ")
if y == 1:
firstlevel()
def firstlevel():
global profile
fightsound()
enemyhp = 50
hp = 100
while enemyhp > 0:
print("Your hp: ", hp, " Enemy hp: ", enemyhp)
input("Press enter to attack...")
damage = ran.randint(0, 25)
enemyhp -= damage
damage = ran.randint(0, 25)
hp -= damage
if hp <= 0:
profile['xp'] += 5
profile['loss'] += 1
pickle.dump(profile, open("save.txt", "wb"))
print("You died, press enter to continue...")
game()
fatality()
profile['xp'] += 10
profile['win'] += 1
pickle.dump(profile, open("save.txt", "wb"))
input("You win! Press enter to continue...")
ranking()
def new_game():
global profile
player = input("Enter a player name -> ")
profile['player'] = player
profile['xp'] = 0
profile['level'] = 1
profile['win'] = 0
profile['loss'] = 0
pickle.dump(profile, open("save.txt", "wb"))
game()
def main():
play_bgmusic()
print(20 * "-")
print("| |")
print("| 1.) New Game |")
print("| 2.) Load Game |")
print("| 3.) Credits |")
print("| |")
print(20 * "-")
x = int(input("Select an option -> "))
if x == 1:
new_game()
if x == 2:
load_game()
if x == 3:
pass
main()
또한 순위 기능을 수정 하겠지만 포인트 옆에 있습니다 –
y가 1과 같다고 확신합니까? y를 인쇄 해보고 원하는 것을 얻는 지보십시오. – PandemoniumSyndicate
ok 시도해 보겠습니다. –