python手记(游戏) 笨方法学python习题36【持续更新中】

如有意见或其他问题可在下方写下评论或加QQ:1693121186
欢迎一起讨论技术问题!
代码如下:

解说:这是笨方法的习题36,让做一个游戏。我会持续更新,如果想复制玩玩的同学,请别将主线线人以下的开发出来。
另外,想运行你还要在运行目录下创建一个文本文件,里面粘贴以下内容:

The world is known as the “god world”, and you are one of them.So let me tell you this level!
Level 1: muscle
Second realm: body
The third realm: the muddy source.
The third stage: Scott’s grip.
Stage 4: cloud

中文翻译:
这个世界被称为“神界”,等级非常分明,你就是其中的一员。所以让我来告诉这个等级分明吧!
第一境界:肌
第二境界:身
第三境界:浑源
第三境界:斯格特之握
第四境界:云

我会努力更新的,请在明天下午接受!
虽然是文字游戏,但我一定会让它更完美的!


更新日志:2018/1/22
昨天我做了一个小时,发现了一个BUG,今天我把它改了,我已经将上面的代码删了,请看下面的!
注:运行方式如图所示
前提,已进入python环境与已打开项目目录
这里写图片描述


BUG:我在运行时发现了一个bug,看到了原先的exit()吗?它有一个特性正常中断程序,我将在放在if语句里,但python运行竟将它扫描上了,到了那就退出了,所以我就改了,将所有exit()去掉了。

# -*- coding: utf-8 -*-

print "\n\tWelcome to the war."
def calatte(): 
    print "Welcome to the city of karat."
    print "Let me introduce the game with text content!哈哈哈"
calatte()

from sys import argv

script, filename = argv

txt = open(filename)

print "Here's your file %s:" % filename
print txt.read()

print "Type the filename again:"
file_again = raw_input("> ")

txt_again = open(file_again)

print txt_again.read()

#游戏函数
def questions_1():
    print "If there was an old woman who needed help, would you help?" #如果有一位老妇人需要帮助,你会帮忙吗?

    answer = raw_input("Help or not>") 

    if answer == "Help":
        print "\n\tOh!You are a man of good heart!Let me continue to ask you a few questions." #哦!你是一个心地善良的人!让我继续问你几个问题。
    elif answer == "not":
        print "h, you wicked man!" #啊,你这个恶毒的人!  
    else:
        print "Please answer!"
def questions_2():
    #如果你的亲人背叛你了,事后他们跪下求你绕过他们,你会?
    print "If your loved ones betray you, then they get down on their knees and beg you to get around them, you will?" 

    answer1 = raw_input("1.forgive\t2.kill\t3.insult ")

    if answer1 == "forgive":
        print "\aWell, yes, you can get the job or the main plot!" #嗯,不错,你可以去领取任务或去做主线剧情了!
    else:
        print "Sorry, please come back." #对不起,请重新来过

    if answer1 == "kill":
        print "\t\a\nThe killing is too heavy, so stop playing!" #杀戮太重,所以,别玩了!
    else:
        print "Sorry, please come back."   

    if answer1 == "insult":
        print "\t\a\nA man is not to be insulted when he is killed.You are not worthy to be a member of a warrior. Die!" #所谓“士可杀,不可辱”,你不配成为战士中的一员,死去吧!
    else:
        print "Sorry, please come back."


#游戏部分
print "\t\a\nI know you're ready to try, but I'll ask you a few questions first!" #我知道你准备好了,但是我先问你几个问题!
questions_1()

print "\t\a\nSecond question!"
questions_2()

#游戏函数
def The_main_sources(): #主线线人
    #你现在还很弱,我会送你一把大剑,让你在副本里寻找到属于你的一把武器
    print "Wu: You are still very weak, I will give you a big sword, let you find in the copy of a weapon belonging to you.!" 
    print "Tip: you get a big sword, \t\a great sword."
    print "%s: Oh!Thank you!" % my_name
    print "Wu: Don't mention it, you are now equipped to go to your first copy - wuthering canyon." #不用谢,你现在装备好前往你的第一个副本——呼啸峡谷
    print "%s: Bye!" % my_name

poem = """
\tGreat sword attributes:
\tAttack: 5000
\tDefense: 1000
\tLife added: 1000.
\tMagic bonus: 500.
\tTalent: beginner must be # 1 # # # # # #.
\t▅ forging times: 3/3
\t▅ refining: 0%
\tAccessories: fairy ▅ state
"""

print "Big sword properties:"
print "---------------------------------------"
print poem
print "-----------------------------------------"

def Out_of_the_valley(): #呼啸山谷外
    #这里便是呼啸山庄了,我在外面等着你,如果你死了,系统会将你返回到这里的
    print "Wu: Here is wuthering heights, and I am waiting for you, and if you die, the system will return you here."
    #你环顾四周,只见一条山谷从下往上,犹如一条大大的伤疤在大地上。再往山上看,那里有一个山顶,闪着蓝色光芒,于是你向吴问道:那个山顶为什么闪着光芒?
    print "You look around and see a valley from below, like a big scar on the ground.Look up the mountain, there is a mountain top, shining blue light, so you ask wu: why the mountain top shine?"
    #我给你解答吧,这个山顶是当年一个斯格特之握等级的强者打出的,似乎那个强者也死在了里面
    print "Wu: I'll give you the answer. The top of the hill was played by a strong man of the same age, who seemed to have died in it."
    print "Wu: If you're lucky enough to be there, you're likely to get a great deal of luck."#如果你有幸能当那里,你很可能会得到莫大的机缘。
    print "%r: Thank you very much!I got a copy." % my_name #谢谢!我进副本了

#你好!战士,我是你开始第一章剧情的线人。我叫无,你叫什么呢?
print "Hello!Soldier, I'm the source of your first chapter.My name is Wu. What's your name?" 

my_name = raw_input("> ")   

The_main_sources()
Out_of_the_valley()
Copy_entry_instruction = raw_input("Into the roaring valley?Please enter ") #进入呼啸山谷?请输入进入
if Copy_entry_instruction == "into":
    print "Entering wuthering heights." #正在进入呼啸山庄中
    print "\a\a\t%10"
    print "\a\a\t%20"
    print "\a\a\t%30"
    print "\a\a\t%50"
    print "\a\a\t%80"
    print "\a\a\t%99"
    print "-----------------"
    print "\a\aThe resources are loaded and entered." #资源加载完成,进入中
    print "-----------------"
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值