




已阅读5页,还剩3页未读, 继续免费阅读
版权说明:本文档由用户提供并上传,收益归属内容提供方,若内容存在侵权,请进行举报或认领
文档简介
1108320134 冒震宇 课程设计题目 打字游戏一 功能:本程序为无声版打字练习:有四个窗体,其中一个为开始窗体frmstart,游戏界面frmplay,还有一个为弹出键盘的界面frmkeyboard,还有一个为察看成绩界面frmscore其中frmstart为启动窗体还有一个模块用来存放全局变量和一个控制字母生成的全局过程 ziti。还有一个文本文件用来储存玩家的信息。二课程详细设计:1)程序开始显示“打字设置”窗口,在“你的姓名”文本框中输入姓名。若未输入姓名就单击“开始练习”或“查看成绩”按钮,则在屏幕上出现一个消息框。在”打字屏幕上随机产生并下落各种字符.若用户在字符落到屏幕底下之前,敲击了键盘上的相应的键,则该字符被“击中”,然后消失。程序根据速度和难度的设置自动计分,分数实时显示在窗口的顶部。计分标准如下:1、慢速+小写字母:打中一个1分2、慢速+大写字母:打中一个2分3、慢速+混合字符:打中一个3分 4、中速+小写字母:打中一个4分5、中速+大写字母:打中一个5分6、中速+混合字符:打中一个6分7、高速+小写字母:打中一个7分8、高速+大写字母:打中一个8分9、高速+混合字符:打中一个9分 所有字符包括大小写字母,数字和符号字符.2)当下落字符中有相同字符时,一次只能打掉一个.如果按了屏幕上没有的字符则扣1分,如果有字符落到屏幕底下则扣10分.3)为了增加游戏的趣味性,可增加背景音乐和打中时的打击声.在此不作要求。4)时间一到则显示用户本次的得分并提示是否继续进行.打字过程中可以按esc键则中止游戏,返回打字设置窗口.5)打字练习过程中,屏幕的顶部显示已用的时间和当前的分数,按f1功能键则弹出键盘布局窗口以供用户参考.6)单击”查看成绩”按钮,弹出“成绩”对话框,显示当前用户每次的练习时间和成绩.三、程序代码展示frmstart:option explicitdim strtime as string 得到输入时间文本框的时间private sub cmdexit_click() 退出按钮unload frmplay: unload frmstart: unload frmscoreend subprivate sub cmdscore_click() 察看成绩按钮dim int7 as integeropen score.txt for input as 3 do while not eof(3) input #3, str1, str2, str3 str4 = str1 + + str2 + + str3 if str1 = frmstart.txtname.text then 如果找到则添加到列表框中 frmscore.lstscore.additem str4 end if if frmstart.txtname.text = then 如果搜索内容为空则全部显示 frmscore.lstscore.additem str4 end if str1 = str2 = str3 = str4 = loop if frmscore.lstscore.listcount = 0 then 如果为空即姓名不存在则显示提示框 int7 = msgbox(没有您的成绩纪录, 48, 成绩查看) if int7 = 1 then unload frmscore end if else frmscore.show end ifclose 3end subprivate sub form_load() frmstart.lbltime.caption = nowtxttime.text = 1optspeed(0).value = true: optzimu(0).value = truetxtname.text = end sub private sub cmdstart_click() 开始按钮dim m as integerif frmstart.txtname.text = then m = msgbox(请您输入您的姓名, 32, 错误) exit subend iffrmstart.visible = falsefrmplay.showend subprivate sub txttime_change() 输入游戏时间,默认一分钟dim int3 as single 用来在strtime 和inttime 中间转换的一个变量strtime = txttime.textint3 = csng(strtime)inttime = int3 * 60end subfrmplay:option explicitdim intsecond as integerdim intminute as integerprivate x as integer 控制爆炸图画的出现和消失private intend as integer 控制游戏的结束private sub form_deactivate()if intend = inttime then intend = 0: timer2.enabled = false 如果是时间到了以后退出,则往文本文件里面写文件 open score.txt for append as 1 write #1, frmstart.txtname.text, cstr(t), frmstart.lbltime.caption close 1 end ifend subprivate sub form_keydown(keycode as integer, shift as integer)dim int4 as integerif keycode = 27 then 用户按了esc int4 = msgbox(真的要结束练习吗?, 36, 打字练习) if int4 = 6 then unload frmplay: frmstart.visible = true end ifend ifif keycode = 112 then 用户按了f1 frmkeyboard.show 1end ifend subprivate sub form_load()intsecond = 0: intminute = 0: intend = 0: t = 0timer2.enabled = true: image1.visible = falsefrmplay.windowstate = 2dim h as integer, z as integer 循环变量for z = 0 to 9 标签控件赋初值 lblshow(z).backcolor = frmplay.backcolor lblshow(z).forecolor = rgb(rnd * 255, rnd * 255, rnd * 255) lblshow(z).top = frmplay.top - lblshow(z).heightnext zfor h = 0 to 2 根据速度的设定来控制下落的速度 if frmstart.optspeed(h).value = true then timer1.interval = 50 * (3 - h) call ziti 随机生成字体 end ifnext hlabel1.backcolor = frame1.backcolor: label2.backcolor = frame1.backcolor: label3.backcolor = frame1.backcolorframe1.width = frmplay.width + 1000end subprivate sub timer1_timer() 搜索是否有字母到底randomizedim intx as integerfor intx = 0 to 9 if lblshow(intx).top = frmplay.height - lblshow(intx).height then t = t 10 有字母到底即扣去十分 if frmstart.optzimu(0).value = true then randomize frmplay.lblshow(intx).caption = chr(rnd * 25 + 97) end if if frmstart.optzimu(1).value = true then randomize frmplay.lblshow(intx).caption = chr(rnd * 47 + 65) if asc(frmplay.lblshow(intx).caption) 90 then frmplay.lblshow(intx).caption = chr(rnd * 47 + 65) end if end if if frmstart.optzimu(2).value = true then randomize frmplay.lblshow(intx).caption = chr(rnd * 57 + 65) end if lblshow(intx).top = frmplay.top - lblshow(intx).height lblshow(intx).forecolor = rgb(rnd * 255, rnd * 255, rnd * 255) end if lblshow(intx).top = lblshow(intx).top + rnd * 200next intx label3.caption = 欢迎 & frmstart.txtname.text & _您现在的得分是 & tend subprivate sub timer2_timer() 控制游戏的结束 dim int5 as integerif intend = inttime then 若大于游戏时间,则退出 int5 = msgbox(本次练习你的成绩是 & cstr(t) & 分 & chr(13) & chr(10) & _ 游戏结束,要继续吗?, 36, 打字练习) if int5 = 6 then call form_load elseif int5 = 7 then unload frmplay: frmstart.visible = true end ifend ifintend = intend + 1 下面的代码控制窗体顶部时间的显示intsecond = intsecond + 1if intsecond = 60 thenintsecond = intsecond - 60: intminute = intminute + 1end iffrmplay.label1.caption = cstr(intminute) & : & cstr(intsecond)end subprivate sub form_keypress(keyascii as integer) dim inty as integer 循环变量 for inty = 0 to 9 if keyascii = asc(lblshow(inty).caption) then 生成新的字符 if frmstart.optzimu(0).value = true then randomize frmplay.lblshow(inty).caption = chr(rnd * 25 + 97) end if if frmstart.optzimu(1).value = true then randomize frmplay.lblshow(inty).caption = chr(rnd * 25 + 65) end if if frmstart.optzimu(2).value = true then randomize frmplay.lblshow(inty).caption = chr(rnd * 57 + 65) end if image1.visible = true: image1.left = lblshow(inty).left: image1.top = lblshow(inty).top timer3.enabled = true lblshow(inty).top = frmplay.top - lblshow(inty).height 加分 dim intxunhuan as integer 循环变量 dim temp as integer 循环变量 for intxunhuan = 0 to 2 if frmstart.optspeed(intxunhuan).value = true then for temp = 0 to 2 if frmstart.optzimu(temp) = true then t = t + 1 + temp + 3 * intxunhuan end if next end if next exit sub end if next intyif inty = 10 then 若没有则减去一分 t = t - 1end if end subprivate sub timer3_timer() 控制爆炸图画的出现和消失dim x as integerx = x + 1if x = 1 then image1.visible = false: x = 0end ifend subfrmkeyboard:option explicitprivate sub form_load()image1.picture = loadpicture(resourcekeyboard.bmp)frmplay.keypreview = false: frmplay.timer1.enabled = false 使键盘出现时,游戏窗体暂停frmplay.timer2.enabled = falseend subprivate sub form_unload(cancel as integer)frmplay.keypreview = true: frmplay.timer1.enabled = truefrmplay.timer2.enabled = trueend submodulel1:option explicitpublic t as integer 记录分数public str1 as string, str2 as string, str3 as string, str4 as stringpublic inttime as singlepublic sub ziti() 控制出现字符的种类 dim a as integer, b as integer, c as integer if frmstart.optzimu(0).value = true then for a = 0 to 9 randomize frmplay.lblshow(a).caption = chr(rnd * 25 + 97) next a end if if frmstart.optzimu(1).value = true then for b = 0 to 9 randomize 使得随机 frmplay.lblshow(b).caption = chr(rnd * 47 + 65) if asc(frmplay.lblshow(b).caption) 90 then b = b - 1 end if next b end if if frmstart.optzimu(2).value = true then for c = 0 to 9 randomize frmplay.lblshow(c).caption = chr(rnd * 57 + 65) next c end ifend sub四.设计过程中出现的问题由于对程序中涉及的一些书本外的知识,尽管看了资料,但是还是不能应用自如,所以本程序的背景音乐和打击声没有实现.可用keypress事件检测键入的字符是否正确。判断esc和f1等控制键或功能键,应该使用keydown事件.关于这两个所涉及的键码,有一些不懂得的地方,经过翻阅书籍和询问同学,解决了这个问题.还有一些小的细节问题,经过自己不断地阅读程序,把这些小的问题解决了。在编
温馨提示
- 1. 本站所有资源如无特殊说明,都需要本地电脑安装OFFICE2007和PDF阅读器。图纸软件为CAD,CAXA,PROE,UG,SolidWorks等.压缩文件请下载最新的WinRAR软件解压。
- 2. 本站的文档不包含任何第三方提供的附件图纸等,如果需要附件,请联系上传者。文件的所有权益归上传用户所有。
- 3. 本站RAR压缩包中若带图纸,网页内容里面会有图纸预览,若没有图纸预览就没有图纸。
- 4. 未经权益所有人同意不得将文件中的内容挪作商业或盈利用途。
- 5. 人人文库网仅提供信息存储空间,仅对用户上传内容的表现方式做保护处理,对用户上传分享的文档内容本身不做任何修改或编辑,并不能对任何下载内容负责。
- 6. 下载文件中如有侵权或不适当内容,请与我们联系,我们立即纠正。
- 7. 本站不保证下载资源的准确性、安全性和完整性, 同时也不承担用户因使用这些下载资源对自己和他人造成任何形式的伤害或损失。
最新文档
- 第5课 歌声嘹亮-子程序设计和机器人发音说课稿-2025-2026学年初中信息技术粤教清华版九年级下册-粤教清华版
- 3.2 土地资源说课稿-2024-2025学年人教版地理八年级上册
- 《教头风雪山神庙》《装在套子里的人》联读 教学设计 2023-2024学年统编版高中语文必修下册
- 2025年中考数学试题分类汇编:统计(9大考点57题) (第1期)原卷版
- 6摆的研究教学设计-2025-2026学年小学科学浙教版2017五年级下册-浙教版
- 9 我的老师教学设计-2025-2026学年小学美术广西版二年级上册-广西版
- 5.1 传感器的原理教学设计-2025-2026学年高中物理沪教版2019选择性必修第二册-沪教版2019
- 2025年行政能力测试题库及答案
- 4.2.2等差数列的前n项和公式(一)教学设计-2023-2024学年高二上学期数学人教A版(2019)选择性必修第二册
- 在北京的金山上(教学设计)-2023-2024学年花城版音乐三年级下册
- NB-T+10488-2021水电工程砂石加工系统设计规范
- (高清版)JTGT 3671-2021 公路交通安全设施施工技术规范
- DZ∕T 0214-2020 矿产地质勘查规范 铜、铅、锌、银、镍、钼(正式版)
- 2024年广东南海控股集团有限公司招聘笔试冲刺题(带答案解析)
- 智能制造基础与应用(第2版)教案 第二章 智能制造数字化基础 2.数字化设计与仿真
- 开学第一课假期收心主题班会 课件
- 中山酒店行业状况分析
- 液压车间生产管理制度
- 植保无人机应急处置预案
- 湖北十堰生产实习报告
- 营销体系之业绩如何做增量10大方法
评论
0/150
提交评论