[第8天]Python小游戏“王者大作战”
今天自制了一个迷你小游戏,属于文字类打架游戏,更准确的说是电脑跟电脑对打。虽然是个很小的游戏,但是是自己亲手设计的,所以很有纪念价值,就把它贴到“简书”上了,嘻嘻!
import random,time
player_victory = 0
enemy_victory = 0
print("一年一度的王者争霸赛开始了!")
time.sleep(1.5)
print("各路英雄好汉纷纷报名参加")
time.sleep(1.5)
print("晋级赛采取三局两胜的形式")
time.sleep(1.5)
print("第一局登场的英雄是:法师【小乔】和战士【刘备】!")
for i in range(1,4):
time.sleep(3)
print(" ")
print("战斗现在开始!\n---------------第 %s 回合---------------"%i)
print(" ")
time.sleep(2)
player_HD = random.randint(3500,7000)
player_attack = random.randint(3100,3600)
enemy_HD = random.randint(6800,10000)
enemy_attack = random.randint(1600,2500)
print("【小乔】\血量:%s\攻击力:%s"%(player_HD,player_attack))
print("------------------------------")
time.sleep(1)
print("【刘备】\血量:%s\攻击力:%s"%(enemy_HD,enemy_attack))
print("------------------------------")
time.sleep(2)
while (player_HD > 0) and (enemy_HD > 0):
player_HD = player_HD - enemy_attack
enemy_HD = enemy_HD - player_attack
print("【小乔】发起猛烈进攻\n【刘备】的剩余血量:%s"%enemy_HD)
print("------------------------------")
time.sleep(1)
print("【刘备】发起猛烈进攻\n【小乔】的剩余血量:%s"%player_HD)
print("------------------------------")
time.sleep(1)
if player_HD > enemy_HD:
print("第 %s 回合:刘备死翘翘了,小乔赢了!"%i)
player_victory += 1
elif player_HD < enemy_HD:
print("第 %s 回合:悲催,刘备把小乔干掉了!"%i)
enemy_victory += 1
else:
print("第 %s 回合:哎呀,小乔和刘备同归于尽了"%i)
print("------------------------------")
time.sleep(2)
if player_victory > enemy_victory:
print("最终结果:小乔赢了!")
elif enemy_victory > player_victory:
print("最终结果:刘备赢了!")
else:
print("最终结果:平局!")
time.sleep(2)
print("今天的比赛就先进行到这里")
time.sleep(1.5)
print("为能坚持到现在的看官撒花ヽ(✿゚▽゚)ノ")
time.sleep(3)