VB课程设计任务书打字游戏.docx
《VB课程设计任务书打字游戏.docx》由会员分享,可在线阅读,更多相关《VB课程设计任务书打字游戏.docx(11页珍藏版)》请在冰点文库上搜索。
VB课程设计任务书打字游戏
课程设计
课程名称:
计算机程序设计(C+VB)
设计题目:
打字游戏___
专业:
工程机械三班__
******
学号:
********
西南交通大学峨眉校区
2012年06月18日
课程设计任务书
专业工程机械三班姓名何继章学号********
开题日期:
2012年06月10日完成日期:
2012年06月18日
题目打字游戏
一、设计的目的
____让人在体验趣味的同时也提高了自己的打字速度,尤其使用于初学打字的同学们!
可以让用户从零开始逐步变为打字高手,短时间内运指如飞!
48小时成为打字高手,寓教于乐。
二、设计的内容及要求
1.功能描述
本程序是利用vb编写的一个打字游戏,游戏可以选择难易程度,选择简单时上方掉落的是单个字符,选择困难时上方掉落的是单词,当正确按键时可以将其击掉,成绩相应增加一分,开始前可以选择游戏速度,点击加减按钮可以调节游戏速度。
本程序还有许多实用功能,可以将游戏暂停、继续、从来、结束等。
2.概要设计
3.详细设计
(1)界面设计
在窗体上添加6个命令按钮command1、command2、command3、command4、
Command5command6、8个标签Label1、Label2、Label3、Label4、Label5、Label6、Label7、Label8、2个定时器time1、time2、1个文本框text1和2个单选按钮option1、option2按表修改它们的属性,如图所示。
对象
属性
值
Command1
Caption
加
Command2
Caption
减
Command3
Caption
开始
Command4
Caption
结束
Command5
Caption
暂停/继续
Command6
Caption
重来
Label1
Caption
Label2
Caption
Label3
Caption
成绩
Label4
Caption
速度
Label5
Caption
18
Label6
Caption
Label7
Caption
Label8
Caption
time1
Interval
0
Time2
Interval
0
Option1
Caption
简单
Option2
Caption
困难
Text1
text
(2)编写程序代码如下:
PrivateSubCommand1_Click()
'曾加速度
Label5.Caption=Label5.Caption+1
EndSub
'减小速度
PrivateSubCommand2_Click()
Label5.Caption=Label5.Caption-1
EndSub
'开始游戏
PrivateSubCommand3_Click()
IfOption1.ValueThen
Timer1.Interval=1
Timer2.Interval=0
Label7.Caption=""
Label1.Top=8760
Label6.Top=8760
Label1.Visible=True
Label6.Visible=True
EndIf
IfOption2.ValueThen
Timer2.Interval=1
Timer1.Interval=0
Label1.Caption=""
Label6.Caption=""
Randomize
Cls
a=Array("one","two","three","free","feel","fly","lacking","the","power","that")
x=Int(Rnd*(UBound(a)+1))
Label7.Caption=a(x)
Command1.Enabled=False
Command2.Enabled=False
Label7.Top=0
Label7.Visible=True
EndIf
Text1.SetFocus
EndSub
PrivateSubForm_KeyPress(KeyAsciiAsInteger)
'判断简单时是否打中,并使成绩加一
IfOption1.ValueThen
Timer1.Interval=1
IfKeyAscii=Asc(Label1.Caption)Then
Label1.Top=0
Label1.Left=Rnd()*10800
Label1.Caption=Chr$(Rnd()*26+97)
Label2.Caption=Label2.Caption+1
EndIf
IfKeyAscii=Asc(Label6.Caption)Then
Label6.Top=0
Label6.Left=Rnd()*10800
Label6.Caption=Chr$(Rnd()*26+97)
Label2.Caption=Label2.Caption+1
EndIf
EndIf
'判断困难时是否打中,并使成绩加一
IfOption2.ValueThen
Timer2.Interval=1
EndIf
IfKeyAscii>=65AndKeyAscii<=86OrKeyAscii>=97AndKeyAscii<=122Then
Label8.Caption=Label8.Caption&Chr(KeyAscii)
ElseIfKeyAscii=32Then
Label8.Caption=""
Text1.Text=""
EndIf
IfLabel7.Caption=Label8.CaptionThen
Label7.Caption=""
Label8.Caption=""
Text1.Text=""
Label7.Top=0
Label7.Left=Rnd()*10800
Randomize
Cls
a=Array("one","two","three","free","feel","fly","lacking","the","power","that")
x=Int(Rnd*(UBound(a)+1))
Label7.Caption=a(x)
Label2.Caption=Label2.Caption+1
EndIf
EndSub
'结束
PrivateSubCommand4_Click()
End
EndSub
'暂停或继续游戏
PrivateSubCommand5_Click()
StaticfAsInteger
Iff=0Then
Timer1.Interval=0
Timer2.Interval=0
f=1
Command3.SetFocus
Else
Timer1.Interval=1
Timer2.Interval=1
f=0
Command3.SetFocus
EndIf
EndSub
'重新游戏
PrivateSubCommand6_Click()
Timer1.Interval=0
Label2.Caption=0
Label5.Caption=18
Timer1.Interval=0
Timer2.Interval=0
Label1.Visible=False
Label6.Visible=False
Label7.Visible=False
Label1.Caption=""
Label6.Caption=""
Label7.Caption=""
Command1.Enabled=True
Command2.Enabled=True
EndSub
PrivateSubTimer1_Timer()
Randomize
'简单时游戏速度
Label1.Top=Label1.Top+Label5.Caption
Label6.Top=Label6.Top+Label5.Caption+15
'判断是否到底,并随机生成字母,从顶开始
IfLabel1.Top>8760Then
Label1.Top=0
Label1.Left=Rnd()*10800
Label1.Caption=Chr$(Rnd()*26+96)
EndIf
IfLabel6.Top>8760Then
Label6.Top=0
Label6.Left=Rnd()*10800
Label6.Caption=Chr$(Rnd()*26+96)
EndIf
EndSub
PrivateSubTimer2_Timer()
Randomize
'困难时游戏速度
Label7.Top=Label7.Top+Label5.Caption+10
'判断是否到底,并随机生成单词,从顶开始
IfLabel7.Top>8760Then
Label7.Top=0
Label7.Left=Rnd()*10800
Randomize
Cls
a=Array("one","two","three","free","feel","fly","lacking","the","power","that")
x=Int(Rnd*(UBound(a)+1))
Label7.Caption=a(x)
Else
Label7.Top=Label7.Top+5
EndIf
EndSub
4.效果及存在问题
运行后得到如图界面
选择简单模式时,单击开始,上方掉落的是单个字符
选择困难模式时,单击开始,上方掉落的是单词
三、指导教师评语
四、成绩
指导教师(签章)
年月日........忽略此处.......