当前位置:   article > 正文

不需要pygame的摸鱼游戏大集合_python不用pygame的游戏

python不用pygame的游戏

1.

  1. import random
  2. userList = [{"名字":"神女法师","攻击":8,"生命":4},
  3. {"名字":"牛头人","攻击":3,"生命":7},
  4. {"名字":"智慧老人","攻击":8,"生命":8},
  5. {"名字":"凯撒酋长","攻击":5,"生命":4},
  6. {"名字":"胡桃夹子","攻击":4,"生命":3}]
  7. enemyList = [{"名字":"怪怪兽","攻击":4,"生命":3},
  8. {"名字":"怪怪大魔王","攻击":8,"生命":7},
  9. {"名字":"神算子","攻击":5,"生命":6},
  10. {"名字":"串串兽","攻击":4,"生命":5},
  11. {"名字":"终结者","攻击":6,"生命":4},
  12. {"名字":"机关兽","攻击":7,"生命":3}]
  13. userScore = 0 #设置我方初始得分
  14. enemyScore = 0 #设置敌方初始得分
  15. for i in range(5):
  16. print("当前卡牌数量",len(userList))
  17. #我方出牌
  18. userIdx= input("输入抽取卡牌编号:")
  19. userIdx = int(userIdx)
  20. userCard = userList[userIdx-1] #获取对应卡牌
  21. print("我方出牌", userCard)
  22. userList.pop(userIdx-1)
  23. #敌方出牌
  24. enemyIdx = random.randint(0, len(enemyList) - 1)
  25. enemyCard = enemyList[enemyIdx]
  26. print("敌方出牌", enemyCard)
  27. enemyList.pop(enemyIdx)
  28. #我方得分
  29. userHP = userCard["生命"] - enemyCard["攻击"]
  30. if userHP > 0 :
  31. userScore = userScore + 1
  32. print("我方得分+1")
  33. #敌方得分
  34. enemyHP = enemyCard["生命"] - userCard["攻击"]
  35. if enemyHP > 0 :
  36. enemyScore = enemyScore + 1
  37. print("敌方得分+1")
  38. print("我方得分:", userScore)
  39. print("敌方得分:", enemyScore)
  40. print("== == == == == == == == == == == == ")
  41. #判断胜负
  42. if userScore > enemyScore:
  43. print("我胜利")
  44. elif userScore < enemyScore:
  45. print("敌方胜利")
  46. else:
  47. print("平局")

2.

  1. import random #导入random工具箱
  2. answer = random.randint(1, 10) #产生1-10至今的随机整数
  3. print(answer)
  4. print("-- -- 数字猜猜猜 -- --") #输出游戏标题
  5. while True:
  6. guess = input("输入1-10之间的整数") #输入猜的整数
  7. guess = int(guess)
  8. if guess == answer: #情况1:猜对了
  9. print("恭喜你,猜对了!")
  10. break
  11. if guess > answer: #情况2:猜大了
  12. print("很遗憾,猜大了!")
  13. if guess < answer: #情况3:猜对了
  14. print("很遗憾,猜小了!")

3.

  1. import random
  2. print("== == 口算训练器 == ==")
  3. while True:
  4. num1=random.randint(1,1500)
  5. num2=random.randint(1,1500)
  6. user=input(str(num1)+"+"+str(num2)+"=")
  7. user=int(user)
  8. answer=num1+num2
  9. if user==answer:
  10. print("回答正确!")
  11. if user!=answer:
  12. print("回答错误,正确答案:",answer)
  13. print("----------------------")

4.(小插曲)

  1. import turtle
  2. def drawSquare():
  3. turtle.pendown()
  4. turtle.fillcolor("yellow")
  5. turtle.begin_fill()
  6. for i in range(4):
  7. turtle.forward(300)
  8. turtle.left(90)
  9. turtle.end_fill()
  10. turtle.penup()
  11. def drawCircle():
  12. turtle.pendown()
  13. turtle.fillcolor("blue")
  14. turtle.begin_fill()
  15. turtle.circle(40)
  16. turtle.end_fill()
  17. turtle.penup()
  18. def drawTriangle():
  19. turtle.pendown()
  20. turtle.fillcolor("red")
  21. turtle.begin_fill()
  22. for i in range(3):
  23. turtle.forward(150)
  24. turtle.left(120)
  25. turtle.end_fill()
  26. turtle.penup()
  27. turtle.goto(-150,-150)
  28. drawSquare()
  29. turtle.goto(-75,-30)
  30. drawCircle()
  31. turtle.goto(75,30)
  32. drawCircle()
  33. turtle.goto(0,-100)
  34. drawCircle()
  35. turtle.goto(-150,150)
  36. drawTriangle()
  37. turtle.goto(0,150)
  38. drawTriangle()

声明:本文内容由网友自发贡献,不代表【wpsshop博客】立场,版权归原作者所有,本站不承担相应法律责任。如您发现有侵权的内容,请联系我们。转载请注明出处:https://www.wpsshop.cn/w/小丑西瓜9/article/detail/386710
推荐阅读
相关标签
  

闽ICP备14008679号