| 网站首页 | 业界新闻 | 小组 | 威客 | 人才 | 下载频道 | 博客 | 代码贴 | 在线编程 | 编程论坛
欢迎加入我们,一同切磋技术
用户名:   
 
密 码:  
共有 722 人关注过本帖
标题:新人求教!!打字游戏vb程序设计,帮忙把没填的空填了就ok了。急!!
只看楼主 加入收藏
花开了了
Rank: 1
等 级:新手上路
帖 子:1
专家分:0
注 册:2013-6-20
收藏
 问题点数:0 回复次数:0 
新人求教!!打字游戏vb程序设计,帮忙把没填的空填了就ok了。急!!
程序代码:
[local]3[/local]Option Explicit
Dim score As Integer
Dim speed As Integer
Dim typetime As String
'初始化字母1
Sub init1()
    '产生随机大写字母、数字及其他符号
   '【?】
    '起初位置
    Lblletter1.Left = Int(Rnd * (Frame1.Width - Lblletter1.Width))
    Lblletter1.Top = Frame1.Top - Lblletter1.Height
End Sub
'初始化字母2
Sub init2()
    '产生随机小写字母
    Lblletter2.Caption = Chr(Int(Rnd * 26) + 97)
    '起初位置
    Lblletter2.Left = Int(Rnd * (Frame1.Width - Lblletter2.Width))
    Lblletter2.Top = Frame1.Top - Lblletter2.Height
End Sub
'开始
Private Sub Command1_Click()
    '输入时间
    typetime = InputBox("请输入打字时间(单位为秒):", "设置时间")
    If IsNumeric(typetime) Then
        LblTime.Caption = typetime
    Else
        Exit Sub
    End If
    '调用子过程
    init1
    '【?】
    '默认的下落速度
    VScroll1.Value = 100
    '开始下落
    'Timer1.Enabled = 【?】
    'Timer2.Enabled = 【?】
    Command1.Enabled = False
    LblScore.Caption = 0
    '设置时间为2分钟
End Sub
Private Sub Frame1_DragDrop(Source As Control, X As Single, Y As Single)
End Sub
'打字
Private Sub VScroll1_KeyPress(KeyAscii As Integer)
    '若打中字母1
    If Chr(KeyAscii) = Lblletter1.Caption Then
        '重新初始化
        '【?】
        '分数累加
        score = score + 1
        '显示分数
        LblScore.Caption = score
    End If
    '若打中字母2
   ' If 【?】 Then
        init2
        score = score + 1
        LblScore.Caption = score
    End If
End Sub
'初始化设置
Private Sub Form_Load()
    Randomize
    Timer1.Enabled = False
    Timer2.Enabled = False
    Lblletter1.AutoSize = True
    Lblletter2.AutoSize = True
    VScroll1.Max = 300
    VScroll1.Min = 20
End Sub
'改变速度
Private Sub VScroll1_Change()
    'speed = 【?】
End Sub
'字母下落
Private Sub Timer1_Timer()
    '字母1下落
    Lblletter1.Top = Lblletter1.Top + speed
    If Lblletter1.Top > Frame1.Height Then
        init1
    End If
    '字母2下落
    Lblletter2.Top = Lblletter2.Top + speed
    If Lblletter2.Top > Frame1.Height Then
        init2
    End If
End Sub
'控制打字时间
Private Sub Timer2_Timer()
    '减时
    LblTime.Caption = Val(LblTime.Caption) - 1
    '若时间到
    If Val(LblTime.Caption) <= 0 Then
        '停止字母下落
        '【】
        Lblletter1.Caption = ""
        Lblletter2.Caption = ""
        '分析分数
        Select Case score / (typetime / 60)
            Case Is <= 20
                 MsgBox vbCrLf + "Don't give up,try again!"
            Case Is < 60
                 MsgBox vbCrLf + "That's right. Come on!"
            Case Is < 100
                MsgBox vbCrLf + "Continue and you will be top gun!"
            Case Is > 150
                 MsgBox vbCrLf + "Congraduation! You have been a top gun!"
        End Select
        Command1.Enabled = True
        Timer1.Enabled = False
        Timer2.Enabled = False
    End If
End Sub








打字游戏.rar (7.65 KB)
搜索更多相关主题的帖子: vb程序设计 打字游戏 
2013-06-20 20:11
快速回复:新人求教!!打字游戏vb程序设计,帮忙把没填的空填了就ok了。急!!
数据加载中...
 
   



关于我们 | 广告合作 | 编程中国 | 清除Cookies | TOP | 手机版

编程中国 版权所有,并保留所有权利。
Powered by Discuz, Processed in 0.031409 second(s), 8 queries.
Copyright©2004-2024, BCCN.NET, All Rights Reserved