[Python] 纯文本查看 复制代码
import pygame
from pygame.locals import *
import sys
from datetime import datetime
from logic import Lo_gic
from dis_play import Dis_play
from Ascii_key import asc_key,bgcolors
pygame.init()
t = pygame.time.Clock()
screen = pygame.display.set_mode((800,600))
pygame.display.set_caption("typing games")
text1 = 'Click-input:'
count = 0
A = ord('A')
Z = ord('Z')
a = ord('a')
z = ord('z')
key_letter = 0
input_lst = []
input_lst2 = []
flag = False
right_count = 0
count_down = False
game_start = False
eng_text = ''
clock_time = 0
while True:
t.tick(20)
wang = Lo_gic()
dis_sc = Dis_play()
current = wang.Count_down(count_down, clock_time, game_start)
screen.fill(bgcolors())
if not flag:
screen.fill((0,0,0))
# eng_text = wang.open_english()[count]
# print(ord(eng_text[2]))
screen.blit(dis_sc.font_text(40, ''.join(eng_text), (255, 255, 255)), (10, 100))
pygame.draw.rect(screen,(200,200,0),dis_sc.draw_rect(200,300,400,50),5)
screen.blit(dis_sc.font_text(50,text1,(255,0,0)), (210,310))
screen.blit(dis_sc.font_text(40, ''.join(input_lst), (0, 255, 255)), (10, 100))
screen.blit(dis_sc.font_text(50, ''.join(input_lst2), (255, 0, 255)), (210, 310))
screen.blit(dis_sc.font_text(40,'words_number:'+str(right_count),(255,255,0)), (550,20))
screen.blit(dis_sc.font_text(20, 'Welcome to the typing game', (0, 255, 255)), (0, 580))
screen.blit(dis_sc.font_text(50, 'countdown: ' + str(current), (255, 0, 0)), (20, 20))
input_lst2,input_lst,eng_text,right_count,flag,text1,aa= \
asc_key(screen,input_lst2,input_lst,text1)
# print(click_ing)
if aa:
clock_time = datetime.now()
count_down = True
game_start = True
if current == True:
screen.blit(dis_sc.font_text(80, 'GAMEOVER', (255, 255, 0)), (210, 250))
pygame.display.update()
pygame.time.delay(2000)
break
else:
screen.blit(dis_sc.font_text(50, 'countdown: ' + str(current), (255, 0, 0)), (20, 20))
for event in pygame.event.get():
if event.type == QUIT:
pygame.quit()
sys.exit()
pygame.display.update()