You are the chairperson of the computer club, and you are tasked withdeveloping a program for your schoolmates to practice English typing. Theprogram should have the following features:
“Typing a given passage.
Calculating accuracy and typing speed.
Viewing a list of previous results.
You have the option to implement additional features as well. To prepare forthis project, your teacher will guide you through the following tasks:
a. Design and create a flowchart for the main program.
b. Complete the main program.
c. Develop the sub-programs
你是计算机俱乐部的主席,你的任务是为你的同学开发一个练习英语打字的程序。该程序应具有以下特点:
输入一段给定的文字。
计算精度和打字速度。
查看先前结果的列表。
您还可以选择实现其他功能。为了准备这个项目,你的老师将指导你完成以下任务:
a.设计并创建主程序流程图。
b.完成主程序。
c.开发子程序
使用python的Pygame库实现,如下列图。
1-其中英文句子内容来源于python爬虫每日爬取的英文句子。
2-用户进入打字游戏页面时会有游戏背景音乐,输入错误时会有错误音效。
3-成就页面有成就规则来约定画出的星星。






pygame开发打字小游戏演示视频
- 联系请加V:zew1040994588
- 源码获取、定制咨询、非开源
-
- while running:
- screen.fill(BG_COLOR)
- for event in pygame.event.get():
- print("event.type值为%s"%(event.type))
- if event.type == pygame.QUIT:
- running = False
- # 恩-23-9-28-停止程序
- exit()
- elif event.type == pygame.KEYDOWN:
- if game_state == State.MENU:
- if event.key == pygame.K_p:
- game_state = State.GAME
- # 从可迭代对象里面挑一个,这里业务逻辑为从句子列表中任意挑一个
- sentence = random.choice(sentences)
- print("sentence内容为%s"%(sentence))
- start_time = time.time()
- user_input = ""
- elif event.key == pygame.K_s:
- game_state = State.SCORES
- # 成就页面监测按键A
- elif event.key == pygame.K_a:
- game_state = State.ACIEVEMENT
- elif event.key == pygame.K_q:
- running = False
- elif game_state == State.GAME:
- print("pygame.K_BACKSPACE值为%s"%(pygame.K_BACKSPACE))
- print("event.key值为%s"%(event.key))
- if event.key == pygame.K_RETURN:
- wpm = len(sentence) / 5 / (time.time() - start_time) * 60
- accuracy = check_input(
- user_input, sentence) / len(sentence) * 100
- score = wpm * accuracy / 100
- insert_score(wpm, accuracy, score)
- # Update the latest score
- latest_score = (wpm, accuracy, score)
- game_state = State.SCORES
- 联系请加V:zew1040994588
- 源码获取、定制咨询、非开源
-
- """
- 23-9-26爬取的内容为:
- '5th International Daoism Forum opens in Jiangsu',
- "China's tourism market speeds up recovery",
- 'US factor emerges in India-Canada row',
- 'China gets to grips with cricket',
- "China's tourism market speeds up recovery",
- 'US factor emerges in India-Canada row',
- 'Thailand rolls out carpet to woo travelers',
- 'Trump takes opposite view of McCarthy on shutdown']
- """
-
- """
- 23-9-27爬取的内容为:
- ['Economic uptick anticipated',
- "Tech hegemony name of NSA's game",
- 'Anesthesia drug put on control list to halt abuse',
- 'Legend wows Hangzhou Asiad at 48', "Tech hegemony name of NSA's game",
- 'Anesthesia drug put on control list to halt abuse',
- "Chinese official slams Japan's nuke wastewater dumping",
- 'Macron unveils new green plan for France']
- """
-
- # 提取内容并输出
- for b_tag in b_tags:
- content = b_tag.text
- print(content)
- print(len(content))
- if len(content) > 45:
- # 句子太长 界面无法显示
- continue
- # print(content)
- list_senetcens.append(content)
- return list_senetcens
-
- print("爬取的英文网页标题句子为%s"%(sentences))
欢迎大家点赞、收藏、关注、评论、批评啦 、查看👇🏻👇🏻获取联系方式👇🏻👇🏻