@ -0,0 +1,24 @@
|
||||
import cv2
|
||||
import os
|
||||
|
||||
# 创建输出文件夹
|
||||
output_folder = "frames"
|
||||
os.makedirs(output_folder, exist_ok=True)
|
||||
|
||||
# 打开视频文件
|
||||
video = cv2.VideoCapture("./Movie/vid_0.mov")
|
||||
frame_count = 0
|
||||
|
||||
while video.isOpened():
|
||||
ret, frame = video.read()
|
||||
if not ret:
|
||||
break
|
||||
|
||||
# 保存帧为 PNG 图片
|
||||
frame_path = os.path.join(output_folder, f"frame_{frame_count:04d}.png")
|
||||
cv2.imwrite(frame_path, frame)
|
||||
frame_count += 1
|
||||
|
||||
# 释放资源
|
||||
video.release()
|
||||
print(f"Saved {frame_count} frames to {output_folder}")
|
@ -0,0 +1,32 @@
|
||||
import sys
|
||||
import pygame
|
||||
|
||||
pygame.init()
|
||||
screen = pygame.display.set_mode((640, 480)) # 设置屏幕大小
|
||||
pygame.display.set_caption('keyboard ctrl') # 设置窗口标题
|
||||
screen.fill((0, 0, 0)) # 屏幕填充RGB颜色
|
||||
|
||||
while True:
|
||||
for event in pygame.event.get():
|
||||
if event.type == pygame.QUIT:
|
||||
sys.exit()
|
||||
|
||||
keys = pygame.key.get_pressed()
|
||||
for i in range(26):
|
||||
if keys[pygame.K_a + i]:
|
||||
print(chr(pygame.K_a + i))
|
||||
|
||||
# 检测上下左右键 #
|
||||
if keys[pygame.K_UP]:
|
||||
print("Up arrow")
|
||||
if keys[pygame.K_DOWN]:
|
||||
print("Down arrow")
|
||||
if keys[pygame.K_LEFT]:
|
||||
print("Left arrow")
|
||||
if keys[pygame.K_RIGHT]:
|
||||
print("Right arrow")
|
||||
|
||||
# ESC to quit #
|
||||
if keys[pygame.K_ESCAPE]:
|
||||
pygame.quit()
|
||||
sys.exit()
|
@ -0,0 +1,25 @@
|
||||
import sys
|
||||
import pygame
|
||||
|
||||
pygame.init()
|
||||
screen = pygame.display.set_mode((640, 480)) # 设置屏幕大小
|
||||
pygame.display.set_caption('mouse ctrl') # 设置窗口标题
|
||||
screen.fill((0, 0, 0)) # 屏幕填充RGB颜色
|
||||
|
||||
while True:
|
||||
for event in pygame.event.get():
|
||||
if event.type == pygame.QUIT:
|
||||
sys.exit()
|
||||
|
||||
# 处理鼠标事件 #
|
||||
if event.type == pygame.MOUSEBUTTONDOWN:
|
||||
print("Mouse Down:", event)
|
||||
if event.type == pygame.MOUSEBUTTONUP:
|
||||
print("Mouse Up:", event)
|
||||
if event.type == pygame.MOUSEMOTION:
|
||||
print("Mouse is moving now:", event)
|
||||
|
||||
# 处理鼠标事件 #
|
||||
if event.type == pygame.KEYDOWN:
|
||||
if event.key == pygame.K_RETURN:
|
||||
print("keyboard event:", event)
|
@ -0,0 +1 @@
|
||||
{"v":"5.12.1","fr":30.0003051757812,"ip":0,"op":160.001627604167,"w":713,"h":1080,"nm":"人物动画02","ddd":0,"assets":[{"id":"video_0","w":713,"h":1080,"u":"images/","p":"vid_0.mov","e":0}],"layers":[{"ddd":0,"ind":1,"ty":9,"nm":"vid_0.mov","cl":"mov","refId":"video_0","sr":1,"ks":{"o":{"a":0,"k":100,"ix":11},"r":{"a":0,"k":0,"ix":10},"p":{"a":0,"k":[356.5,540,0],"ix":2,"l":2},"a":{"a":0,"k":[356.5,540,0],"ix":1,"l":2},"s":{"a":0,"k":[100,100,100],"ix":6,"l":2}},"ao":0,"ip":0,"op":160.001627604167,"st":0,"bm":0}],"markers":[],"props":{}}
|
@ -0,0 +1,74 @@
|
||||
import pygame
|
||||
import os
|
||||
|
||||
# 初始化 Pygame
|
||||
pygame.init()
|
||||
window_width = 800
|
||||
window_height = 600
|
||||
window = pygame.display.set_mode((window_width, window_height))
|
||||
pygame.display.set_caption("小人动画")
|
||||
clock = pygame.time.Clock()
|
||||
|
||||
# 加载帧序列
|
||||
frames = []
|
||||
frame_folder = "frames"
|
||||
for frame_file in sorted(os.listdir(frame_folder)):
|
||||
if frame_file.endswith(".png"):
|
||||
frame = pygame.image.load(os.path.join(frame_folder, frame_file))
|
||||
# 等比例缩放帧图片
|
||||
frame_width, frame_height = frame.get_size()
|
||||
scale_factor = min(window_width / frame_width, window_height / frame_height)
|
||||
scaled_frame = pygame.transform.scale(frame, (int(frame_width * scale_factor), int(frame_height * scale_factor)))
|
||||
frames.append(scaled_frame)
|
||||
|
||||
# 设置字体(使用支持中文的字体文件)
|
||||
font_path = "c:/Windows/Fonts/simhei.ttf" # 替换为你的中文字体文件路径
|
||||
font = pygame.font.Font(font_path, 36) # 使用中文字体,字号 36
|
||||
|
||||
# 播放动画
|
||||
current_frame = 0
|
||||
running = True
|
||||
show_message = False # 是否显示提示框
|
||||
message = "别乱点!" # 提示框内容
|
||||
message_timer = 0 # 提示框显示时间
|
||||
|
||||
while running:
|
||||
# 处理事件
|
||||
for event in pygame.event.get():
|
||||
if event.type == pygame.QUIT:
|
||||
running = False
|
||||
elif event.type == pygame.MOUSEBUTTONDOWN: # 检测鼠标点击
|
||||
mouse_pos = pygame.mouse.get_pos() # 获取鼠标点击位置
|
||||
print(f"Mouse clicked at: {mouse_pos}") # 打印鼠标点击位置
|
||||
show_message = True # 显示提示框
|
||||
message_timer = pygame.time.get_ticks() # 记录当前时间
|
||||
|
||||
# 绘制当前帧
|
||||
window.fill((0, 0, 0)) # 清空屏幕
|
||||
# 将帧居中显示
|
||||
frame_width, frame_height = frames[current_frame].get_size()
|
||||
x = (window_width - frame_width) // 2
|
||||
y = (window_height - frame_height) // 2
|
||||
window.blit(frames[current_frame], (x, y))
|
||||
|
||||
# 显示提示框
|
||||
if show_message:
|
||||
# 绘制提示框背景
|
||||
message_surface = font.render(message, True, (255, 255, 255)) # 白色文字
|
||||
message_rect = message_surface.get_rect(center=(window_width // 2, window_height - 50)) # 提示框位置在窗口底部
|
||||
pygame.draw.rect(window, (0, 0, 0), message_rect.inflate(20, 10)) # 黑色背景
|
||||
window.blit(message_surface, message_rect)
|
||||
|
||||
# 5 秒后隐藏提示框
|
||||
if pygame.time.get_ticks() - message_timer > 5000: # 检查是否超过 5 秒
|
||||
show_message = False
|
||||
|
||||
# 更新帧索引
|
||||
current_frame = (current_frame + 1) % len(frames)
|
||||
|
||||
# 更新屏幕
|
||||
pygame.display.flip()
|
||||
clock.tick(24) # 控制帧率
|
||||
|
||||
# 退出 Pygame
|
||||
pygame.quit()
|
@ -0,0 +1,117 @@
|
||||
import pygame
|
||||
import sys
|
||||
import random
|
||||
|
||||
# 初始化 Pygame
|
||||
pygame.init()
|
||||
|
||||
# 设置窗口尺寸
|
||||
window_width = 800
|
||||
window_height = 600
|
||||
window = pygame.display.set_mode((window_width, window_height))
|
||||
pygame.display.set_caption("弹球小游戏")
|
||||
|
||||
# 设置颜色
|
||||
WHITE = (255, 255, 255)
|
||||
RED = (255, 0, 0)
|
||||
BLUE = (0, 0, 255)
|
||||
|
||||
# 设置小球初始位置和速度
|
||||
ball_radius = 10
|
||||
ball_x = random.randint(ball_radius, window_width - ball_radius)
|
||||
ball_y = ball_radius
|
||||
ball_speed_x = random.choice([-5, 5])
|
||||
ball_speed_y = 5
|
||||
|
||||
# 设置挡板初始位置和大小
|
||||
paddle_width = 100
|
||||
paddle_height = 20
|
||||
paddle_x = (window_width - paddle_width) // 2
|
||||
paddle_y = window_height - paddle_height - 10
|
||||
paddle_speed = 10
|
||||
|
||||
# 设置时钟
|
||||
clock = pygame.time.Clock()
|
||||
|
||||
# 游戏状态
|
||||
game_over = False
|
||||
|
||||
# 重置游戏
|
||||
def reset_game():
|
||||
global ball_x, ball_y, ball_speed_x, ball_speed_y, paddle_x, game_over
|
||||
ball_x = random.randint(ball_radius, window_width - ball_radius)
|
||||
ball_y = ball_radius
|
||||
ball_speed_x = random.choice([-5, 5])
|
||||
ball_speed_y = 5
|
||||
paddle_x = (window_width - paddle_width) // 2
|
||||
game_over = False
|
||||
|
||||
# 主循环
|
||||
running = True
|
||||
while running:
|
||||
# 处理事件
|
||||
for event in pygame.event.get():
|
||||
if event.type == pygame.QUIT: # 检测窗口关闭事件
|
||||
running = False
|
||||
elif event.type == pygame.KEYDOWN: # 检测键盘按下事件
|
||||
if event.key == pygame.K_RETURN and game_over: # 按下回车键重新开始
|
||||
reset_game()
|
||||
|
||||
# 检测键盘持续按下状态
|
||||
keys = pygame.key.get_pressed()
|
||||
if keys[pygame.K_LEFT]: # 按下左箭头键
|
||||
paddle_x -= paddle_speed
|
||||
if keys[pygame.K_RIGHT]: # 按下右箭头键
|
||||
paddle_x += paddle_speed
|
||||
|
||||
# 限制挡板在窗口内移动
|
||||
paddle_x = max(0, min(paddle_x, window_width - paddle_width))
|
||||
|
||||
# 更新小球位置
|
||||
if not game_over:
|
||||
ball_x += ball_speed_x
|
||||
ball_y += ball_speed_y
|
||||
|
||||
# 小球碰到左右边界时反弹
|
||||
if ball_x <= ball_radius or ball_x >= window_width - ball_radius:
|
||||
ball_speed_x = -ball_speed_x
|
||||
|
||||
# 小球碰到上边界时反弹
|
||||
if ball_y <= ball_radius:
|
||||
ball_speed_y = -ball_speed_y
|
||||
|
||||
# 小球碰到挡板时反弹
|
||||
if (paddle_x <= ball_x <= paddle_x + paddle_width and
|
||||
paddle_y <= ball_y + ball_radius <= paddle_y + paddle_height):
|
||||
ball_speed_y = -ball_speed_y
|
||||
|
||||
# 小球碰到下边界时游戏结束
|
||||
if ball_y >= window_height - ball_radius:
|
||||
game_over = True
|
||||
|
||||
# 清空屏幕
|
||||
window.fill(WHITE)
|
||||
|
||||
# 绘制小球
|
||||
pygame.draw.circle(window, RED, (ball_x, ball_y), ball_radius)
|
||||
|
||||
# 绘制挡板
|
||||
pygame.draw.rect(window, BLUE, (paddle_x, paddle_y, paddle_width, paddle_height))
|
||||
|
||||
# 显示游戏结束信息
|
||||
if game_over:
|
||||
font_path = "c:/Windows/Fonts/simhei.ttf"
|
||||
font = pygame.font.Font(font_path, 74)
|
||||
text = font.render("游戏结束", True, (0, 0, 0))
|
||||
text_rect = text.get_rect(center=(window_width // 2, window_height // 2))
|
||||
window.blit(text, text_rect)
|
||||
|
||||
# 更新屏幕
|
||||
pygame.display.flip()
|
||||
|
||||
# 控制帧率
|
||||
clock.tick(60)
|
||||
|
||||
# 退出 Pygame
|
||||
pygame.quit()
|
||||
sys.exit()
|
After Width: | Height: | Size: 308 KiB |
After Width: | Height: | Size: 308 KiB |
After Width: | Height: | Size: 308 KiB |
After Width: | Height: | Size: 308 KiB |
After Width: | Height: | Size: 307 KiB |
After Width: | Height: | Size: 307 KiB |
After Width: | Height: | Size: 307 KiB |
After Width: | Height: | Size: 307 KiB |
After Width: | Height: | Size: 307 KiB |
After Width: | Height: | Size: 307 KiB |
After Width: | Height: | Size: 308 KiB |
After Width: | Height: | Size: 308 KiB |
After Width: | Height: | Size: 308 KiB |
After Width: | Height: | Size: 308 KiB |
After Width: | Height: | Size: 308 KiB |
After Width: | Height: | Size: 308 KiB |
After Width: | Height: | Size: 308 KiB |
After Width: | Height: | Size: 308 KiB |
After Width: | Height: | Size: 308 KiB |
After Width: | Height: | Size: 308 KiB |
After Width: | Height: | Size: 307 KiB |
After Width: | Height: | Size: 306 KiB |
After Width: | Height: | Size: 305 KiB |
After Width: | Height: | Size: 304 KiB |
After Width: | Height: | Size: 303 KiB |
After Width: | Height: | Size: 303 KiB |
After Width: | Height: | Size: 303 KiB |
After Width: | Height: | Size: 302 KiB |
After Width: | Height: | Size: 303 KiB |
After Width: | Height: | Size: 303 KiB |
After Width: | Height: | Size: 303 KiB |
After Width: | Height: | Size: 303 KiB |
After Width: | Height: | Size: 302 KiB |
After Width: | Height: | Size: 302 KiB |
After Width: | Height: | Size: 302 KiB |
After Width: | Height: | Size: 302 KiB |
After Width: | Height: | Size: 302 KiB |
After Width: | Height: | Size: 302 KiB |
After Width: | Height: | Size: 302 KiB |
After Width: | Height: | Size: 302 KiB |
After Width: | Height: | Size: 302 KiB |
After Width: | Height: | Size: 302 KiB |
After Width: | Height: | Size: 302 KiB |
After Width: | Height: | Size: 302 KiB |
After Width: | Height: | Size: 302 KiB |
After Width: | Height: | Size: 303 KiB |
After Width: | Height: | Size: 304 KiB |
After Width: | Height: | Size: 304 KiB |
After Width: | Height: | Size: 306 KiB |
After Width: | Height: | Size: 306 KiB |
After Width: | Height: | Size: 306 KiB |
After Width: | Height: | Size: 307 KiB |
After Width: | Height: | Size: 307 KiB |
After Width: | Height: | Size: 307 KiB |
After Width: | Height: | Size: 307 KiB |
After Width: | Height: | Size: 307 KiB |
After Width: | Height: | Size: 307 KiB |
After Width: | Height: | Size: 307 KiB |
After Width: | Height: | Size: 307 KiB |
After Width: | Height: | Size: 307 KiB |
After Width: | Height: | Size: 307 KiB |
After Width: | Height: | Size: 307 KiB |
After Width: | Height: | Size: 307 KiB |
After Width: | Height: | Size: 307 KiB |
After Width: | Height: | Size: 307 KiB |
After Width: | Height: | Size: 308 KiB |
After Width: | Height: | Size: 307 KiB |
After Width: | Height: | Size: 308 KiB |
After Width: | Height: | Size: 308 KiB |
After Width: | Height: | Size: 308 KiB |
After Width: | Height: | Size: 307 KiB |
After Width: | Height: | Size: 308 KiB |
After Width: | Height: | Size: 308 KiB |
After Width: | Height: | Size: 308 KiB |
After Width: | Height: | Size: 308 KiB |
After Width: | Height: | Size: 308 KiB |
After Width: | Height: | Size: 308 KiB |
After Width: | Height: | Size: 308 KiB |
After Width: | Height: | Size: 308 KiB |
After Width: | Height: | Size: 308 KiB |
After Width: | Height: | Size: 308 KiB |
After Width: | Height: | Size: 308 KiB |
After Width: | Height: | Size: 308 KiB |
After Width: | Height: | Size: 308 KiB |
After Width: | Height: | Size: 307 KiB |
After Width: | Height: | Size: 307 KiB |
After Width: | Height: | Size: 307 KiB |
After Width: | Height: | Size: 307 KiB |
After Width: | Height: | Size: 307 KiB |
After Width: | Height: | Size: 307 KiB |
After Width: | Height: | Size: 308 KiB |
After Width: | Height: | Size: 308 KiB |