. , , ,

,,,

"" — ,

.

:

:

1)    , . . , .

2)    , ( .

3)    .

P.S. ( ), ( ), , , , .

1)    (Dim, Const)

2)    (Rnd()).

3)    .(Pset(x,y))

4)    (Rnd()).

5)    : , .

6)    .

7)    : , (), .

8)    : , 3), . .

9)    : , , (), .

10)

P.S. . , , .

, , , , , .

:

_

'------- -------

Option Explicit

Dim () As

Dim LastPos As

Dim Apple As

Dim Bomba As

Dim i, j, As Integer

Dim XDir, YDir As Integer

Dim FirstXPos, FirstYPos As Integer

Dim 1 As Byte

Dim 2 As Single

Dim As String

'------- --------

Const TIC = 1 '

Const BackCollor = &H8000000F '

Const WormCollor = &H80& '

Const AppleCollor = &HFF00& '

Const BombaCollor = &H80000012 '

Const = 10 '

Const = 5 '

Const = 3 '

-------------------------------------------------------------------------------------------------

Public Sub Form_Load()

.BackColor = BackCollor

.DrawWidth =

=

ReDim Preserve (1 To )

'------ ------

FirstXPos = 5 + Int(Rnd() * 41)

FirstYPos = 5 + Int(Rnd() * 41)

For i = 1 To 5

(i).XPos = FirstXPos

(i).YPos = FirstYPos + i

Next i

'------ ------

XDir = 0

YDir = -1 '

'------ ----

AppleGen

BombaGen

Taimer.Interval = TIC

End Sub

'--- ---

Private Sub ()

.ForeColor = WormCollor

.Caption =

For i = 1 To

.PSet ((i).XPos * 100, (i).YPos * 100)

Next i

End Sub

-------------------------------------------------------------------------------------------------

Private Sub Taimer_Timer()

End Sub

-------------------------------------------------------------------------------------------------

Private Sub ()

= Chr(10) & Chr(13) '

.AutoRedraw = True

.DrawWidth =

LastPos = ()

For i = To 2 Step -1

(i) = (i - 1)

Next i

(1).XPos = (1).XPos + XDir

(1).YPos = (1).YPos + YDir

'------ ------

On Error GoTo

1 = (1).XPos - 1

1 = (1).YPos - 1

1 = (1).XPos + 206

1 = (1).YPos + 206

'------ ------

:

For i = 2 To

If (1).XPos = (i).XPos And (1).YPos = (i).YPos

Then Taimer.Interval = 0

..Caption = & _

" " & & _

" " & & & _

" " &

.Show

_.Enabled = False

End If

Next i

'----- -----

On Error GoTo 1

2 = 1 / (Abs(((1).XPos - Apple.XPos)) + Abs(((1).YPos - Apple.YPos)))

'----- ------

On Error GoTo 2

2 = 1 / (Abs(((1).XPos - Bomba.XPos)) + Abs(((1).YPos - Bomba.YPos)))

Exit Sub

'---------------- ---------------

:

Taimer.Interval = 0

..Caption = & _

" " & & _

" " & & & _

" " &

.Show

_.Enabled = False

Exit Sub

1:

= +

ReDim Preserve (1 To )

'------- -------

For i = To + 1 Step -1

(i) = (i - )

Next i

'

For i = To 1 Step -1

(i).XPos = (i + 1).XPos + XDir

(i).YPos = (i + 1).YPos + YDir

Next i

AppleGen

Exit Sub

2:

Taimer.Interval = 0

..Caption = & _

" " & & _

" " & & & _

" " &

.Show

_.Enabled = False

Exit Sub

End Sub

-------------------------------------------------------------------------------------------------

Private Sub ()

'------ -------

.ForeColor = BackCollor

.PSet (LastPos.XPos * 100, LastPos.YPos * 100)

.ForeColor = WormCollor

.PSet ((1).XPos * 100, (1).YPos * 100)

.PSet (().XPos * 100, ().YPos * 100)

'------ -------

.ForeColor = AppleCollor

.PSet (Apple.XPos * 100, Apple.YPos * 100)

'------ --------

.ForeColor = BombaCollor

.PSet (Bomba.XPos * 100, Bomba.YPos * 100)

End Sub

-------------------------------------------------------------------------------------------------

Private Sub TaimerApple_Timer()

TaimerApple.Interval = (5 + Int(Rnd() * 11)) * 1000

.ForeColor = BackCollor

.PSet (Apple.XPos * 100, Apple.YPos * 100)

AppleGen

End Sub

-------------------------------------------------------------------------------------------------

Private Sub TaimerBomba_Timer()

TaimerBomba.Interval = (5 + Int(Rnd() * 11)) * 1000

.ForeColor = BackCollor

.PSet (Bomba.XPos * 100, Bomba.YPos * 100)

BombaGen

End Sub

-------------------------------------------------------------------------------------------------

Private Sub AppleGen()

1:

Apple.XPos = 1 + Int(Rnd() * 49)

Apple.YPos = 1 + Int(Rnd() * 49)

i = 1

Do While i <=

If Apple.XPos = (i).XPos And Apple.YPos = (i).YPos Then

GoTo 1

Exit Do

End If

i = i + 1

Loop

End Sub

-------------------------------------------------------------------------------------------------

Private Sub BombaGen()

2:

Bomba.XPos = 1 + Int(Rnd() * 49)

Bomba.YPos = 1 + Int(Rnd() * 49)

i = 1

Do While i <=

If Bomba.XPos = (i).XPos And Bomba.YPos = (i).YPos Or Bomba.XPos = Apple.XPos And Bomba.YPos = Apple.YPos Then

GoTo 2

Exit Do

End If

i = i + 1

Loop

End Sub

-------------------------------------------------------------------------------------------------


'----- ------

Private Sub _KeyDown(KeyCode As Integer, Shift As Integer)

Select Case KeyCode

Case 38 '

XDir = 0

YDir = -1

Case 40 '

XDir = 0

YDir = 1

Case 37 '

XDir = -1

YDir = 0

Case 39 '

XDir = 1

YDir = 0

Case 27 'ESC

End

Case 113 'F2-

_.Enabled = True

_.Form_Load

.Hide

End Select

End Sub

-------------------------------------------------------------------------------------------------

Private Sub Up_Click()

XDir = 0

YDir = -1

End Sub

Private Sub Down_Click()

XDir = 0

YDir = 1

End Sub

Private Sub Left_Click()

XDir = -1

YDir = 0

End Sub

Private Sub Right_Click()

XDir = 1

YDir = 0

End Sub

Private Sub Command1_Click()

End

End Sub

Private Sub Command2_Click()

_.Enabled = True

_.Form_Load

.Hide

End Sub

Dim As String

-------------------------------------------------------------------------------------------------

Private Sub Avtor_Click()

= Chr(10) & Chr(13)

AboutAvtor.Label4.Caption = " ," & & _

" "

.Enabled = False

AboutAvtor.Show

End Sub

-------------------------------------------------------------------------------------------------

Private Sub Exit_Click()

_Click

End Sub

Private Sub NewGame_Click()

_Click

End Sub

Private Sub _Click()

Unload _

Unload Me

End Sub

Private Sub _Click()

_.Enabled = True

_.Form_Load

.Hide

End Sub

AboutAvtor

Private Sub Image1_Click()

.Enabled = True

Unload Me

End Sub

Module1

Option Explicit

Public Type

XPos As Integer

YPos As Integer

End Type

. : : 1) , . .

 

 

 

! , , , .
. , :