vb打字游戏
利用定时器等控件,制作一个打字小游戏:要求字母(大约10个左右)自动下落,用户按对应字母键(不区分大小写)可以使之消失,每消掉30个字母升一级(设置三级即可),落下底边的...
利用定时器等控件,制作一个打字小游戏:要求字母(大约10个左右)自动下落,用户按对应字母键(不区分大小写)可以使之消失,每消掉30个字母升一级(设置三级即可),落下底边的字母超过10个时“Game Over”。
展开
5个回答
展开全部
加10个label1控件组,一个timer,
操作:
运行后,回车即可进行游戏,
代码:
Private Declare Function GetAsyncKeyState Lib "user32" (ByVal vKey As Long) As Integer
Dim m As Integer
Private Sub Form_KeyPress(KeyAscii As Integer)
If KeyAscii = 13 Then
Timer1.Interval = 100
Else
For j = 0 To 9
If Label1(j).Caption = UCase(Chr(KeyAscii)) Then
m = m + 1
If m = 30 Then Me.Caption = "第一级"
If m = 60 Then Me.Caption = "第2级"
If m = 90 Then Me.Caption = "第3级"
Label1(j).Top = 0
Exit For
End If
Next
End If
End Sub
Private Sub Form_Load()
For i = 0 To 9
Label1(i).Top = 0
Next
Me.Caption = "第0级"
End Sub
Private Sub Timer1_Timer()
Static n As Integer
If n = 10 Then
MsgBox "游戏结束"
Timer1.Enabled = False
End If
For i = 0 To 9
If Label1(i).Top > Form1.Height Then
Label1(i).Top = 0
Randomize
Label1(i).Caption = Chr(Int(Rnd * 26 + 65))
n = n + 1
ElseIf Label1(i).Top = 0 Then
Randomize
Label1(i).Caption = Chr(Int(Rnd * 26 + 65))
Label1(i).Top = Label1(i).Top + 100
Else
Label1(i).Top = Label1(i).Top + 100
End If
Next
End Sub
操作:
运行后,回车即可进行游戏,
代码:
Private Declare Function GetAsyncKeyState Lib "user32" (ByVal vKey As Long) As Integer
Dim m As Integer
Private Sub Form_KeyPress(KeyAscii As Integer)
If KeyAscii = 13 Then
Timer1.Interval = 100
Else
For j = 0 To 9
If Label1(j).Caption = UCase(Chr(KeyAscii)) Then
m = m + 1
If m = 30 Then Me.Caption = "第一级"
If m = 60 Then Me.Caption = "第2级"
If m = 90 Then Me.Caption = "第3级"
Label1(j).Top = 0
Exit For
End If
Next
End If
End Sub
Private Sub Form_Load()
For i = 0 To 9
Label1(i).Top = 0
Next
Me.Caption = "第0级"
End Sub
Private Sub Timer1_Timer()
Static n As Integer
If n = 10 Then
MsgBox "游戏结束"
Timer1.Enabled = False
End If
For i = 0 To 9
If Label1(i).Top > Form1.Height Then
Label1(i).Top = 0
Randomize
Label1(i).Caption = Chr(Int(Rnd * 26 + 65))
n = n + 1
ElseIf Label1(i).Top = 0 Then
Randomize
Label1(i).Caption = Chr(Int(Rnd * 26 + 65))
Label1(i).Top = Label1(i).Top + 100
Else
Label1(i).Top = Label1(i).Top + 100
End If
Next
End Sub
展开全部
加10个label1控件组,一个timer,
操作:
运行后,回车即可进行游戏,
操作:
运行后,回车即可进行游戏,
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
展开全部
学习ING
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
展开全部
程序界面,设计,外围代码已经好了,请加QQ644676751,或者 发邮件 : 644676751@qq.com
程序最多 2天写完,肯定比3L的好就行了
程序最多 2天写完,肯定比3L的好就行了
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
展开全部
可以自己做,找找网上例程, 可以HI我.
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询