Commit a9fcb0ee by BellCodeEditor

auto save

parent 6a7fd0e0
Showing with 80 additions and 6 deletions
import random
import pygame
from pygame.locals import *
from sys import exit
import stringpygame.init() #初始化 display 模块
#全屏显示
#screen = pygame.display.Info()
#PANEL_width = screen.current_w #设置屏幕的宽度
#PANEL_highly = screen.current_h #设置屏幕的高度
#自定义显示大小
PANEL_width = 800 #设置屏幕的宽度
PANEL_highly = 900 #设置屏幕的高度FONT_PX = 20
winSur = pygame.display.set_mode((PANEL_width, PANEL_highly)) #设置屏幕的宽和高
pygame.display.set_caption("模拟黑客帝国中的代码雨-阿黎逸阳") #设置标题
background=pygame.image.load(r"F:\微信公众号\Python\32.六一儿童节黑客帝国\代码雨背景.png") #设置背景图片
font = pygame.font.SysFont('verdana.ttf', 19) #从系统内加载字体
bg_suface = pygame.Surface((PANEL_width, PANEL_highly), flags=pygame.SRCALPHA)
pygame.Surface.convert(bg_suface) #修改图像(Surface 对象)的像素格式
bg_suface.fill(pygame.Color(0, 0, 0, 28)) #设置填充的颜色
winSur.fill((0, 0, 0))
#纯数字 texts = [font.render(str(i), True, (0, 255, 0)) for i in range(10)]
#纯字母 letter = ['q', 'w', 'e', 'r', 't', 'y', 'u', 'i', 'o', 'p', 'a', 's', 'd', 'f', 'g', 'h', 'j', 'k', 'l', 'z', 'x', 'c','v', 'b', 'n', 'm']
#各种字符混合
letter = string.printable #设置字符内容
texts = [font.render(str(letter[i]), True, (0, 255, 0)) for i in range(len(letter))]
column = int(PANEL_width / FONT_PX) # 根据窗口的宽度计算字母的列数
drops = [0 for i in range(column)]
while True:
# 从队列中获取事件,防止窗口秒退和无响应
for event in pygame.event.get():
winSur.blit(background,(220,0)) #对齐的坐标
if event.type == pygame.QUIT:
exit()
elif event.type == pygame.KEYDOWN:
if event.key == pygame.K_q:
exit()
pygame.time.delay(19) #暂停毫秒数
winSur.blit(bg_suface, (0, 0)) #更新图像
for i in range(len(drops)):
text = random.choice(texts)
winSur.blit(text, (i * FONT_PX, drops[i] * FONT_PX)) #重新定义每个坐标点的图像
drops[i] += 1
if drops[i] * 10 > PANEL_highly or random.random() > 0.94: #超出范围后重置坐标位置
drops[i] = 0
pygame.display.flip()
\ No newline at end of file
...@@ -8,10 +8,37 @@ ...@@ -8,10 +8,37 @@
# list_hero.insert(i,power) # list_hero.insert(i,power)
# break # break
# print(list_hero) # print(list_hero)
# 请注释掉上面的代码,并在下一行创建一个名为dict_hero的字典 # 请注释掉上面的代码,并在下一行创建一个名为dict_hero的字典
dict_hero={'猴三':10,'猴一':21,'猴五':22,'猴队长':29,'猴七':30} # dict_hero={'猴三':10,'猴一':21,'猴五':22,'猴队长':29,'猴七':30}
dict_hero['猴五']=30 # dict_hero['猴五']=30
dict_hero['孙悟空']=600 # dict_hero['孙悟空']=600
if "孙悟空" in dict_hero: # if "孙悟空" in dict_hero:
print(dict_hero['孙悟空']) # print(dict_hero['孙悟空'])
print(dict_hero) # print(dict_hero)
#自动售货机
# hp={'可乐':3,'雷碧':5,'农夫三拳':6,'六个核弹':8,'矿泉水':1000,'绿茶':30}
# k=input("快点儿!要啥?")
# if k in hp:
# print(str(hp[k])+"元,赶快给钱!")
# else:
# print("没有!滚!")
#
cj={"张三":90,"李四":99,"王五":78,"赵四":45}
k=input("请输入你的名字:")
v=input("请输入你的成绩:")
if k in cj:
if int(v)>cj[k]:
cj[k]=int(v)
print("恭喜你,你的成绩更新为"+v+"分")
else:
print("更新失败")
else:
cj[k]=int(v)
print("恭喜你"+k+"你的成绩上传成功")ff
\ No newline at end of file
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