1.求助,一个基于labview的打地鼠游戏设计
基于Labview的打地鼠游戏程序VI,打开可直接使用。
程序图:
二、方案论证
1.地鼠部分
方案一:运用事件,实现点击的确认,并利用随机来判定哪个口有地鼠。
方案二:调用ActiveX控件,采用更简单的语句编写,例如Flash。
鉴于此次想要练习Labview的应用,选用了方案一。
2.LABVIEW程序设计
初步的设计并不理想,不能实现地鼠自动消失以及乱点鼠标的惩罚。
经过多次调整方案,最后采用了对于事件进行详尽分类,将地鼠的出现与消失编入事件,后来加入开始结束按键以后,问题变得更加复杂,于是在调用子VI的基础上,又增加了“等待开始”与“失败”两个事件,在此基础上重新调整了每一个参数在不同事件中的传递以及累计运算,最后实现了数据的统计。
在等待地鼠出现的事件中加入了难度的递增判断。对于同类数据隐藏,并把相同分类的编入簇处理,以简化框图。
3.界面美化
初步美化界面,个性化了按键,对于某些按键加入特效。最终加入音效。
2.求vb打地鼠游戏的设计
'窗口中就一个LABEL,名称:lblInfo'这个带有动画 Option Explicit Dim lZQ As Long Dim lCW As Long Dim dStart As Double '开始时间 Dim dStop As Double '停止时间 Dim iNum As Integer '字数 Dim lTime As Long ' Dim iTime As Integer Dim iCode As Integer Dim iScorce As Integer '分数 Dim bOK As Boolean Private Sub Form_DblClick() '开始 Me.Timer1.Enabled = True dStart = Time End Sub Private Sub Form_Resize() Me.lblInfo.Top = Me.Height - 1000 End Sub Private Sub Form_KeyDown(KeyCode As Integer, Shift As Integer) If dStart <> 0 Then If KeyCode = iCode Or KeyCode = iCode - 32 Then' If iCode <= 90 And Shift <> 2 Then '大写' Beep' lCW = lCW + 1' Else lZQ = lZQ + 1 iScorce = iScorce + 1' End If Else Beep lCW = lCW + 1 iScorce = iScorce - 1 End If End If bOK = True lTime = 0 iTime = 0 If iScorce < 0 Then iScorce = 0 Me.lblInfo.Caption = "总字数:" & iNum & ";正确数量:" & lZQ & ";错误数量:" & lCW & ";正确率:" & Round(lZQ / iNum * 100, 2) & "%;得分:" & iScorce '" ' , "统计" Call Timer1_Timer End Sub Private Sub Form_Load() Me.Timer1.Interval = 50 Me.Timer1.Enabled = False End Sub Private Sub Timer1_Timer() Static i As Integer Static j As Integer Static k As Integer Static l As Integer Me.AutoRedraw = True Me.KeyPreview = True If lTime * Me.Timer1.Interval / 1000 >= 500 Then '规定500秒任务 GoTo OVER End If If ((iTime * Me.Timer1.Interval) Mod 5000 = 0) Or bOK = True Then '每个字规定最多显示5秒钟 If iTime <> 0 Then lCW = lCW + 1 iScorce = iScorce - 1 If iScorce < 0 Then iScorce = 0 Me.lblInfo.Caption = "总字数:" & iNum & ";正确数量:" & lZQ & ";错误数量:" & lCW & ";正确率:" & Round(lZQ / iNum * 100, 2) & "%;得分:" & iScorce '" ' , "统计" End If iTime = 0 bOK = False Me.Cls Randomize i = Int(Rnd() * Me.ScaleWidth - 500) j = Int(Rnd() * Me.ScaleHeight - 500) k = Int(Rnd() * 90) + 10 '字号 l = Int(Rnd() * 26) '产生52个字母的其中一个 'l = Int(Rnd() * 53) '产生52个字母的其中一个 If l <= 25 Then '大写 l = 65 + l Else l = 97 + l - 26 End If iCode = l '记录 Me.CurrentX = i Me.CurrentY = j Me.FontSize = k Me.Print Chr(l) iNum = iNum + 1 l = 0 Else Me.Cls l = l + 1 If i - 100 * l < 100 Then l = 0 Me.CurrentX = Me.Width - 500 i = Me.Width - 500 Else Me.CurrentX = i - l * 100 End If Me.CurrentY = j Me.FontSize = k Me.Print Chr(iCode) End If If iNum >= 100 Then GoTo OVER iTime = iTime + 1 lTime = lTime + 1 Exit Sub OVER: Me.Timer1.Enabled = False dStop = Time If iScorce < 0 Then iScorce = 0 Me.lblInfo.Caption = "总耗时:" & Round((dStop - dStart) * 24 * 3600, 2) & "秒," & vbCrLf & "总字数:" & iNum & ";正确数量:" & lZQ & ";错误数量:" & lCW & ";正确率:" & Round(lZQ / iNum * 100, 2) & "%;得分:" & iScorce lTime = 0 iTime = 0 iNum = 0 End Sub。
3.求vb打地鼠游戏的设计
'窗口中就一个LABEL,名称:lblInfo'这个带有动画Option ExplicitDim lZQ As LongDim lCW As LongDim dStart As Double '开始时间Dim dStop As Double '停止时间Dim iNum As Integer '字数Dim lTime As Long 'Dim iTime As IntegerDim iCode As IntegerDim iScorce As Integer '分数Dim bOK As BooleanPrivate Sub Form_DblClick() '开始 Me.Timer1.Enabled = True dStart = TimeEnd SubPrivate Sub Form_Resize() Me.lblInfo.Top = Me.Height - 1000End SubPrivate Sub Form_KeyDown(KeyCode As Integer, Shift As Integer) If dStart <> 0 Then If KeyCode = iCode Or KeyCode = iCode - 32 Then' If iCode <= 90 And Shift <> 2 Then '大写' Beep' lCW = lCW + 1' Else lZQ = lZQ + 1 iScorce = iScorce + 1' End If Else Beep lCW = lCW + 1 iScorce = iScorce - 1 End If End If bOK = True lTime = 0 iTime = 0 If iScorce < 0 Then iScorce = 0 Me.lblInfo.Caption = "总字数:" & iNum & ";正确数量:" & lZQ & ";错误数量:" & lCW & ";正确率:" & Round(lZQ / iNum * 100, 2) & "%;得分:" & iScorce '" ' , "统计" Call Timer1_TimerEnd SubPrivate Sub Form_Load() Me.Timer1.Interval = 50 Me.Timer1.Enabled = FalseEnd SubPrivate Sub Timer1_Timer() Static i As Integer Static j As Integer Static k As Integer Static l As Integer Me.AutoRedraw = True Me.KeyPreview = True If lTime * Me.Timer1.Interval / 1000 >= 500 Then '规定500秒任务 GoTo OVER End If If ((iTime * Me.Timer1.Interval) Mod 5000 = 0) Or bOK = True Then '每个字规定最多显示5秒钟 If iTime <> 0 Then lCW = lCW + 1 iScorce = iScorce - 1 If iScorce < 0 Then iScorce = 0 Me.lblInfo.Caption = "总字数:" & iNum & ";正确数量:" & lZQ & ";错误数量:" & lCW & ";正确率:" & Round(lZQ / iNum * 100, 2) & "%;得分:" & iScorce '" ' , "统计" End If iTime = 0 bOK = False Me.Cls Randomize i = Int(Rnd() * Me.ScaleWidth - 500) j = Int(Rnd() * Me.ScaleHeight - 500) k = Int(Rnd() * 90) + 10 '字号 l = Int(Rnd() * 26) '产生52个字母的其中一个 'l = Int(Rnd() * 53) '产生52个字母的其中一个 If l <= 25 Then '大写 l = 65 + l Else l = 97 + l - 26 End If iCode = l '记录 Me.CurrentX = i Me.CurrentY = j Me.FontSize = k Me.Print Chr(l) iNum = iNum + 1 l = 0 Else Me.Cls l = l + 1 If i - 100 * l < 100 Then l = 0 Me.CurrentX = Me.Width - 500 i = Me.Width - 500 Else Me.CurrentX = i - l * 100 End If Me.CurrentY = j Me.FontSize = k Me.Print Chr(iCode) End If If iNum >= 100 Then GoTo OVER iTime = iTime + 1 lTime = lTime + 1 Exit SubOVER: Me.Timer1.Enabled = False dStop = Time If iScorce < 0 Then iScorce = 0 Me.lblInfo.Caption = "总耗时:" & Round((dStop - dStart) * 24 * 3600, 2) & "秒," & vbCrLf & "总字数:" & iNum & ";正确数量:" & lZQ & ";错误数量:" & lCW & ";正确率:" & Round(lZQ / iNum * 100, 2) & "%;得分:" & iScorce lTime = 0 iTime = 0 iNum = 0End Sub。
4.打地鼠的游戏建议
1.全神贯注,手眼并用,左右两手分别负责各自一边会更加有效。
2.偶尔会看到出来的不是地鼠而是更可爱的兔子,也不要心软,照样砸下去。
3.不仅要求速度快,而且要准,有时候因为心急,可能砸错了洞口,也是要扣分的哦!
转载请注明出处众文网 » 打地鼠游戏设计毕业论文