Commit 941c4633 by BellCodeEditor

save project

parent 9d8bfb93
a=0
b=0
c=0
d=0
f=0
g=0
h=0
s=0
import random
while True:
a = random.randint(0,90) # 生成答案
b = random.randint(0,90)
c = random.randint(0,90)
d = random.randint(0,90)
f = random.randint(0,90)
g = random.randint(0,90)
h = random.randint(0,90)
print('本次'+str(a)+'-'+str(b)+'-'+str(c)+'-'+str(d)+'-'+str(f)+'-'+str(g)+'-'+str(h))
if a+b+c==90 and a+d+h==90 and a+23+g==90 and b+d+57==90 and c+d+g==90 and c+f+h==90 and 23+d+f==90 and g+57+h==90:
print('****************************'/n+str(a)/n+str(b)/n+str(c)/n+str(d)/n+str(f)/n+str(g)/n+str(h)/n+'*****************************************')
break
a=0
b=0
c=0
d=0
f=0
g=0
h=0
s=0
for i in range(0,45):
a=i
if a+b+c==90 and a+d+h==90 and a+23+g==90 and b+d+57==90 and c+d+g==90 and c+f+h==90 and 23+d+f==90 and g+57+h==90:
while True:
print('****************************'/n+str(a)/n+str(b)/n+str(c)/n+str(d)/n+str(f)/n+str(g)/n+str(h)/n+'*****************************************')
for j in range(0,45):
b=j
if a+b+c==90 and a+d+h==90 and a+23+g==90 and b+d+57==90 and c+d+g==90 and c+f+h==90 and 23+d+f==90 and g+57+h==90:
while True:
print('****************************'/n+str(a)/n+str(b)/n+str(c)/n+str(d)/n+str(f)/n+str(g)/n+str(h)/n+'*****************************************')
for k in range(0,45):
c=k
if a+b+c==90 and a+d+h==90 and a+23+g==90 and b+d+57==90 and c+d+g==90 and c+f+h==90 and 23+d+f==90 and g+57+h==90:
while True:
print('****************************'/n+str(a)/n+str(b)/n+str(c)/n+str(d)/n+str(f)/n+str(g)/n+str(h)/n+'*****************************************')
for l in range(0,45):
d=l
if a+b+c==90 and a+d+h==90 and a+23+g==90 and b+d+57==90 and c+d+g==90 and c+f+h==90 and 23+d+f==90 and g+57+h==90:
while True:
print('****************************'/n+str(a)/n+str(b)/n+str(c)/n+str(d)/n+str(f)/n+str(g)/n+str(h)/n+'*****************************************')
for m in range(0,45):
f=m
if a+b+c==90 and a+d+h==90 and a+23+g==90 and b+d+57==90 and c+d+g==90 and c+f+h==90 and 23+d+f==90 and g+57+h==90:
while True:
print('****************************'/n+str(a)/n+str(b)/n+str(c)/n+str(d)/n+str(f)/n+str(g)/n+str(h)/n+'*****************************************')
for n in range(0,45):
g=n
if a+b+c==90 and a+d+h==90 and a+23+g==90 and b+d+57==90 and c+d+g==90 and c+f+h==90 and 23+d+f==90 and g+57+h==90:
while True:
print('****************************'/n+str(a)/n+str(b)/n+str(c)/n+str(d)/n+str(f)/n+str(g)/n+str(h)/n+'*****************************************')
for o in range(0,45):
h=o
if o==44:
print('本次'+str(i)+'-'+str(j)+'-'+str(k)+'-'+str(l)+'-'+str(m)+'-'+str(n)+'-'+str(o+1))
if a+b+c==90 and a+d+h==90 and a+23+g==90 and b+d+57==90 and c+d+g==90 and c+f+h==90 and 23+d+f==90 and g+57+h==90:
while True:
print('****************************'/n+str(a)/n+str(b)/n+str(c)/n+str(d)/n+str(f)/n+str(g)/n+str(h)/n+'*****************************************')
\ No newline at end of file
username = "python" # 保存在服务器数据库中的用户账号(正确的账号) q = "python" # 保存在服务器数据库中的用户账号(正确的账号)
userpassword = "123456" # 保存在服务器数据库中的用户密码(正确的密码) w = "123456" # 保存在服务器数据库中的用户密码(正确的密码)
# 请用input()实现用户输入账号、密码的功能 # 请用input()实现用户输入账号、密码的功能
a=input('账号')
b=input('密码')
if a==q and b==w:
print('登陆成功')
# 如果用户输入的账号、密码正确,提示登陆成功 # 如果用户输入的账号、密码正确,提示登陆成功
\ No newline at end of file
users = {} # 存储用户数据的字典,键为用户名,值为密码
c = 0
cc={}
jieguo=0
y =0
username = ''
username1=''
username2=''
import 王者荣耀
def register():
"""注册新用户"""
username = input("请输入用户名(q退出):")
if username == 'q':
main()
if username in users:
print("该用户名已被注册,请重新输入!")
register()
else:
password = input("请输入密码:")
users[username] = password
cc[username] = 0
print("恭喜,注册成功!")
def login():
"""登录账户"""
username = input("请输入用户名(q退出):")
if username == 'q':
main()
if username in users:
if cc[username]==3:
print('用户已锁定')
else:
password = input("请输入密码(您还有"+str(3-cc[username])+'次输入机会):')
if username in users and password == users[username]:
print("登录成功!")
return username
else:
print("用户名或密码错误,请重新登录!")
cc[username] = cc[username]+1
login()
else:
print('没有此用户')
login()
def game():
jieguo=input("是否开始游戏?")
if jieguo=='是':
if username != '':
y=input('请问要玩什么游戏?(1-猜数游戏,2-贪吃蛇,3-王者荣耀)')
if y=='1':
print(username+',欢迎来到猜数游戏!')
import diy3
elif y=='2':
print(username+',欢迎来到贪吃蛇!')
import diy4
elif y=='3':
print(username+',欢迎来到王者峡谷!')
start_game()
else:
print('那返回主页面了哦!')
main()
else:
print('请先登录哦!')
def main():
"""程序入口"""
while True:
choice = input("请选择操作(1-注册,2-登录,3-游戏):")
if choice not in ('1', '2','3'):
print("输入的操作有误,请重新选择!")
continue
elif choice == '1':
register()
elif choice == '2':
login()
username1 = username
print(username1)
return username1
elif choice == '3':
game()
if __name__ == '__main__':
while True:
main()
username2 = username
\ No newline at end of file
import random
import time
c=0
q=0
while True:
#print('欢迎来到猜数游戏!')
min_num = input('最小可猜测值:') # 最小可猜测值
if not min_num.isdigit(): # 检查输入是否为数字
print("请输入一个有效数字!")
continue
else:
min_num=int(min_num)
break
while True:
max_num = input('最大可猜测值:') # 最大可猜测值
if not max_num.isdigit(): # 检查输入是否为数字
print("请输入一个有效数字!")
continue
else:
max_num=int(max_num)
break
q = float((max_num-min_num+1)//200)
ans = random.randint(min_num, max_num) # 生成答案
e=input('是否办理VIP(跳过加载)?')
if e=='是':
q=0.1
print('正在生成答案')
for i in range(6):
print('已生成%'+str(i*20))
time.sleep(q)
print('生成成功!')
print(f"猜数游戏:请在[{min_num}, {max_num}]的范围内猜一个数字")
while True:
guess = input("你的猜测是:")
if not guess.isdigit(): # 检查输入是否为数字
print("请输入一个有效数字!")
continue
guess = int(guess)
if guess < min_num or guess > max_num: # 检查输入是否在可猜测范围内
print("请输入一个在范围内的数字!")
continue
if guess > ans:
c+=1
print("你猜的太大了!你已经猜了"+str(c)+'次了!加油')
elif guess < ans:
c+=1
print("你猜的太小了!你已经猜了"+str(c)+'次了!加油')
else:
if c<=q*10:
print("恭喜你,猜对了!你一共猜了"+str(c)+'次!超过了全国%99的用户,继续保持!')
if c>q*10 and c<q*20:
print("恭喜你,猜对了!你一共猜了"+str(c)+'次!超过了全国%80的用户,在努力一把!')
if c>q*20:
print("恭喜你,猜对了!你一共猜了"+str(c)+'次!超过了全国%60的用户,下次加油!')
w=input('还要不要再来')
if w=='要':
pass
else:
print('再见,欢迎下次再来。')
break
\ No newline at end of file
import pygame
import random
# 初始化Pygame
pygame.init()
# 设置游戏窗口的大小和标题
width, height = 640, 480
screen = pygame.display.set_mode((width, height))
pygame.display.set_caption("贪吃蛇")
# 设置游戏的fps和计时器
fps = 5
clock = pygame.time.Clock()
# 定义颜色
white = (255, 255, 255)
black = (0, 0, 0)
red = (255, 0, 0)
green = (0, 255, 0)
# 定义蛇的初始状态
snake_head_pos = [random.randint(5, 15) * 20, random.randint(5, 15) * 20]
snake_body = [[snake_head_pos[0], snake_head_pos[1]],
[snake_head_pos[0] - 20, snake_head_pos[1]],
[snake_head_pos[0] - 40, snake_head_pos[1]]]
direction = "right"
# 定义食物的位置
food_pos = [random.randrange(1, width - 20, 20),
random.randrange(1, height - 20, 20)]
# 游戏循环
while True:
# 处理事件
for event in pygame.event.get():
if event.type == pygame.QUIT:
# 退出游戏
pygame.quit()
quit()
elif event.type == pygame.KEYDOWN:
# 处理键盘事件
if event.key == pygame.K_LEFT and direction != "right":
direction = "left"
elif event.key == pygame.K_RIGHT and direction != "left":
direction = "right"
elif event.key == pygame.K_UP and direction != "down":
direction = "up"
elif event.key == pygame.K_DOWN and direction != "up":
direction = "down"
# 移动蛇的位置
if direction == "left":
snake_head_pos[0] -= 20
elif direction == "right":
snake_head_pos[0] += 20
elif direction == "up":
snake_head_pos[1] -= 20
elif direction == "down":
snake_head_pos[1] += 20
# 检查蛇是否吃到食物
if snake_head_pos == food_pos:
food_pos = [random.randrange(1, width - 20, 20),
random.randrange(1, height - 20, 20)]
else:
snake_body.pop(0)
# 检查蛇是否撞到墙或自己
if snake_head_pos[0] < 0 or snake_head_pos[0] > width - 20 \
or snake_head_pos[1] < 0 or snake_head_pos[1] > height - 20 \
or [snake_head_pos[0], snake_head_pos[1]] in snake_body:
# 退出游戏
pygame.quit()
quit()
# 添加蛇头和蛇尾到蛇的身体列表
snake_body.append([snake_head_pos[0], snake_head_pos[1]])
# 填充背景颜色
screen.fill(white)
# 绘制蛇的身体和食物
for pos in snake_body:
pygame.draw.rect(screen, green, [pos[0], pos[1], 20, 20])
pygame.draw.rect(screen, red, [food_pos[0], food_pos[1], 20, 20])
# 更新游戏界面
pygame.display.update()
# 控制游戏帧率
clock.tick(fps)
\ No newline at end of file
import pygame
import random
# 初始化Pygame
pygame.init()
# 设置游戏窗口的大小和标题
width, height = 800, 600
screen = pygame.display.set_mode((width, height))
pygame.display.set_caption("俄罗斯方块")
# 定义颜色
white = (255, 255, 255)
black = (0, 0, 0)
red = (255, 0, 0)
green = (0, 255, 0)
blue = (0, 0, 255)
# 定义方块的大小和颜色
block_size = 20
colors = [red, green, blue]
# 定义不同形状的方块
shapes = [
((0, 1), (1, 1), (2, 1), (3, 1)), # ----
((0, 2), (0, 1), (1, 1), (2, 1)), # |--
((0, 1), (1, 1), (1, 2), (2, 2)), # --|
((0, 1), (1, 1), (2, 1), (2, 2)), # L
((0, 1), (1, 1), (2, 1), (2, 0)), # 反L
((1, 0), (2, 0), (0, 1), (1, 1)), # S
((0, 0), (1, 0), (1, 1), (2, 1)), # 反S
]
n_shapes = len(shapes)
# 随机生成一个形状的方块
shape_index = random.randint(0, n_shapes - 1)
shape = shapes[shape_index]
color_index = random.randint(0, len(colors) - 1)
color = colors[color_index]
# 定义方块的位置(初始在屏幕顶端中央位置)
x, y = width // 2 - block_size * 2, block_size * 2
# 定义方块的状态(需要向下一格)
state = "move_down"
# 定义游戏循环
fps = 5
clock = pygame.time.Clock()
while True:
# 处理事件
for event in pygame.event.get():
if event.type == pygame.QUIT:
# 退出游戏
pygame.quit()
quit()
elif event.type == pygame.KEYDOWN:
# 处理键盘事件
if event.key == pygame.K_LEFT:
x -= block_size
elif event.key == pygame.K_RIGHT:
x += block_size
elif event.key == pygame.K_DOWN:
state = "move_down_fast"
elif event.key == pygame.K_UP:
shape = list(zip(*shape[::-1]))
elif event.key == pygame.K_SPACE:
y -= block_size
# 根据方块状态更新方块的位置
if state == "move_down" or state == "move_down_fast":
y += block_size
# 将方块的状态设置为需要向下移动一格(每一帧都需要处理)
state = "move_down"
# 检查是否需要创建一个新的方块
if y >= height - block_size * 4:
# 退出游戏
pygame.quit()
quit()
# 检查是否需要合并方块
if y > 0:
for i in range(len(shape)):
px, py = shape[i]
if screen.get_at((x + px * block_size, y + py * block_size)) != white:
# 合并方块
for idx in shape:
screen.fill(color, (x + idx[0] * block_size, y + idx[1] * block_size, block_size, block_size))
# 随机生成新的方块
shape_index = random.randint(0, n_shapes - 1)
shape = shapes[shape_index]
color_index = random.randint(0, len(colors) - 1)
color = colors[color_index]
x, y = width // 2 - block_size * 2, block_size * 2
state = "move_down"
break
# 填充背景颜色
screen.fill
import random
a=0
a = random.randint(0,1)
print(a)
\ No newline at end of file
import random
import random
# 定义英雄类
class Hero:
def __init__(self, name, type, hp, attack):
self.name = name
self.type = type
self.hp = hp
self.attack = attack
def attack_hero(self, hero):
hero.hp -= self.attack
print(f"{self.name}攻击了{hero.name},造成了{self.attack}点伤害。{hero.name}剩余{hero.hp}点生命值。")
# 定义法师类
class Mage(Hero):
def __init__(self, name):
super().__init__(name, "法师", 80, 15)
self.skills = ["火球术", "冰冻术", "魔法护盾"]
self.ultimate_skill = "天崩地裂"
def fireball(self, hero):
skill_damage = random.randint(10, 20)
hero.hp -= skill_damage
print(f"{self.name}释放了火球术,对{hero.name}造成了{skill_damage}点伤害。{hero.name}剩余{hero.hp}点生命值。")
def freeze(self, hero):
skill_damage = random.randint(10, 20)
hero.hp -= skill_damage
print(f"{self.name}释放了冰冻术,对{hero.name}造成了{skill_damage}点伤害。{hero.name}剩余{hero.hp}点生命值。")
def magic_shield(self):
self.hp += 10
print(f"{self.name}释放了魔法护盾,恢复了10点生命值。{self.name}剩余{self.hp}点生命值。")
def ultimate(self, hero):
skill_damage = random.randint(30, 40)
hero.hp -= skill_damage
print(f"{self.name}释放了天崩地裂,对{hero.name}造成了{skill_damage}点伤害。{hero.name}剩余{hero.hp}点生命值。")
# 定义坦克类
class Tank(Hero):
def __init__(self, name):
super().__init__(name, "坦克", 150, 10)
self.skills = ["嘲讽", "盾牌猛击", "铁蹄冲撞"]
self.ultimate_skill = "龙魂猛击"
def taunt(self):
print(f"{self.name}使用了嘲讽,吸引了敌方英雄的注意力。")
def shield_hit(self, hero):
hero.hp -= self.attack
print(f"{self.name}使用了盾牌猛击,对{hero.name}造成了{self.attack}点伤害。{hero.name}剩余{hero.hp}点生命值。")
def charge(self, hero):
skill_damage = random.randint(20, 30)
hero.hp -= skill_damage
print(f"{self.name}使用了铁蹄冲撞,对{hero.name}造成了{skill_damage}点伤害。{hero.name}剩余{hero.hp}点生命值。")
def ultimate(self, hero):
skill_damage = random.randint(40, 50)
hero.hp -= skill_damage
print(f"{self.name}使用了龙魂猛击,对{hero.name}造成了{skill_damage}点伤害。{hero.name}剩余{hero.hp}点生命值。")
# 定义游戏开始函数
def start_game():
print("游戏开始!你需要选择你的英雄")
hero_type = input("请选择你的英雄类型(法师/坦克):")
if hero_type == "法师":
hero_name = input("请输入你的英雄名称:")
hero = Mage(hero_name)
elif hero_type == "坦克":
hero_name = input("请输入你的英雄名称:")
hero = Tank(hero_name)
else:
print("输入错误,游戏结束。")
return
print(f"你选择的英雄为{hero.name},类型为{hero.type},生命值为{hero.hp}。你需要面对的敌人是{name2},生命值为{hp2}。")
while hero.hp > 0 and hp2 > 0:
action = input(f"请选择你的技能(技能列表:{hero.skills},终极技:{hero.ultimate_skill}):")
if action == "火球术":
hero.fireball(enemy_hero)
elif action == "冰冻术":
hero.freeze(enemy_hero)
elif action == "魔法护盾":
hero.magic_shield()
elif action == "嘲讽":
hero.taunt()
elif action == "盾牌猛击":
hero.shield_hit(enemy_hero)
elif action == "铁蹄冲撞":
hero.charge(enemy_hero)
elif action == hero.ultimate_skill:
hero.ultimate(enemy_hero)
else:
print("输入错误,请重新选择。")
continue
if enemy_hero.hp <= 0:
print(f"{enemy_hero.name}已被击败,你赢得了胜利!")
break
enemy_action = random.choice(enemy_hero.skills + [enemy_hero.ultimate_skill])
if enemy_action == "火球术":
enemy_hero.fireball(hero)
elif enemy_action == "冰冻术":
enemy_hero.freeze(hero)
elif enemy_action == "魔法护盾":
enemy_hero.magic_shield()
elif enemy_action == "嘲讽":
enemy_hero.taunt()
elif enemy_action == "盾牌猛击":
enemy_hero.shield_hit(hero)
elif enemy_action == "铁蹄冲撞":
enemy_hero.charge(hero)
elif enemy_action == enemy_hero.ultimate_skill:
enemy_hero.ultimate(hero)
if hero.hp <= 0:
print(f"{hero.name}已被击败,你输了!")
break
# 定义主函数
if __name__ == '__main__':
name2 = "瑞兹"
hp2 = 100
enemy_hero = Mage(name2)
start_game()
\ No newline at end of file
++ "b/\347\224\250\346\210\267\345\220\215.txt"
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or sign in to comment