Visual Basic içinde Tetris Yapmak konusu , Option Explicit Private i, k, durum, renk, r, s, level, puan Private iaktifsekilkare(3) As Integer Private devam(3) As Boolean Private devamet As Boolean Private sola(3) As Boolean Private solagit As ...
|
|
|||||||
| KAYIT OL | Yönetim Takımı | Üye Listesi | Tüm konuları okunmuş kabul et |
|
|
#1 (permalink) |
|
Moderator
![]() Üyelik Tarihi: 26-10-2006
Mesajlar: 1,694
Rep Gücü: 75
Rep Puanı: 3251
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() |
Option Explicit Private i, k, durum, renk, r, s, level, puan Private iaktifsekilkare(3) As Integer Private devam(3) As Boolean Private devamet As Boolean Private sola(3) As Boolean Private solagit As Boolean Private saga(3) As Boolean Private sagagit As Boolean Private sil(11) As Boolean Private Sub form_keydown(keycode As Integer, shift As Integer) On Error Resume Next If keycode = vbKeyLeft Then If Not (iaktifsekilkare(0) Mod 10 = 1) Then If Shape1(iaktifsekilkare(0) - 1).Visible = False Then sola(0) = True Else sola(0) = False End If If (iaktifsekilkare(1) - 1 = iaktifsekilkare(0)) Then sola(1) = True Else sola(1) = False End If End If If ((iaktifsekilkare(2) - 1 = iaktifsekilkare(0)) Or (iaktifsekilkare(2) - 1 = iaktifsekilkare(1))) Then sola(2) = True Else If Shape1(iaktifsekilkare(2) - 1).Visible = False Then sola(2) = True Else sola(2) = False End If End If If ((iaktifsekilkare(3) - 1 = iaktifsekilkare(0)) Or (iaktifsekilkare(3) - 1 = iaktifsekilkare(1)) Or (iaktifsekilkare(3) - 1 = iaktifsekilkare(1) Or (iaktifsekilkare(3) - 1 = iaktifsekilkare(2)))) Then sola(3) = True Else If Shape1(iaktifsekilkare(3) - 1).Visible = False Then sola(3) = True Else sola(3) = False End If End If For i = 0 To 3 If sola(i) = True Then solagit = True Else solagit = False GoTo soladevam End If Next soladevam: If solagit = True Then If solagit = True Then For i = 0 To 3 Shape1(iaktifsekilkare(i)).Visible = False iaktifsekilkare(i) = iaktifsekilkare(i) - 1 Shape1(iaktifsekilkare(i)).Visible = True Shape1(iaktifsekilkare(i)).BackColor = QBColor(renk) Next End If End If End If End If If keycode = vbKeyRight Then If Not (iaktifsekilkare(3) Mod 10 = 0) Then If Shape1(iaktifsekilkare(3) + 1).Visible = False Then saga(3) = True Else saga(3) = False End If If (iaktifsekilkare(2) + 1 = iaktifsekilkare(3)) Then saga(2) = True Else If Shape1(iaktifsekilkare(2) + 1).Visible = False Then saga(2) = True Else saga(2) = False End If End If If ((iaktifsekilkare(1) + 1 = iaktifsekilkare(3)) Or (iaktifsekilkare(1) + 1 = iaktifsekilkare(2))) Then saga(1) = True Else If Shape1(iaktifsekilkare(1) + 1).Visible = False Then saga(1) = True Else saga(1) = False End If End If If ((iaktifsekilkare(0) + 1 = iaktifsekilkare(3)) Or (iaktifsekilkare(0) + 1 = iaktifsekilkare(2)) Or (iaktifsekilkare(0) + 1 = iaktifsekilkare(1))) Then saga(0) = True Else If Shape1(iaktifsekilkare(0) + 1).Visible = False Then saga(0) = True Else saga(0) = False End If End If For i = 0 To 3 If saga(i) = True Then sagagit = True Else sagagit = False GoTo sagadevam End If Next sagadevam: If sagagit = True Then For i = 3 To 0 Step -1 Shape1(iaktifsekilkare(i)).Visible = False iaktifsekilkare(i) = iaktifsekilkare(i) + 1 Shape1(iaktifsekilkare(i)).Visible = True Shape1(iaktifsekilkare(i)).BackColor = QBColor(renk) Next End If End If End If If keycode = vbKeyDown Then Timer1.Enabled = False Timer1.Interval = 10 Timer1.Enabled = True End If If keycode = vbKeySpace Then Select Case k Case 1 If durum = 1 Then On Error Resume Next If Shape1(iaktifsekilkare(1) - 20).Visible = False And Shape1(iaktifsekilkare(1) - 10).Visible = False Then For i = 0 To 3 Shape1(iaktifsekilkare(i)).Visible = False Next iaktifsekilkare(0) = iaktifsekilkare(1) - 20 iaktifsekilkare(1) = iaktifsekilkare(1) - 10 iaktifsekilkare(2) = iaktifsekilkare(1) + 10 iaktifsekilkare(3) = iaktifsekilkare(1) + 20 durum = 2 End If ElseIf durum = 2 Then On Error Resume Next If Shape1(iaktifsekilkare(2) - 1).Visible = False And Shape1(iaktifsekilkare(2) + 1).Visible = False And Shape1(iaktifsekilkare(2) + 2).Visible = False And (Not iaktifsekilkare(2) Mod 10 = 1) And (iaktifsekilkare(2) Mod 10 < 9) And (Not (iaktifsekilkare(2) Mod 10 = 0)) Then For i = 0 To 3 Shape1(iaktifsekilkare(i)).Visible = False Next iaktifsekilkare(0) = iaktifsekilkare(2) - 1 iaktifsekilkare(1) = iaktifsekilkare(2) iaktifsekilkare(2) = iaktifsekilkare(2) + 1 iaktifsekilkare(3) = iaktifsekilkare(2) + 1 durum = 1 End If End If Case 2 If durum = 1 Then If iaktifsekilkare(2) < 200 Then If Shape1(iaktifsekilkare(2) + 10).Visible = False And Shape1(iaktifsekilkare(3) - 10).Visible = False Then For i = 0 To 3 Shape1(iaktifsekilkare(i)).Visible = False Next iaktifsekilkare(0) = iaktifsekilkare(2) iaktifsekilkare(1) = iaktifsekilkare(0) + 10 iaktifsekilkare(2) = iaktifsekilkare(3) - 10 iaktifsekilkare(3) = iaktifsekilkare(2) + 10 durum = 2 End If End If ElseIf durum = 2 Then If Shape1(iaktifsekilkare(0) - 11).Visible = False And Shape1(iaktifsekilkare(0) - 10).Visible = False And Not (iaktifsekilkare(0) Mod 10 = 1) Then For i = 0 To 3 Shape1(iaktifsekilkare(i)).Visible = False Next iaktifsekilkare(0) = iaktifsekilkare(0) - 11 iaktifsekilkare(1) = iaktifsekilkare(0) + 1 iaktifsekilkare(2) = iaktifsekilkare(1) + 10 iaktifsekilkare(3) = iaktifsekilkare(2) + 1 durum = 1 End If End If Case 3 If durum = 1 Then If iaktifsekilkare(2) < 200 Then If Shape1(iaktifsekilkare(2) + 10).Visible = False And Shape1(iaktifsekilkare(0) - 10).Visible = False Then For i = 0 To 3 Shape1(iaktifsekilkare(i)).Visible = False Next iaktifsekilkare(0) = iaktifsekilkare(0) - 10 iaktifsekilkare(1) = iaktifsekilkare(0) + 10 iaktifsekilkare(2) = iaktifsekilkare(2) iaktifsekilkare(3) = iaktifsekilkare(2) + 10 durum = 2 End If End If ElseIf durum = 2 Then If Shape1(iaktifsekilkare(2) - 9).Visible = False And Shape1(iaktifsekilkare(2) - 10).Visible = False And Not (iaktifsekilkare(2) Mod 10 = 0) And Not (iaktifsekilkare(0) Mod 10 = 1) Then For i = 0 To 3 Shape1(iaktifsekilkare(i)).Visible = False Next iaktifsekilkare(0) = iaktifsekilkare(1) iaktifsekilkare(1) = iaktifsekilkare(0) - 9 iaktifsekilkare(2) = iaktifsekilkare(1) + 10 iaktifsekilkare(3) = iaktifsekilkare(1) + 1 durum = 1 End If End If Case 4 Case 5 If durum = 1 Then If iaktifsekilkare(1) < 190 Then If Shape1(iaktifsekilkare(1) + 10).Visible = False And Shape1(iaktifsekilkare(1) + 20).Visible = False Then For i = 0 To 3 Shape1(iaktifsekilkare(i)).Visible = False Next iaktifsekilkare(0) = iaktifsekilkare(1) iaktifsekilkare(1) = iaktifsekilkare(0) + 10 iaktifsekilkare(2) = iaktifsekilkare(1) + 10 iaktifsekilkare(3) = iaktifsekilkare(0) + 1 durum = 2 End If End If ElseIf durum = 2 Then If Shape1(iaktifsekilkare(3) + 10).Visible = False And Shape1(iaktifsekilkare(0) - 1).Visible = False And (Not (iaktifsekilkare(0) Mod 10 < 2)) Then For i = 0 To 3 Shape1(iaktifsekilkare(i)).Visible = False Next iaktifsekilkare(0) = iaktifsekilkare(0) - 1 iaktifsekilkare(1) = iaktifsekilkare(0) + 1 iaktifsekilkare(2) = iaktifsekilkare(1) + 1 iaktifsekilkare(3) = iaktifsekilkare(2) + 10 durum = 3 End If ElseIf durum = 3 Then If Shape1(iaktifsekilkare(2) - 10).Visible = False And Shape1(iaktifsekilkare(2) - 20).Visible = False And iaktifsekilkare(2) > 20 Then For i = 0 To 3 Shape1(iaktifsekilkare(i)).Visible = False Next iaktifsekilkare(0) = iaktifsekilkare(0) + 1 iaktifsekilkare(1) = iaktifsekilkare(0) + 1 - 20 iaktifsekilkare(2) = iaktifsekilkare(1) + 10 iaktifsekilkare(3) = iaktifsekilkare(2) + 10 durum = 4 End If ElseIf durum = 4 Then If Shape1(iaktifsekilkare(0) - 10).Visible = False And Shape1(iaktifsekilkare(3) + 1).visible0false And (Not (iaktifsekilkare(3) Mod 10 = 0)) Then For i = 0 To 3 Shape1(iaktifsekilkare(i)).Visible = False Next iaktifsekilkare(0) = iaktifsekilkare(2) - 1 iaktifsekilkare(1) = iaktifsekilkare(0) + 10 iaktifsekilkare(2) = iaktifsekilkare(1) + 1 iaktifsekilkare(3) = iaktifsekilkare(2) + 1 durum = 1 End If End If Case 6 If durum = 1 Then If Shape1(iaktifsekilkare(2) - 1).Visible = False And Shape1(iaktifsekilkare(2) - 11).Visible = False And iaktifsekilkare(2) > 20 Then For i = 0 To 3 Shape1(iaktifsekilkare(i)).Visible = False Next iaktifsekilkare(0) = iaktifsekilkare(2) - 11 iaktifsekilkare(1) = iaktifsekilkare(0) + 10 iaktifsekilkare(2) = iaktifsekilkare(1) + 10 iaktifsekilkare(3) = iaktifsekilkare(2) + 1 durum = 2 End If ElseIf durum = 2 Then On Error Resume Next If Shape1(iaktifsekilkare(3) + 1).Visible = False And (Not (iaktifsekilkare(3) Mod 10 = 0)) And Shape1(iaktifsekilkare(2) + 10).Visible = False Then For i = 0 To 3 Shape1(iaktifsekilkare(i)).Visible = False Next iaktifsekilkare(0) = iaktifsekilkare(2) iaktifsekilkare(1) = iaktifsekilkare(0) + 10 iaktifsekilkare(2) = iaktifsekilkare(0) + 1 iaktifsekilkare(3) = iaktifsekilkare(2) + 1 durum = 3 End If ElseIf durum = 3 Then On Error Resume Next If Shape1(iaktifsekilkare(0) - 1).Visible = False And Shape1(iaktifsekilkare(1) + 10).Visible = False And (Not (iaktifsekilkare(0) Mod 10 = 1)) Then For i = 0 To 3 Shape1(iaktifsekilkare(i)).Visible = False Next iaktifsekilkare(0) = iaktifsekilkare(0) - 1 iaktifsekilkare(1) = iaktifsekilkare(0) + 1 iaktifsekilkare(2) = iaktifsekilkare(1) + 10 iaktifsekilkare(3) = iaktifsekilkare(2) + 10 durum = 4 End If ElseIf durum = 4 Then If Shape1(iaktifsekilkare(2) + 1).Visible = False And Shape1(iaktifsekilkare(2) - 9).Visible = False And (Not (iaktifsekilkare(1) Mod 10 = 0)) Then For i = 0 To 3 Shape1(iaktifsekilkare(i)).Visible = False Next iaktifsekilkare(2) = iaktifsekilkare(1) - 9 iaktifsekilkare(3) = iaktifsekilkare(2) + 10 durum = 1 End If End If End Select For i = 0 To 3 Shape1(iaktifsekilkare(i)).Visible = True Shape1(iaktifsekilkare(i)).BackColor = QBColor(renk) Next End If End Sub Private Sub form_load() 'şekilleri yerleştirelim For i = 0 To 20 For k = 1 To 10 Load Shape1(10 * i + k) If k = 1 Then Shape1(i * 10 + k).Left = Shape1(0).Left + Shape1(0).Width Shape1(i * 10 + k).Top = Shape1(0).Top Else Shape1(i * 10 + k).Left = Shape1(i * 10 + k - 1).Left + Shape1(i * 10 + k - 1).Width Shape1(i * 10 + k).Top = Shape1(0).Top End If Next Shape1(0).Top = Shape1(0).Top - Shape1(0).Height Next Shape2.Move Shape1(1).Left - 5, Shape1(210).Top - 5, 10 * Shape1(0).Width + 10, Shape1(0).Height * 20 + 10 Call sekilsec For i = 0 To 10 Shape1(i).Visible = True Next level = 0 puan = 0 Label1.Caption = "level" & level Label2.Caption = "punanınız:" & puan End Sub Private Sub sekilsec() Randomize Timer k = Int(Rnd * 6) + 1 Select Case k Case 1: iaktifsekilkare(0) = 204 iaktifsekilkare(1) = 205 iaktifsekilkare(2) = 206 iaktifsekilkare(3) = 207 durum = 1 Case 2: iaktifsekilkare(0) = 195 iaktifsekilkare(1) = 196 iaktifsekilkare(2) = 206 iaktifsekilkare(3) = 207 durum = 1 Case 3: iaktifsekilkare(0) = 205 iaktifsekilkare(1) = 196 iaktifsekilkare(2) = 206 iaktifsekilkare(3) = 197 durum = 1 Case 4: iaktifsekilkare(0) = 195 iaktifsekilkare(1) = 205 iaktifsekilkare(2) = 196 iaktifsekilkare(3) = 206 durum = 1 Case 5: iaktifsekilkare(0) = 195 iaktifsekilkare(1) = 205 iaktifsekilkare(2) = 206 iaktifsekilkare(3) = 207 durum = 1 Case 6: iaktifsekilkare(0) = 205 iaktifsekilkare(1) = 206 iaktifsekilkare(2) = 197 iaktifsekilkare(3) = 207 durum = 1 End Select bidaha: renk = Int(Rnd * 15) + 1 If renk = 7 Then GoTo bidaha For i = 0 To 3 Shape1(iaktifsekilkare(i)).Visible = True Shape1(iaktifsekilkare(i)).BackColor = QBColor(renk) Next End Sub Private Sub timer1_timer() devamet = False For i = 0 To 3 devam(i) = False Next If Shape1(iaktifsekilkare(0) - 10).Visible = False Then devam(0) = True If (iaktifsekilkare(1) - 10 = iaktifsekilkare(0)) Then devam(1) = True Else If Shape1(iaktifsekilkare(1) - 10).Visible = False Then devam(1) = True End If If (iaktifsekilkare(2) - 10 = iaktifsekilkare(1)) Then devam(2) = True Else If Shape1(iaktifsekilkare(2) - 10).Visible = False Then devam(2) = True End If If (iaktifsekilkare(3) - 10 = iaktifsekilkare(2)) Then devam(3) = True Else If Shape1(iaktifsekilkare(3) - 10).Visible = False Then devam(3) = True End If For i = 0 To 3 If devam(i) = True Then devamet = True Else devamet = False GoTo devamdevam End If Next devamdevam: If devamet = True Then For i = 0 To 3 On Error Resume Next Shape1(iaktifsekilkare(i)).Visible = False iaktifsekilkare(i) = iaktifsekilkare(i) - 10 Shape1(iaktifsekilkare(i)).Visible = True Shape1(iaktifsekilkare(i)).BackColor = QBColor(renk) Next Else Call kontrol Call sekilsec End If End Sub Private Sub kontrol() sil(11) = False basla: level = Int(puan / 1500) Select Case level Case 0: Timer1.Interval = 1000 Case 1: Timer1.Interval = 1000 Case 2: Timer1.Interval = 500 Case 3: Timer1.Interval = 250 Case 4: Timer1.Interval = 125 Case 5: Timer1.Interval = 60 Case 6: Timer1.Interval = 30 Case 7: Timer1.Interval = 15 Case 8: Timer1.Interval = 10 End Select If level > 8 Then Timer1.Interval = 5 Label1.Caption = "level" & level For i = 1 To 19 For r = 1 To 10 If Shape1(i * 10 + r).Visible = True Then sil(r) = True Else sil(r) = False End If Next For r = 1 To 10 If sil(r) = True Then sil(11) = True Else sil(11) = False GoTo silelim End If Next silelim: If sil(11) = True Then GoTo silbakalim Next Exit Sub silbakalim: puan = puan + 100 Label2.Caption = "puanınız:" & puan For s = i To 19 For r = 1 To 10 If Shape1(s * 10 + r + 10).Visible = True Then Shape1(s * 10 + r).BackColor = Shape1(s * 10 + r + 10).BackColor Else Shape1(s * 10 + r).Visible = False End If Next Next GoTo basla End Sub
__________________
Geri döndüm
|
|
|
|
![]() |
| Konu Yönetim Seçenekleri | |
| Konu Gösterim Seçenekleri | |
|
|