Yılan Oyunu(DeLphi de)

ALpMontana

КЯaL´da TaNıMaM КuяaL´da
Katılım
28 May 2006
Mesajlar
6,644
Reaction score
0
Puanları
0
Yaş
38
Konum
Eski Açık [ALiSamiYEN]
im tablo(1 To 30, 1 To 20) As Integer
Dim konum(1 To 5) As Byte

Private Sub ekran_KeyDown(KeyCode As Integer, Shift As Integer)
Select Case KeyCode
Case 37:
If konum(5) <> 2 Then konum(5) = 4
Case 38:
If konum(5) <> 3 Then konum(5) = 5
Case 39:
If konum(5) <> 4 Then konum(5) = 2
Case 40:
If konum(5) <> 5 Then konum(5) = 3
Case 19:
If Timer1.Enabled = True Then Timer1.Enabled = False Else Timer1.Enabled = True
Case 32:
Timer1.Enabled = True
End Select
End Sub

Private Sub Form_Load()
ekran.Scale (1, 1)-(31, 21)
For i = 1 To 30
For j = 1 To 20
tablo(i, j) = 0
Next j
Next i
For i = 1 To 30
ekran.PaintPicture duvar.Picture, i, 1: tablo(i, 1) = 1
ekran.PaintPicture duvar.Picture, i, 20: tablo(i, 20) = 1
Next
For i = 2 To 19
ekran.PaintPicture duvar.Picture, 1, i: tablo(1, i) = 1
ekran.PaintPicture duvar.Picture, 30, i: tablo(30, i) = 1
Next

For i = 11 To 19
ekran.PaintPicture yilan.Picture, i, 10: tablo(i, 10) = 1
Next
10:
Randomize Timer
x = Fix(Rnd * 30) + 1
y = Fix(Rnd * 20) + 1

If tablo(x, y) = 0 Then
ekran.PaintPicture yem.Picture, x, y
tablo(x, y) = 8
Else
GoTo 10
End If
konum(1) = 20
konum(2) = 10

konum(3) = 11
konum(4) = 10

konum(5) = 2

End Sub

Private Sub Timer1_Timer()
puan = True

Select Case konum(5)
Case 2:
If tablo(konum(1) + 1, konum(2)) = 0 Or tablo(konum(1) + 1, konum(2)) = 8 Then

If tablo(konum(1) + 1, konum(2)) = 8 Then
Label1.Caption = Val(Label1.Caption) + 1
puan = True
End If

tablo(konum(1), konum(2)) = konum(5)
konum(1) = konum(1) + 1

Else
Timer1.Enabled = False
MsgBox "kaybettiniz"
Exit Sub
End If

Case 3:
If tablo(konum(1), konum(2) + 1) = 0 Or tablo(konum(1), konum(2) + 1) = 8 Then

If tablo(konum(1), konum(2) + 1) = 8 Then
Label1.Caption = Val(Label1.Caption) + 1
puan = True
End If

tablo(konum(1), konum(2)) = konum(5)
konum(2) = konum(2) + 1

Else

Timer1.Enabled = False
MsgBox "kaybettiniz"
Exit Sub
End If

Case 4:
If tablo(konum(1) - 1, konum(2)) = 0 Or tablo(konum(1) - 1, konum(2)) = 8 Then

If tablo(konum(1) - 1, konum(2)) = 8 Then
Label1.Caption = Val(Label1.Caption) + 1
puan = True
End If

tablo(konum(1), konum(2)) = konum(5)
konum(1) = konum(1) - 1

Else
Timer1.Enabled = False
MsgBox "kaybettin Lan mal"
Exit Sub
End If
Case 5:
If tablo(konum(1), konum(2) - 1) = 0 Or tablo(konum(1), konum(2) - 1) = 8 Then

If tablo(konum(1), konum(2) - 1) = 8 Then
Label1.Caption = Val(Label1.Caption) + 1
puan = True
End If

tablo(konum(1), konum(2)) = konum(5)
konum(2) = konum(2) - 1

Else
Timer1.Enabled = False
MsgBox "kaybettin Lan mal"
Exit Sub
End If
End Select
ekran.PaintPicture parca.Picture, konum(1), konum(2)

If puan = False Then
ekran.PaintPicture bosluk.Picture, konum(3), konum(4)

Select Case tablo(konum(3), konum(4))
Case 2: konum(3) = konum(4) + 1
tablo(konum(3) - 1, konum(4)) = 0
Case 3: konum(4) = konum(4) + 1
tablo(konum(3), konum(4) - 1) = 0
Case 4: konum(3) = konum(4) + 1
tablo(konum(3) + 1, konum(4)) = 0
Case 5: konum(4) = konum(4) + 1
tablo(konum(3), konum(4) + 1) = 0

End Select
Else
20:
Randomize Timer
x = Fix(Rnd * 30) + 1
y = Fix(Rnd * 20) + 1

If tablo(x, y) = 0 Then
ekran.PaintPicture yem.Picture, x, y
tablo(x, y) = 8
Else
GoTo 20
End If
End If
End Sub

bunu hoca 1.sınıfdayken ıstemısdı hatırlıom :emzik
 
Geri
Üst