Anonymous
Anonymous asked in 電腦與網際網路程式設計 · 2 decades ago

誰能幫我做VB的龜兔賽跑阿

http://uploadhut.com/view.php/162885.rar(到此下載)

案開始後電腦困難難度不同而速度不同

但是玩家則要快案→圖片才會跑

跑到最右邊停止並出現玩家或電腦勝利的警示框

誰能幫幫忙

2 Answers

Rating
  • Anonymous
    2 decades ago
    Favorite Answer

    Public Class Form1

    Inherits System.Windows.Forms.Form

    Dim Selec

    '請先拉三個Radiobutton 1 2 3

    '拉兩個Label 1 2 ,圖形自己加上

    '拉一個Timer 1

    '拉一個Button 1

    #Region " Windows Form 設計工具產生的程式碼 "

    .........中間省略..........

    #End Region

    Private Sub Form1_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles MyBase.Load

    Timer1.Enabled = False

    Timer1.Interval = 500

    End Sub

    Private Sub Button1_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles Button1.Click

    '起始位置歸零

    Label1.Left = 0

    Label2.Left = 0

    If RadioButton1.Checked = False And RadioButton2.Checked = False And RadioButton3.Checked = False Then

    MsgBox("請選擇難度")

    Else

    Timer1.Enabled = True

    End If

    End Sub

    '第二個自動跑,且每個TICK檢查是否到終點

    Private Sub Timer1_Tick(ByVal sender As Object, ByVal e As System.EventArgs) Handles Timer1.Tick

    Label2.Left = Label2.Left + 50 * Selec

    If Label1.Left >= Form1.ActiveForm.Width - Label1.Width Then

    Timer1.Enabled = False

    MsgBox("Label1 is winner")

    End If

    If Label2.Left >= Form1.ActiveForm.Width - Label2.Width Then

    Timer1.Enabled = False

    MsgBox("Label2 is winner")

    End If

    End Sub

    '每按ㄧ次滑鼠加ㄧ段距離

    Private Sub Form1_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles MyBase.Click

    Label1.Left = Label1.Left + 50

    End Sub

    Private Sub RadioButton1_CheckedChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles RadioButton1.CheckedChanged

    If RadioButton1.Checked = True Then

    Selec = 1

    End If

    End Sub

    Private Sub RadioButton2_CheckedChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles RadioButton2.CheckedChanged

    If RadioButton2.Checked = True Then

    Selec = 2

    End If

    End Sub

    Private Sub RadioButton3_CheckedChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles RadioButton3.CheckedChanged

    If RadioButton3.Checked = True Then

    Selec = 3

    End If

    End Sub

    End Class

    '有問題其它自己慢慢調

    Source(s): Me (By VB.Net 2003)
  • 2 decades ago

    Dim z As Integer: Dim x As Integer: Dim y As Integer

    Private Sub Form_Load()

    Image1.LoadPicture = ("電腦的圖檔")

    Image1.Left = 0: Image1.Top = 100

    Image2.LoadPicture = ("玩家的圖檔")

    Image1.Left = 0: Image1.Top = 200

    End Sub

    Private Sub Command1_Click()

    a = InputBox(請選擇難易度,困難選1.中等選2.容易選3,請選擇)

    Select Case a

    Case 1

    z = 100

    Case 2

    z = 300

    Case 3

    z = 500

    End Select

    End Sub

    Private Sub Form_Click()

    x = Image2.Left

    x = x + 100

    If Image1.Left > Width Then

    MsgBox "玩家勝"

    MsgBox "電腦輸"

    Exit Sub

    End If

    End Sub

    Private Sub Timer1_Timer()

    Timer1.Interval = z

    y = Image1.Left

    y= y+ 100

    If Image1.Left > Width Then

    MsgBox "電腦勝"

    MsgBox "玩家輸"

    Exit Sub

    End If

    End Sub

    Source(s): DIY
Still have questions? Get your answers by asking now.