Commit 2a488058 by BellCodeEditor

auto save

parent ad6ba584
File added
bg.png

200 KB

bush.png

14.5 KB

cacti.png

5.58 KB

hero1.png

12.4 KB

hero2.png

10.9 KB

hero3.png

11.3 KB

hero4.png

11.5 KB

hero5.png

11.9 KB

import pygame
from pygame import locals
pygame.init() # 初始化
# 创建一个窗口
screen = pygame.display.set_mode((1000, 600))
pygame.display.set_caption("悟空酷跑")
FPS = pygame.time.Clock() # pygame时钟,控制游戏速度(帧数)
# 载入图片
background = pygame.image.load('bg.png') # 背景
road = pygame.image.load('road.png') # 路
stone = pygame.image.load('stone.png') # 石头
cacti = pygame.image.load('cacti.png') # 仙人掌
apple = pygame.image.load('bush.png') # 灌木丛
hero = [pygame.image.load('hero1.png'),pygame.image.load('hero2.png'),pygame.image.load('hero3.png'),pygame.image.load('hero4.png'),pygame.image.load('hero5.png')]
wukong = hero[0]
index = 0
zhuangtai = "run"
y = 400
t = 30
while True:
for event in pygame.event.get():
if event.type == locals.QUIT:
# 接收到退出事件后退出程序
exit()
if event.type == locals.KEYDOWN:
if event.key == locals.K_SPACE:
zhuangtai = "up"
# print(zhuangtai)
if zhuangtai == "run":
wukong = hero[index % 5]
index += 1
if zhuangtai == "up":
# if :
if t > 0 and y > 150:
y -= t
t -= 2
else:
zhuangtai = "down"
if zhuangtai == "down":
# if :
if t < 30 and y < 400:
y += t
t += 2
else:
zhuangtai = "run"
t = 30
# 将背景图画上去
screen.blit(background, (0, 0))
screen.blit(road, (0, 500))
screen.blit(wukong, (150, y))
# 刷新画面
pygame.display.update()
FPS.tick(60)
\ No newline at end of file
import pygame
from pygame import locals
import os
pygame.init() # 初始化
# 创建窗口
screen = pygame.display.set_mode((640, 480))
pygame.display.set_caption("音乐播放器")
# 载入图片、资源
bg_img = pygame.image.load('background.png') # 背景图
play_img = pygame.image.load('play.png') # 播放按钮
stop_img = pygame.image.load('stop.png') # 暂停按钮
last_img = pygame.image.load('last.png') # 上一曲按钮
next_img = pygame.image.load('next.png') # 下一曲按钮
logo_img = pygame.image.load('logo.png') # 下一曲按钮
myfont = pygame.font.Font('neuropol.ttf',15)
music_list = []
path = "C:\\Users\\Administrator\\Desktop\\新建文件夹 (2)"
filelist = os.listdir(path)
num = -1
for i in filelist:
if i[-4:] == ".wav" or i[-4:] == ".ogg":
music_list.append(i)
volume = 0.2
pygame.mixer.music.set_volume(volume) # 初始播放音量
click = 0
play_button = stop_img
angle = 1
while True:
play_time = pygame.mixer.music.get_pos()
play_time = int(play_time/1000)
p_m = play_time // 60
p_s = play_time % 60
info = str(p_m)+":"+str(p_s)
text = myfont.render(info,True,(0,0,0))
new_img = pygame.transform.rotate(logo_img,angle)
new_rect = new_img.get_rect(center = (320,190))
if click % 2 == 0:
angle += 1
l_x = new_rect[0]
l_y = new_rect[1]
# print(new_rect,"坐标",l_x,l_y)
for event in pygame.event.get():
if event.type == locals.QUIT:
exit()
# 按键,控制声音大小
if event.type == locals.KEYDOWN:
if event.key == locals.K_w:
volume += 0.1
if volume > 1:
volume = 1
pygame.mixer.music.set_volume(volume)
if event.key == locals.K_s:
volume -= 0.1
if volume < 0:
volume = 0
pygame.mixer.music.set_volume(volume)
if event.type == locals.MOUSEBUTTONDOWN:
if event.button == 1: # 左击
x, y = event.pos
if x > 270 and x < 370 and y > 350 and y < 450: # 播放按钮
click += 1
if click % 2 == 0:
play_button = stop_img
pygame.mixer.music.unpause()
else:
play_button = play_img
pygame.mixer.music.pause()
if x > 420 and x < 520 and y > 350 and y < 400: # 下一曲
num += 1
if num > len(music_list) - 1:
num = 0
pygame.mixer.music.load(path + "\\" + music_list[num])
pygame.mixer.music.play()
play_button = stop_img
if click % 2 == 0:
click += 2
else:
click += 1
if x > 120 and x < 220 and y > 350 and y < 400: # 上一曲
num -= 1
if num < 0:
num = len(music_list) - 1
pygame.mixer.music.load(path + "\\" + music_list[num])
pygame.mixer.music.play()
play_button = stop_img
if click % 2 == 0:
click += 2
else:
click += 1
if pygame.mixer.music.get_busy() == False:
num += 1
if num > len(music_list)-1:
num = 0
pygame.mixer.music.load(path + "\\" + music_list[num])
pygame.mixer.music.play()
# 绘制画面
screen.blit(bg_img, (0, 0)) # 填充背景
screen.blit(play_button, (270, 330)) # 暂停按钮
screen.blit(new_img, (l_x, l_y)) # 中间logo图
screen.blit(last_img, (120, 350)) # 上一曲
screen.blit(next_img, (420, 350)) # 下一曲
screen.blit(text,(40,440))
# 刷新画面
pygame.display.update()
\ No newline at end of file
road.png

34.7 KB

{"第1名": 0, "第2名": 0, "第3名": 0}
\ No newline at end of file
stone.png

11.3 KB

b_temp = 0
b_temp = 0
l_temp = []
mo = []
da = []
result = ""
a = input("输入年月日:")
a = list(a)
jq1 = [2.4,2.19,3.5,3.20,4.4,5.5,5.20,6.5,6.21,7.6,8.7,8.22,9.7,9.22,10.8,11.7,11.22,12.7,12.21,1.5]
jq2 = ['LC','YS','JZ','CF','QM','LX','XM','MZ','XZ','XS','LQ','CS','BL','QF','HL','LD','XX','DX','DZ','XH']
months1 = [1,2,3,4,5,6,7,8,9]
months2 = [10,11,12]
days1 = [4,5,6,7,8]
days2 = [19,20,21,22]
while result == "":
if a[5] == "0":
mo = a[6]
else:
mo = a[5:7]
if a[8] == "0":
da = a[9]
else:
da = a[8:10]
if len(mo) == 1:
for i in months1:
if mo[0] == str(i):
mo[0] = i
else:
for i in months2:
if mo[0] == str(i):
mo[0] = i
if mo[1] == str(i):
mo[1] = i
if len(da) == 1:
for i in days1:
if da[0] == str(i):
da[0] = i
else:
for i in days2:
if da[0] == str(i):
da[0] = i
if da[1] == str(i):
da[1] = i
mo = "".join(mo)
da = "".join(da)
mo.da = mo + "." + da
mo.da = int(mo.da)
# for i in jq1:
print(mo.da)
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