1.
import random
userList = [{"名字":"神女法师","攻击":8,"生命":4},
{"名字":"牛头人","攻击":3,"生命":7},
{"名字":"智慧老人","攻击":8,"生命":8},
{"名字":"凯撒酋长","攻击":5,"生命":4},
{"名字":"胡桃夹子","攻击":4,"生命":3}]
enemyList = [{"名字":"怪怪兽","攻击":4,"生命":3},
{"名字":"怪怪大魔王","攻击":8,"生命":7},
{"名字":"神算子","攻击":5,"生命":6},
{"名字":"串串兽","攻击":4,"生命":5},
{"名字":"终结者","攻击":6,"生命":4},
{"名字":"机关兽","攻击":7,"生命":3}]
userScore = 0 #设置我方初始得分
enemyScore = 0 #设置敌方初始得分
for i in range(5):
print("当前卡牌数量",len(userList))
#我方出牌
userIdx= input("输入抽取卡牌编号:")
userIdx = int(userIdx)
userCard = userList[userIdx-1] #获取对应卡牌
print("我方出牌", userCard)
userList.pop(userIdx-1)
#敌方出牌
enemyIdx = random.randint(0, len(enemyList) - 1)
enemyCard = enemyList[enemyIdx]
print("敌方出牌", enemyCard)
enemyList.pop(enemyIdx)
#我方得分
userHP = userCard["生命"] - enemyCard["攻击"]
if userHP > 0 :
userScore = userScore + 1
print("我方得分+1")
#敌方得分
enemyHP = enemyCard["生命"] - userCard["攻击"]
if enemyHP > 0 :
enemyScore = enemyScore + 1
print("敌方得分+1")
print("我方得分:", userScore)
print("敌方得分:", enemyScore)
print("== == == == == == == == == == == == ")
#判断胜负
if userScore > enemyScore:
print("我胜利")
elif userScore < enemyScore:
print("敌方胜利")
else:
print("平局")
2.
import random #导入random工具箱
answer = random.randint(1, 10) #产生1-10至今的随机整数
print(answer)
print("-- -- 数字猜猜猜 -- --") #输出游戏标题
while True:
guess = input("输入1-10之间的整数") #输入猜的整数
guess = int(guess)
if guess == answer: #情况1:猜对了
print("恭喜你,猜对了!")
break
if guess > answer: #情况2:猜大了
print("很遗憾,猜大了!")
if guess < answer: #情况3:猜对了
print("很遗憾,猜小了!")
3.文章来源:https://www.toymoban.com/news/detail-513182.html
import random
print("== == 口算训练器 == ==")
while True:
num1=random.randint(1,1500)
num2=random.randint(1,1500)
user=input(str(num1)+"+"+str(num2)+"=")
user=int(user)
answer=num1+num2
if user==answer:
print("回答正确!")
if user!=answer:
print("回答错误,正确答案:",answer)
print("----------------------")
4.(小插曲)文章来源地址https://www.toymoban.com/news/detail-513182.html
import turtle
def drawSquare():
turtle.pendown()
turtle.fillcolor("yellow")
turtle.begin_fill()
for i in range(4):
turtle.forward(300)
turtle.left(90)
turtle.end_fill()
turtle.penup()
def drawCircle():
turtle.pendown()
turtle.fillcolor("blue")
turtle.begin_fill()
turtle.circle(40)
turtle.end_fill()
turtle.penup()
def drawTriangle():
turtle.pendown()
turtle.fillcolor("red")
turtle.begin_fill()
for i in range(3):
turtle.forward(150)
turtle.left(120)
turtle.end_fill()
turtle.penup()
turtle.goto(-150,-150)
drawSquare()
turtle.goto(-75,-30)
drawCircle()
turtle.goto(75,30)
drawCircle()
turtle.goto(0,-100)
drawCircle()
turtle.goto(-150,150)
drawTriangle()
turtle.goto(0,150)
drawTriangle()
到了这里,关于不需要pygame的摸鱼游戏大集合的文章就介绍完了。如果您还想了解更多内容,请在右上角搜索TOY模板网以前的文章或继续浏览下面的相关文章,希望大家以后多多支持TOY模板网!