这篇介绍第二个游戏,叫做Dragon Realm,就是简单的文本游戏,就像二选一一样,通过time模块中的函数来延迟时间。
游戏中有两个山洞,一个有宝藏,另一个则有厄运,玩家选择进入哪个山洞。
源代码:
import random
import time
def displayIntro():
print("""You are in a land full of dragons.In front of you,
you see two caves. In one cave, the dragon is friendly
and will share his treasure with you. The other dragon
is greedy and hungry, and eat you on sight.""")
print()
def chooseCave():
cave = ''
while cave != '1' and cave != '2':
print('Which cave will you go into?(1 or 2)')
cave = input()
return cave
def checkCave(chosenCave):
print('You approach the cave...')
time