import pygame
import sys
# 初始化混音器
pygame.mixer.init(44100, 16, 2, 1024)
# 设置窗口
screen = pygame.display.set_mode((1024, 720))
# 读取键盘键位顺序
with open('typewriter.kb', 'r') as file:
keys = file.read().split('\n')
# 加载声音文件
sounds = []
for sound_file in ["a.OGG", "b.OGG", "c.OGG", "d.OGG"]:
sounds.append(pygame.mixer.Sound(sound_file))
key_sound = dict(zip(keys, sounds))
sound_queue = []
clock = pygame.time.Clock()
pygame.mixer.music.set_volume(0.5) # 设置音量为0.5
all_keys = [
'a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm',
'n', 'o', 'p', 'q', 'r', 's', 't