Another Games
July 4, 2008
‘add 1 timer and 2 command buttons
Dim wkday
Dim mnthday
Dim mnth
Private Sub comm2_MouseMove(Button As Integer, Shift As Integer, X As Single, Y As Single)
Randomize ( ![]()
comm1.Visible = True
comm2.Visible = False
comm1.ForeColor = QBColor(Rnd(8))
End Sub
Private Sub comm1_MouseMove(Button As Integer, Shift As Integer, X As Single, Y As Single)
Randomize ( ![]()
comm1.Visible = False
comm2.Visible = True
comm2.ForeColor = QBColor(Rnd(8))
End Sub
Private Sub Form_Load()
Me.Height = 4500
Me.Width = 8500
Me.Left = 1800
Me.Top = 2000
wkday = Weekday(Now)
mnth = Month(Now)
If wkday = 1 Then
wkday = “Sunday”
ElseIf wkday = 2 Then
wkday = “Monday”
ElseIf wkday = 3 Then
wkday = “Tuesday”
ElseIf wkday = 4 Then
wkday = “Wednesday”
ElseIf wkday = 5 Then
wkday = “Thursday”
ElseIf wkday = 6 Then
wkday = “Friday”
ElseIf wkday = 7 Then
wkday = “Saturday”
End If
If mnth = 1 Then
mnth = “January”
ElseIf mnth = 2 Then
mnth = “February”
ElseIf mnth = 3 Then
mnth = “March”
ElseIf mnth = 4 Then
mnth = “April”
ElseIf mnth = 5 Then
mnth = “May”
ElseIf mnth = 6 Then
mnth = “June”
ElseIf mnth = 7 Then
mnth = “July”
ElseIf mnth = 8 Then
mnth = “August”
ElseIf mnth = 9 Then
mnth = “September”
ElseIf mnth = 10 Then
mnth = “October”
ElseIf mnth = 11 Then
mnth = “November”
ElseIf mnth = 12 Then
mnth = “December”
End If
End Sub
Private Sub Timer1_Timer()
Me.Caption = Time & “, ” & wkday & “, ” & mnth & ” ” & Day(Now) & “, ” & Year(Now)
timelbl.Caption = Time & “, ” & wkday & “, ” & mnth & ” ” & Day(Now) & “, ” & Year(Now)
End Sub
Ping Pong
May 29, 2008
Public counter As Integer, direction As String
Private Sub cmdDown_Click()
cmdDown.Tag
End Sub
Private Sub Form_Load()
For T = Line1.LBound To Line1.UBound
Let Line1(T).X1 = Main.Width / 2
Let Line1(T).X2 = Main.Width / 2
Next T
counter = 0
End Sub
Private Sub Text1_KeyDown(KeyCode As Integer, Shift As Integer)
Const Inc = 1
If KeyCode = Asc(”A”) Or KeyCode = Asc(”a”) Then
Let Shape2.Top = Shape2.Top - Inc
If Shape2.Top < 0 Then Let Shape2.Top = 0
End If
If KeyCode = Asc(”Z”) Or KeyCode = Asc(”z”) Then
Let Shape2.Top = Shape2.Top + Inc
If Shape2.Top > 4920 Then Let Shape2.Top = 4920
End If
If KeyCode = Asc(”P”) Or KeyCode = Asc(”p”) Then
Let Shape1.Top = Shape1.Top - Inc
If Shape1.Top < 0 Then Let Shape1.Top = 0
End If
If KeyCode = Asc(”L”) Or KeyCode = Asc(”l”) Then
Let Shape1.Top = Shape1.Top + Inc
If Shape1.Top > 4920 Then Let Shape1.Top = 4920
End If
If KeyCode = Asc(”q”) Or KeyCode = Asc(”Q”) Then
End
End If
If KeyCode = Asc(”c”) Or KeyCode = Asc(”C”) Then
frmCredits.Show
Timer1.Enabled = False
End If
Let Text1.Text = “”
counter = 0
End Sub
Private Sub Text1_KeyUp(KeyCode As Integer, Shift As Integer)
counter = -1
End Sub
Private Sub Timer1_Timer()
Let speed = Val(Shape3.Tag)
Let Vspeed = Val(Text1.Tag)
Const Vmax = 220
If speed = 0 Then Let speed = 250
If Vspeed = 0 Then Let Vspeed = 110
Let Shape3.Left = Shape3.Left + speed
Let Shape3.Top = Shape3.Top + Vspeed
If ((Shape3.Left + Shape3.Width) > Shape1.Left) And (Shape3.Top > Shape1.Top) And (Shape1.Top + Shape1.Height > Shape3.Top) Then
If (Shape3.Left > (Shape1.Left + Shape1.Width)) Then
Let Label2.Caption = Val(Label2.Caption) + 1
Let Shape3.Left = Main.Width / 2
Shape1.Top = Main.Height / 2
Shape2.Top = Main.Height / 2
counter = -1
MsgBox “You lose, but it was close”
End If
Let speed = -speed
If Vspeed > 0 Then Let Vspeed = -Int(Rnd * Vmax)
If Vspeed < 0 Then Let Vspeed = Int(Rnd * Vmax)
End If
If ((Shape3.Left) < (Shape2.Left + Shape2.Width)) And Shape3.Top > Shape2.Top And Shape2.Top + Shape2.Height > Shape3.Top Then
If (Shape3.Left < (Shape2.Left)) Then
Let Label1.Caption = Val(Label1.Caption) + 1
Let Shape3.Left = Main.Width / 2
Shape2.Top = Main.Height / 2
Shape1.Top = Main.Height / 2
counter = -1
MsgBox “You lose, but it was close”
End If
Let speed = -speed
If Vspeed > 0 Then Let Vspeed = -Int(Rnd * Vmax)
If Vspeed < 0 Then Let Vspeed = Int(Rnd * Vmax)
End If
If Shape3.Left > Main.Width Then
Let Label2.Caption = Val(Label2.Caption) + 1
Let Shape3.Left = Main.Width / 2
MsgBox “Another Point For The guy on the Left”
Let Shape3.Left = Main.Width / 2
Shape2.Top = Main.Height / 2
Shape1.Top = Main.Height / 2
End If
If Shape3.Left < 0 Then
Let Label1.Caption = Val(Label1.Caption) + 1
Let Shape3.Left = Main.Width / 2
MsgBox “Another Point For The guy on the Right”
Let Shape3.Left = Main.Width / 2
Shape2.Top = Main.Height / 2
Shape1.Top = Main.Height / 2
End If
If Shape3.Top < 0 Then
Let Vspeed = -Vspeed
Let Shape3.Top = 0
End If
If Shape3.Top > 5400 Then
Let Vspeed = -Vspeed
Let Shape3.Top = 5400
End If
Let Shape3.Tag = speed
Let Text1.Tag = Vspeed
Inc = 245
If (speed > 0) Then
direction = “Right”
ElseIf (speed < 0) Then
direction = “Left”
End If
If (counter <> -1) Then
If (direction = “Left”) Then
If Text1.Text = “A” Or Text1.Text = “a” Then
Let Shape2.Top = Shape2.Top - Inc
If Shape2.Top < 0 Then Let Shape2.Top = 0
End If
If Text1.Text = “Z” Or Text1.Text = “z” Then
Let Shape2.Top = Shape2.Top + Inc
If Shape2.Top > 4920 Then Let Shape2.Top = 4920
End If
ElseIf (direction = “Right”) Then
If Text1.Text = “P” Or Text1.Text = “p” Then
Let Shape1.Top = Shape1.Top - Inc
If Shape1.Top < 0 Then Let Shape1.Top = 0
End If
If Text1.Text = “L” Or Text1.Text = “l” Then
Let Shape1.Top = Shape1.Top + Inc
If Shape1.Top > 4920 Then Let Shape1.Top = 4920
End If
End If
End If
End Sub