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
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
| Public Class Form1
Public g As Graphics = Me.CreateGraphics
'Графика
Public b As Drawing.Color = Color.Black
'Public Form1 As Bitmap
Public t As Integer = 0
'счетчик еды
Dim cvet As Color = Color.Black
Public xx As Integer
' Public sh As Font = New System.Drawing.Font("Times", 8, FontStyle.Italic)
'Кисть
Dim pen1 As Pen = New Pen(Color.Green, 10)
Dim pen2 As Pen = New Pen(Color.White, 10)
Dim pen3 As Pen = New Pen(Color.Red, 10)
'Координаты еды
Public e1, e2, i As Integer
'Новая кнопка
Public butt As New Button
Private Sub Form1_KeyDown(ByVal sender As Object, ByVal e As System.Windows.Forms.KeyEventArgs) Handles MyBase.KeyDown
'ЗАБИНДЕННЫЕ КНОПКИ ДЛЯ УПРАВЛЕНИЯ ПИТОНОМ
Select Case e.KeyCode
'Пауза
Case Keys.P : Timer2.Stop() : Timer1.Stop() : Timer3.Stop() : Timer4.Stop() : Timer5.Stop() : Timer6.Stop()
Case Keys.Escape : Timer2.Stop() : Timer1.Stop() : Timer3.Stop() : Timer4.Stop() : Timer5.Stop() : Timer6.Stop() : Menusha.ShowDialog()
'Управление змеей
Case Keys.F1 : Timer2.Stop() : Timer1.Stop() : Timer3.Stop() : Timer4.Stop() : Timer5.Stop() : Timer6.Stop() : Help.ShowHelp(Me, "Справка.chm")
Case Keys.Left : Timer4.Enabled = True And Timer1.Enabled = False : Timer2.Enabled = False : Timer5.Enabled = False : Timer6.Start()
Case Keys.Right : Timer1.Enabled = True And Timer4.Enabled = False : Timer2.Enabled = False : Timer5.Enabled = False : Timer6.Start()
Case Keys.Up : Timer5.Enabled = True And Timer2.Enabled = False : Timer1.Enabled = False : Timer4.Enabled = False : Timer6.Start()
Case Keys.Down : Timer2.Enabled = True And Timer5.Enabled = False : Timer4.Enabled = False : Timer1.Enabled = False : Timer6.Start()
End Select
'прикольчик
Select Case e.KeyCode
Case Keys.Space : Timer3.Start()
End Select
End Sub
' !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
' @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
Private Sub Timer1_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Timer1.Tick
'ДВИЖЕНИЕ ПИТОНА ПО X В ПРАВО
'Тело змейки
g.DrawLine(pen1, x1, y1, x1 + 5, y1)
x1 = x1 + xp
Call noveda()
'ОГРАНИЧЕНИЯ ПИТОНА
If (x1 >= Me.Width - 8) Then
'начать с начало
Timer1.Stop()
butt.Dispose()
Timer6.Enabled = False
xx = 0
Dialog1.ShowDialog()
End If
End Sub
Private Sub Timer2_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Timer2.Tick
'ДВИЖЕНИЕ ПИТОНА ПО Y ВНИЗ
'Тело змейки
g.DrawLine(pen1, x1, y1, x1, y1 + 5)
y1 = y1 + yvn
Call noveda()
'ОГРАНИЧЕНИЯ ПИТОНА
If (y1 >= Me.Height - 34) Then
'начать с начало
Timer2.Stop()
butt.Dispose()
Timer6.Enabled = False
xx = 0
Dialog1.ShowDialog()
End If
End Sub
Private Sub Timer4_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Timer4.Tick
'ДВИЖЕНИЕ ПИТОНА ПО Х В ЛЕВО
'Тело змейки
g.DrawLine(pen1, x1, y1, x1 + 5, y1)
x1 = x1 - xl
Call noveda()
'ОГРАНИЧЕНИЯ ПИТОНА
If (x1 < 0) Then
'начать с начало
Timer4.Stop()
butt.Dispose()
Timer6.Enabled = False
xx = 0
Dialog1.ShowDialog()
End If
End Sub
Private Sub Timer5_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Timer5.Tick
'ДВИЖЕНИЕ ПИТОНА ПО Y В ВЕРХ
'Тело Змейки
g.DrawLine(pen1, x1, y1, x1, y1 + 5)
y1 = y1 - yver
Call noveda()
'ОГРАНИЧЕНИЯ ПИТОНА
If (y1 <= -1) Then
'начать с начало
Timer5.Stop()
butt.Dispose()
Timer6.Enabled = False
xx = 0
Dialog1.ShowDialog()
End If
End Sub
Public Sub noveda()
'условие для еды
If ((y1 >= e2) And (y1 <= e2 + 22.5)) And ((x1 >= e1) And (x1 <= e1 + 22.5)) Then
'удаление кнопки, когда питон съел
butt.Dispose()
Timer3.Enabled = True
'Счетчик ЕДЫ
s = s + 1
If (s < 1) Then
Label1.Text = CStr(s) & " зайцев"
Else
Label1.Text = CStr(s) & " заец"
End If
If (s >= 2) Then
Label1.Text = CStr(s) & " зайца"
End If
If (s > 4) Then
Label1.Text = CStr(s) & " зайцев"
End If
If (s > 20) Then
Label1.Text = CStr(s) & " заец"
End If
If (s > 21) Then
Label1.Text = CStr(s) & " зайца"
End If
'переход на следующий уровень
If s = 10 Then
xy = 50
k = 1
Timer1.Stop()
Timer2.Stop()
Timer4.Stop()
Timer5.Stop()
pozd.ShowDialog()
Timer1.Interval = xy
Timer2.Interval = xy
Timer4.Interval = xy
Timer5.Interval = xy
End If
If s = 20 Then
xy = 40
k = 2
Timer1.Stop()
Timer2.Stop()
Timer4.Stop()
Timer5.Stop()
pozd.ShowDialog()
Timer1.Interval = xy
Timer2.Interval = xy
Timer4.Interval = xy
Timer5.Interval = xy
End If
If s = 30 Then
xy = 30
k = 3
Timer1.Stop()
Timer2.Stop()
Timer4.Stop()
Timer5.Stop()
pozd.ShowDialog()
Timer1.Interval = xy
Timer2.Interval = xy
Timer4.Interval = xy
Timer5.Interval = xy
End If
If s = 40 Then
xy = 20
k = 4
Timer1.Stop()
Timer2.Stop()
Timer4.Stop()
Timer5.Stop()
pozd.ShowDialog()
Timer1.Interval = xy
Timer2.Interval = xy
Timer4.Interval = xy
Timer5.Interval = xy
End If
If s = 50 Then
xy = 10
k = 5
Timer1.Stop()
Timer2.Stop()
Timer4.Stop()
Timer5.Stop()
pozd.ShowDialog()
Timer1.Interval = xy
Timer2.Interval = xy
Timer4.Interval = xy
Timer5.Interval = xy
End If
If s = 60 Then
xy = 50
p = "Вы выграли!!!"
Timer1.Stop()
Timer2.Stop()
Timer4.Stop()
Timer5.Stop()
Dialog2.ShowDialog()
Timer1.Interval = xy
Timer2.Interval = xy
Timer4.Interval = xy
Timer5.Interval = xy
End If
End If
End Sub
Public Sub naezd()
'If cvet = drawLine(pen1, x1, y1, x1 + 1, y1) Then
Dialog1.ShowDialog()
' End If
End Sub
Private Sub Timer3_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Timer3.Tick
'ЕДА
Randomize()
e1 = (((Me.Width / 2) + 15) + ((Me.Width / 2) - 35)) * Rnd()
e2 = (((Me.Height / 2)) + ((Me.Height / 2) - 50)) * Rnd()
butt = New Button()
Me.Controls.Add(butt)
butt.ClientSize = New System.Drawing.Size(15, 15)
butt.Location = New Point(e1, e2)
butt.BackColor = Color.Red
butt.Enabled = False
'проверка чтоб еда не попадала на таймер времени и счет еды
If (e1 <= 90) And (e2 <= 40) Then
butt.Dispose()
Else
If Timer3.Enabled = True Then
Timer3.Enabled = False
End If
End If
End Sub
Private Sub Form1_Resize(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Resize
g = Me.CreateGraphics()
End Sub
Private Sub Timer6_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Timer6.Tick
'Счетчик времени
Label2.Text = ""
t1 = t1 + 1
Label2.Text = "Время: " & CStr(xx) & "м " & CStr(t1) & "с"
If (t1 = 60) Then
xx = xx + 1
t1 = 0
End If
End Sub
End Class |