ik heb een spel gemaakt ..
met 3 forms
als ik hem in vb6 test werkt hij wel maar als ik van het hele project een .exe maak niet...... heb alles geprobobeerd..
Code form 1
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
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
Option Explicit
Dim u, d, l, r, showm As Boolean
Dim x, y As Integer
Dim mx, my As Integer
Dim ex, ey As Integer
Dim score As Long
Dim stage As Long
Dim level_score As Integer
Dim fuel As Integer
Dim es As Integer
Private Sub Form_Load()
Private Sub Form_Load()
speed 10
End Sub
'MediaPlayer1.playerApplication = App.Path & "\sfx\fire.wav"
'MediaPlayer2.FileName = App.Path & "\sfx\Explosion.wav"
'MediaPlayer3.FileName = App.Path & "\sfx\mainsound.mp3"
lblScore.Caption = "0"
x = 0
y = 0
ex = -100
ex = -100
es = 10
fuel = 1
stage = 1
End Sub
Private Sub Form_Paint()
shooter.SetFocus
End Sub
Private Sub shooter_KeyDown(KeyCode As Integer, Shift As Integer)
If KeyCode = 49 Then speed = speed - 1
If speed <= 0 Then speed = 0
If speed > 30 Then speed = 30
If KeyCode = 50 Then speed = speed + 1
If KeyCode = vbKeyLeft Then l = True
If KeyCode = vbKeyRight Then r = True
If KeyCode = vbKeyUp Then u = True
If KeyCode = vbKeyDown Then d = True
If KeyCode = vbKeySpace Then
If Not showm Then
fireit
End If
End If
If KeyCode = vbKeyEscape Then Unload Me: Form2.Show
End Sub
Private Sub shooter_KeyUp(KeyCode As Integer, Shift As Integer)
If KeyCode = vbKeyLeft Then l = False
If KeyCode = vbKeyRight Then r = False
If KeyCode = vbKeyUp Then u = False
If KeyCode = vbKeyDown Then d = False
End Sub
Private Sub Timer1_Timer()
Static ch As Boolean
ch = Not ch
If ch Then
shooter.Picture = Picture2.Picture
Else
shooter.Picture = Picture3.Picture
End If
End Sub
Private Sub Timer2_Timer()
If l Then
x = x - speed
If x < 0 Then x = 0
End If
If r Then
x = x + speed
If x >= Me.ScaleWidth - 100 Then x = Me.ScaleWidth - 100
End If
If u Then
y = y - speed
If y < 0 Then y = 0
End If
If d Then
y = y + speed
If y >= Me.ScaleHeight - 100 Then y = Me.ScaleHeight - 100
End If
Label5.Caption = "X = " & x
Label6.Caption = "Y = " & y
shooter.Left = x
shooter.Top = y
Label3.Caption = CStr(speed)
If showm Then
mx = mx + 20
If mx > Me.ScaleWidth Then
showm = False
fire.Visible = False
End If
fire.Left = mx
fire.Top = my
If level_score = 9 Then
MsgBox "Je hebt Je zelf weer een level hoger gekregen" & vbCrLf & "Verder met level " & stage + 1, vbInformation, "Level up !"
stage = stage + 1
level_score = 0
es = es + 5 ' Increase enemny speed
en.Picture = LoadPicture((App.Path & "\data\op2.gif"))
End If
If (my > ey And my < ey + 60) And (mx > ex) Then
score = score + 10
level_score = level_score + 1
showm = False
SetEn
End If
Else
fire.Visible = False
End If
ex = ex - es
en.Left = ex
If ex < -200 Then
SetEn
en.Top = ey
End If
lblScore = CStr(score)
lblStage = CStr(stage)
Label8.Caption = "EX = " & ex
Label7.Caption = "EY = " & ey
If (y > ey - 40 And y < ey + 30) And (x > ex And x < ex + 100) Then
fuel = fuel + 1
'If fuel > 1 Then MediaPlayer2.Play
Picture1.BackColor = RGB(Rnd * 255, Rnd * 255, Rnd * 255)
SetEn
Select Case fuel
Case 2
Image1.Picture = LoadPicture(App.Path & "\data\fuel50.gif")
Case 3
Image1.Picture = LoadPicture(App.Path & "\data\fuel20.gif")
Case 4
Image1.Picture = LoadPicture(App.Path & "\data\game-over.gif")
End Select
If fuel = 4 Then
MsgBox "Game Over", vbCritical, "Shooter"
Unload Me
Form2.Show
End If
End If
End Sub
Private Sub fireit()
'MediaPlayer1.Play
showm = True
mx = shooter.Left + 100
my = shooter.Top + 50
fire.Visible = True
End Sub
Public Sub SetEn()
ey = Int(Rnd * Me.ScaleHeight) - 100
ex = Me.ScaleWidth
en.Left = ex
en.Top = ey
End Sub
Private Sub Timer3_Timer()
es = es + 5
End Sub
Code Form 2 Volgens de debug zit het in form2 ongeveer bij line 20 tot 24
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
Option Explicit
Private Sub Command1_Click()
Unload Me
Form1.Show
End Sub
Private Sub Command2_Click()
Form3.Show
End Sub
Private Sub Command3_Click()
Unload Me
End
End Sub
Private Sub Form_Load()
speed = 10
End Sub
Code form 3
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
Option Explicit
Dim s As Integer
Private Sub Command1_Click()
s = Val(Text1.Text)
If s < 0 Or s > 30 Then
Call Er
Exit Sub
End If
speed = Text1.Text
Unload Me
End Sub
Private Sub Command2_Click()
Unload Me
End Sub
Private Sub Form_Load()
Text1.Text = CStr(Module1.speed)
Label3.Caption = "Minimum Snelheid is 0." & vbCrLf & "Maximum Snelheid is 30."
End Sub
Private Sub Er()
MsgBox "kies een nummer 0-30."
s = 10
End Sub