伊莉討論區

標題: 賽跑程式 [打印本頁]

作者: lee13079    時間: 2009-4-23 04:37 AM     標題: 賽跑程式

Option Explicit
Dim A, B, C As Integer
Dim winCount As Integer  ' 計算櫻木連贏次數

Private Sub Command1_Click()

Picture1.Left = 120
Picture2.Left = 120
Picture3.Left = 120
Timer1.Enabled = True

End Sub


Private Sub Command2_Click()
End
End Sub

Private Sub Form_Load()
Randomize

With Label1
.Caption = "贏 " & 0 & " 次"
.FontSize = 12
.ForeColor = QBColor(2)
End With
With Label2
.Caption = "贏 " & 0 & " 次"
.FontSize = 12
.ForeColor = QBColor(2)
End With
With Label3
.Caption = "贏 " & 0 & " 次"
.FontSize = 12
.ForeColor = QBColor(2)
End With


With Label4
.Caption = ""
.FontSize = 16
.ForeColor = QBColor(12)
End With

With Label5
.Caption = "總比賽場次 : " & 0
.FontSize = 14
.ForeColor = QBColor(3)
End With

Timer1.Enabled = False

End Sub

Private Sub Timer1_Timer()

If winCount >= 3 Then  ' 當櫻木連贏三次時
  Picture1.Left = Picture1.Left + Int(Rnd * 500) + 100 '加速
  Else
  Picture1.Left = Picture1.Left + Int(Rnd * 500)
End If
Picture2.Left = Picture2.Left + Int(Rnd * 500)
Picture3.Left = Picture3.Left + Int(Rnd * 500)

If Picture1.Left > 6000 Then
Call Awin
End If

If Picture2.Left > 6000 Then
Call Bwin
End If

If Picture3.Left > 6000 Then
Call Cwin
End If
End Sub


Sub Awin()
Timer1.Enabled = False
Label4.Caption = "櫻木花道 贏了 !!"
A = A + 1
Label1.Caption = "贏 " & A & " 次"
Label5.Caption = "總比賽場次 : " & (A + B + C)
Shape1(0).Width = Shape1(0).Width + 80
Shape1(0).FillColor = RGB(255, 0, 0)
Shape1(0).FillStyle = 0

winCount = winCount + 1 ' 計算櫻木連贏次數

End Sub

Sub Bwin()
Timer1.Enabled = False
Label4.Caption = "流川楓 贏了 !!"
B = B + 1
Label2.Caption = "贏 " & B & " 次"
Label5.Caption = "總比賽場次 : " & (A + B + C)
Shape1(1).Width = Shape1(1).Width + 80
Shape1(1).FillColor = RGB(0, 255, 0)
Shape1(1).FillStyle = 0

winCount = 0  ' 計算櫻木連贏次數
End Sub
Sub Cwin()
Timer1.Enabled = False
Label4.Caption = "赤木剛憲 贏了 !!"
C = C + 1
Label3.Caption = "贏 " & C & " 次"
Label5.Caption = "總比賽場次 : " & (A + B + C)
Shape1(2).Width = Shape1(2).Width + 80
Shape1(2).FillColor = RGB(0, 0, 255)
Shape1(2).FillStyle = 0

winCount = 0  ' 計算櫻木連贏次數
End Sub
作者: 8881888    時間: 2009-4-28 08:43 PM

提示: 作者被禁止或刪除 內容自動屏蔽




歡迎光臨 伊莉討論區 (http://wahas.com/) Powered by Discuz!