-
Notifications
You must be signed in to change notification settings - Fork 0
/
Football.frm
152 lines (146 loc) · 3.91 KB
/
Football.frm
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
VERSION 5.00
Begin VB.Form Form1
BackColor = &H00FFFFC0&
BorderStyle = 1 'Fixed Single
Caption = "Form1"
ClientHeight = 7545
ClientLeft = 5700
ClientTop = 2355
ClientWidth = 6330
KeyPreview = -1 'True
LinkTopic = "Form1"
MaxButton = 0 'False
MinButton = 0 'False
Picture = "Football.frx":0000
ScaleHeight = 7696.811
ScaleMode = 0 'User
ScaleWidth = 6938.055
Begin VB.Timer Timer1
Enabled = 0 'False
Interval = 50
Left = 240
Top = 5520
End
Begin VB.Shape Shape1
BorderStyle = 0 'Transparent
Height = 735
Left = 0
Top = 7080
Width = 6495
End
Begin VB.Label Label2
Alignment = 2 'Center
BackStyle = 0 'Transparent
BeginProperty Font
Name = "Britannic Bold"
Size = 36
Charset = 0
Weight = 400
Underline = 0 'False
Italic = 0 'False
Strikethrough = 0 'False
EndProperty
ForeColor = &H00FF8080&
Height = 735
Left = 2640
TabIndex = 1
Top = 1080
Width = 1335
End
Begin VB.Image Image1
Height = 690
Left = 2640
Picture = "Football.frx":8E14
Stretch = -1 'True
Top = 2760
Width = 690
End
Begin VB.Label Label1
Alignment = 2 'Center
BackStyle = 0 'Transparent
Caption = "GAME OVER"
BeginProperty Font
Name = "Britannic Bold"
Size = 36
Charset = 0
Weight = 400
Underline = 0 'False
Italic = 0 'False
Strikethrough = 0 'False
EndProperty
ForeColor = &H00400000&
Height = 735
Left = 1200
TabIndex = 0
Top = 120
Visible = 0 'False
Width = 4095
End
Begin VB.Menu new
Caption = "NEW GAME"
End
Begin VB.Menu exit
Caption = "EXIT"
End
End
Attribute VB_Name = "Form1"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False
Dim gravity, yspeed, xspeed, score As Integer
Private Sub exit_Click()
Unload Me
End Sub
Private Sub Form_Load()
gravity = 15
xspeed = 0
yspeed = 0
score = 0
Timer1.Enabled = True
End Sub
Private Sub Form_MouseDown(Button As Integer, Shift As Integer, X As Single, Y As Single)
If Button = vbLeftButton Then
score = score + 1
If X < Image1.Left And Y >= (Image1.Top + Image1.Height) Then
xspeed = 100
yspeed = -150
ElseIf X > (Image1.Left + Image1.Width) And Y >= (Image1.Top + Image1.Height) Then
xspeed = -100
yspeed = -150
ElseIf (X >= Image1.Left And X <= (Image1.Left + Image1.Width)) And (Y >= (Image1.Top + Image1.Height)) Then
xspeed = 0
yspeed = -150
End If
End If
End Sub
Private Sub new_Click()
Unload Me
Me.Show
End Sub
Private Sub Timer1_Timer()
Label2.Caption = score
yspeed = yspeed + gravity
Image1.Top = Image1.Top + yspeed
Image1.Left = Image1.Left + xspeed
If collide(Image1, Shape1) = True Then
Timer1.Enabled = False
Label1.Visible = True
End If
If Image1.Left <= 10 Then
score = score - 1
xspeed = 80
yspeed = 120
ElseIf Image1.Left >= 6100 Then
score = score - 1
xspeed = -80
yspeed = 120
End If
End Sub
Private Function collide(ByVal ball As Object, grnd As Object) As Boolean
If ball.Top + ball.Height >= grnd.Top Then
collide = True
Else
collide = False
End If
End Function