+ Rispondi al Thread
Visualizzazione dei risultati da 1 a 5 su 5

Discussione: Problema per invertire senso di caduta del tetris in VB6

  1. #1
    alien75 non è in linea Scolaretto
    Post
    203

    Problema per invertire senso di caduta del tetris in VB6

    Buon giorno ho scaricato un tetris semplice fatto in VB6.
    Mi trovo difronte l' esigenza di invertire il senso di caduta delle pedine (quindi dal basso verso l' alto).
    Mi interessa inoltre capire qul'è la varibile che mi permette di cambiare la posizione di partenza di tali pedine.
    Ho provato e riprovato a cercare la varibile giusta per fare ciò ma non riesco a trovare nessun stratagemma che faccia al caso mio.
    Per favore aiutatemi.
    Il progetto può essere scaricato da qui ---> http://freesourcecode.net/vbprojects...c#.XQ5ii8bOPZv
    Ultima modifica di alien75; 22-06-2019 18:22 

  2. #2
    L'avatar di AntonioG
    AntonioG non è in linea Moderatore Globale Ultimo blog: Commodore 64 e Codemotion
    Luogo
    Roma
    Post
    16,251
    Blogs
    5
    Si scaricano solo i .bas
    Avvisi generali e importanti, a pena CHIUSURA thread e/o BAN
    Il crossposting è vietato.
    Le richieste di "pappa pronta" sono vietate.
    Utilizzate i tag CODE per il codice.
    Leggere il Regolamento per chiarimenti PRIMA di creare nuovi thread.
    Utilizzare sempre i PM per comunicare con i moderatori.
    Non mi contattate in PM per problemi di software, usate il forum

  3. #3
    alien75 non è in linea Scolaretto
    Post
    203
    Lo puoi scaricare completamente da qui ---> FreeVBCode code snippet: Simple Tetris clone
    Dimmi che te ne pare.

  4. #4
    L'avatar di AntonioG
    AntonioG non è in linea Moderatore Globale Ultimo blog: Commodore 64 e Codemotion
    Luogo
    Roma
    Post
    16,251
    Blogs
    5
    La posizione di partenza la cambi impostando

    fy = 5700

    ma il senso è insito in tutto il codice e non sarà facile cambiarlo senza cambiare parti rilevanti di codice.
    Avvisi generali e importanti, a pena CHIUSURA thread e/o BAN
    Il crossposting è vietato.
    Le richieste di "pappa pronta" sono vietate.
    Utilizzate i tag CODE per il codice.
    Leggere il Regolamento per chiarimenti PRIMA di creare nuovi thread.
    Utilizzare sempre i PM per comunicare con i moderatori.
    Non mi contattate in PM per problemi di software, usate il forum

  5. #5
    alien75 non è in linea Scolaretto
    Post
    203

    Progressi

    Quote Originariamente inviato da AntonioG Visualizza il messaggio
    La posizione di partenza la cambi impostando

    fy = 5700

    ma il senso è insito in tutto il codice e non sarà facile cambiarlo senza cambiare parti rilevanti di codice.
    Riporto di seguito i sorgenti che compongono il gioco e le ultime modifiche e progressi:


    load.bas
    codice:
    Const KEY_LEFT = 37
    Const KEY_UP = 38
    Const KEY_RIGHT = 39
    Const KEY_DOWN = 40
    Const PAUSE = 80
    Const NEW_GAME = 78
    Const END_GAME = 27
    Public resize As Boolean
    
    Private Sub Form_KeyDown(KeyCode As Integer, Shift As Integer)
    
       If Timer1.Enabled = True Then
       
       With box(rnum)
            If KeyCode = KEY_RIGHT Then
               If hitright = True Then Exit Sub
               If hitbrixright = True Then Exit Sub
               clear
               For i = 1 To 4
                   .X(i) = .X(i) + boxwidth
               Next i
               display
           End If
           If KeyCode = KEY_LEFT Then
              If hitleft = True Then Exit Sub
              If hitbrixleft = True Then Exit Sub
              clear
              For i = 1 To 4
                  .X(i) = .X(i) - boxwidth
              Next i
              display
           End If
           If KeyCode = KEY_UP Then
              clear
              tempstate = state
              state = state + 1
              If state > .rot Then
                 state = 1
              End If
              If rotate = False Then state = tempstate
              display
           End If
           If KeyCode = KEY_DOWN Then
              For i = 1 To 7
                  clear
                  If Control = True Then Exit Sub
                  For j = 1 To 4
                      .Y(j) = .Y(j) + boxwidth
                  Next j
                  display
              Next i
              If Control = True Then Exit Sub
           End If
        End With
        End If
           
           If KeyCode = PAUSE Then
              Timer1.Enabled = Not (Timer1.Enabled)
           End If
           If KeyCode = NEW_GAME Then
              Form_Load
              Label2.Caption = "SCORE : " + Str(score)
           End If
           
           If KeyCode = END_GAME Then
              Form_Unload (1)
           End If
      
    End Sub
    
    Private Sub Form_Load()
       Formmain.Refresh
       box(1).rot = 4
       box(2).rot = 1
       For i = 3 To 6
           box(i).rot = 4
       Next i
       box(7).rot = 2
       boxwidth = 300: pos = 0
       fx = 2500
       fy = 2700     'posizione di partenza
       score = 0
       newbrix
       display
    End Sub
    
    Private Sub Form_Resize()
       resize = True
    End Sub
    
    Private Sub Form_Unload(Cancel As Integer)
       MsgBox "I hope you enjoyed the Game"
       End
    End Sub
    Private Sub Timer1_Timer()
       If resize = True Then
          For i = 1 To pos
              test (i)
          Next i
          resize = False
       End If
       With box(rnum)
            If Control = True Then Exit Sub
            clear
            For i = 1 To 4
                .Y(i) = .Y(i) - boxwidth    'cambiare segno per invertire senso di caduta
            Next i
            display
       End With
    End Sub
    
    Public Sub display()
       With box(rnum)
            For i = 1 To 4
                Line (.X(i), .Y(i))-(.X(i) + boxwidth, .Y(i) + boxwidth), RGB(.r, .g, .b), BF
                fill 0, 0, 0, i
            Next i
       End With
    End Sub
    Public Sub clear()
       With box(rnum)
            For i = 1 To 4
                Line (.X(i), .Y(i))-(.X(i) + boxwidth, .Y(i) + boxwidth), RGB(0, 0, 0), BF
                fill 0, 0, 0, i
            Next i
       End With
    End Sub
    
    Public Sub fill(rd, gr, bl, j)
       With box(rnum)
            Line (.X(j), .Y(j))-(.X(j) + boxwidth, .Y(j)), RGB(rd, gr, bl)
            Line (.X(j), .Y(j))-(.X(j), .Y(j) + boxwidth), RGB(rd, gr, bl)
            Line (.X(j), .Y(j) + boxwidth)-(.X(j) + boxwidth, .Y(j) + boxwidth), RGB(rd, gr, bl)
            Line (.X(j) + boxwidth, .Y(j))-(.X(j) + boxwidth, .Y(j) + boxwidth), RGB(rd, gr, bl)
       End With
    End Sub
    
    Public Function Control() As Boolean
       With box(rnum)
       For i = 1 To 4
           If .Y(i) - boxwidth = 0 Then    'cambiare  fy + (11 * boxwidth)  per cambiare punto di arrivo
              For k = 1 To 4
                  pos = pos + 1
                  old(pos).X = .X(k)
                  old(pos).Y = .Y(k)
                  old(pos).bl = True
                  old(pos).r = .r
                  old(pos).g = .g
                  old(pos).b = .b
              Next k
              display
              control2
              newbrix
              Control = True
              Exit Function
           End If
       Next i
           '****************************
       For i = 1 To 4
           For l = 1 To pos
               If .Y(i) + boxwidth = old(l).Y And .X(i) = old(l).X Then
                  For k = 1 To 4
                      If .Y(k) = fy Then
                         MsgBox Space(12) + "end": End
                      End If
                      pos = pos + 1
                      old(pos).X = .X(k)
                      old(pos).Y = .Y(k)
                      old(pos).bl = True
                      old(pos).r = .r
                      old(pos).g = .g
                      old(pos).b = .b
                  Next k
                  display
                  control2
                  newbrix
                  Control = True
                  Exit Function
               End If
           Next l
       Next i
       Control = False
       End With
    End Function
    Public Sub newbrix()
       Randomize Timer
       rnum = Int(Rnd * 7) + 1
       With box(rnum)
            .X(1) = fx + (4 * boxwidth)
            If rnum = 2 Then
               .Y(1) = fy - (2 * boxwidth)
            Else
               If rnum = 7 Then
                  .Y(1) = fy - (4 * boxwidth)
               Else
                  .Y(1) = fy - (3 * boxwidth)
               End If
            End If
            .r = Int(Rnd * 255) + 1
            .g = Int(Rnd * 255) + 1
            .b = Int(Rnd * 255) + 1
            tempx(1) = .X(1)
            tempy(1) = .Y(1)
            state = 1
       End With
       calc
       inputvar
    End Sub
    Public Sub control2()
       Dim fin(20)
       metr = 1
       For i = 1 To pos
           cn = 1
           For j = 1 To 10
               If old(j).Y = fy + (i * boxwidth) Then
                  cn = cn + 1
                  If cn = 10 Then
                     metr = metr + 1
                     fin(metr) = old(j).Y
                  End If
               End If
           Next j
       Next i
       '**********************
       If metr <> 0 Then
          score = score + (metr * 10)
          Label2.Caption = "SCORE : " + Str(score)
          For i = 1 To metr
              For j = 1 To pos
                  If old(j).Y = fin(i) Then
                     old(j).bl = False
                  End If
              Next j
          Next i
       '***********************
          Line (fx, fy)-(fx + (10 * boxwidth), fy + (20 * boxwidth)), RGB(0, 0, 0), BF
          For j = 1 To metr
              For i = 1 To pos
                  If old(i).bl = True And old(i).Y > fin(j) Then
                     old(i).Y = old(i).Y + boxwidth   'modificare qui per cumulo verso l'alto
                  End If
              Next i
          Next j
       '************************
          num = 1
          For i = 1 To pos
              If old(i).bl = True Then
                 num = num + 1
                 clean(num).X = old(i).X: clean(num).Y = old(i).Y
                 clean(num).r = old(i).r: clean(num).g = old(i).g: clean(num).b = old(i).b
                 test (i)
              End If
          Next i
       '***************************
          pos = num
          For i = 1 To num
              With old(i)
                   .X = clean(i).X
                   .Y = clean(i).Y
                   .bl = True
                   .r = clean(i).r
                   .g = clean(i).g
                   .b = clean(i).b
              End With
          Next i
       End If
    End Sub
    
    Public Sub test(i)
       With old(i)
            Line (.X, .Y)-(.X + boxwidth, .Y + boxwidth), RGB(.r, .g, .b), BF
            Line (.X, .Y)-(.X + boxwidth, .Y), RGB(0, 0, 0)
            Line (.X, .Y)-(.X, .Y + boxwidth), RGB(0, 0, 0)
            Line (.X, .Y + boxwidth)-(.X + boxwidth, .Y + boxwidth), RGB(0, 0, 0)
            Line (.X + boxwidth, .Y)-(.X + boxwidth, .Y + boxwidth), RGB(0, 0, 0)
     End With
    End Sub

    tetris2.bas
    codice:
    Attribute VB_Name = "Module1"
    
    Option Base 1
    Type tempbox
         X(4) As Integer
         Y(4) As Integer
         r As Integer
         g As Integer
         b As Integer
         rot As Integer
    End Type
    
    Public box(7) As tempbox
    Type tempold
         X As Integer
         Y As Integer
         bl As Boolean
         r As Integer
         g As Integer
         b As Integer
    End Type
    Public old(200) As tempold
    Type tempclean
         X As Integer
         Y As Integer
         bl As Boolean
         r As Integer
         g As Integer
         b As Integer
    End Type
    Public clean(200) As tempclean
    Public tempx(4), tempy(4) As Integer
    Public score, state, boxwidth, pos, rnum, fx, fy As Integer
    
    Public Function rotate() As Boolean
       With box(rnum)
            If rnum = 1 Or rnum = 3 Or rnum = 4 Or rnum = 5 Or rnum = 6 Then
               If state = 1 Then
                  tempx(1) = .X(1) + boxwidth
                  tempy(1) = .Y(1) - boxwidth
               End If
               If state = 2 Then
                  tempx(1) = .X(1) + boxwidth
                  tempy(1) = .Y(1) + boxwidth
               End If
               If state = 3 Then
                  tempx(1) = .X(1) - boxwidth
                  tempy(1) = .Y(1) + boxwidth
               End If
               If state = 4 Then
                  tempx(1) = .X(1) - boxwidth
                  tempy(1) = .Y(1) - boxwidth
               End If
            End If
            If rnum = 2 Then
               Exit Function
            End If
            If rnum = 7 Then
               If state = 1 Then
                  tempx(1) = .X(1) - (2 * boxwidth)
                  tempy(1) = .Y(1) - (2 * boxwidth)
               End If
               If state = 2 Then
                  tempx(1) = .X(1) + (2 * boxwidth)
                  tempy(1) = .Y(1) + (2 * boxwidth)
               End If
            End If
            calc
            '*****************************
            For i = 1 To 4
                If tempx(i) < fx Then
                   tempx(1) = tempx(1) + boxwidth
                   calc
                End If
                If tempx(i) + boxwidth = fx + (12 * boxwidth) Then
                   tempx(1) = tempx(1) - (2 * boxwidth)
                   calc
                Else
                   If tempx(i) + boxwidth > fx + (10 * boxwidth) Then
                      tempx(1) = tempx(1) - boxwidth
                      calc
                   End If
                End If
                If tempy(i) + boxwidth >= fy + (20 * boxwidth) Then
                   rotate = False
                   Exit Function
                End If
            Next i
            '**********************
            For i = 1 To pos
                For j = 1 To 4
                    If tempx(j) = old(i).X And tempy(j) = old(i).Y Then
                       rotate = False
                       Exit Function
                    End If
                Next j
            Next i
            '*********************
            rotate = True
            inputvar
       End With
    End Function
    Public Sub inputvar()
       With box(rnum)
            For i = 1 To 4
                .X(i) = tempx(i)
                .Y(i) = tempy(i)
            Next i
       End With
    End Sub
    Public Function hitleft() As Boolean
       With box(rnum)
            For i = 1 To 4
                If .X(i) = fx Then
                    hitleft = True: Exit Function
                End If
            Next i
            hitleft = False
       End With
    End Function
    Public Function hitright() As Boolean
       With box(rnum)
            For i = 1 To 4
                If .X(i) + boxwidth = fx + (10 * boxwidth) Then
                    hitright = True: Exit Function
                End If
            Next i
            hitright = False
       End With
    End Function
    Public Function hitbrixright() As Boolean
       With box(rnum)
       If pos <> 0 Then
          For i = 1 To 4
              For j = 1 To pos
                  If .X(i) + boxwidth = old(j).X And .Y(i) = old(j).Y Then
                     hitbrixright = True: Exit Function
                  End If
              Next j
          Next i
       End If
       hitbrixright = False
       End With
    End Function
    Public Function hitbrixleft() As Boolean
       With box(rnum)
       If pos <> 0 Then
          For i = 1 To 4
              For j = 1 To pos
                  If .X(i) = old(j).X + boxwidth And .Y(i) = old(j).Y Then
                     hitbrixleft = True: Exit Function
                  End If
              Next j
          Next i
       End If
       hitbrixleft = False
       End With
    End Function

    tetris.bas
    codice:
    Attribute VB_Name = "Module2"
    Public Sub calc()
       If rnum = 1 Then
           If state = 1 Then
               tempx(2) = tempx(1)
               tempy(2) = tempy(1) + boxwidth
               tempx(3) = tempx(2)
               tempy(3) = tempy(2) + boxwidth
               tempx(4) = tempx(3) + boxwidth
               tempy(4) = tempy(3)
            End If
            If state = 2 Then
               tempx(2) = tempx(1) - boxwidth
               tempy(2) = tempy(1)
               tempx(3) = tempx(2) - boxwidth
               tempy(3) = tempy(2)
               tempx(4) = tempx(3)
               tempy(4) = tempy(3) + boxwidth
            End If
            If state = 3 Then
               tempx(2) = tempx(1)
               tempy(2) = tempy(1) - boxwidth
               tempx(3) = tempx(2)
               tempy(3) = tempy(2) - boxwidth
               tempx(4) = tempx(3) - boxwidth
               tempy(4) = tempy(3)
            End If
            If state = 4 Then
               tempx(2) = tempx(1) + boxwidth
               tempy(2) = tempy(1)
               tempx(3) = tempx(2) + boxwidth
               tempy(3) = tempy(2)
               tempx(4) = tempx(3)
               tempy(4) = tempy(3) - boxwidth
            End If
       End If
       '***************************
       If rnum = 2 Then
          If state = 1 Then
             tempx(2) = tempx(1) + boxwidth
             tempy(2) = tempy(1)
             tempx(3) = tempx(1)
             tempy(3) = tempy(1) + boxwidth
             tempx(4) = tempx(2)
             tempy(4) = tempy(3)
          End If
       End If
       '***********************
       If rnum = 3 Then
          If state = 1 Then
             tempx(2) = tempx(1)
             tempy(2) = tempy(1) + boxwidth
             tempx(3) = tempx(2)
             tempy(3) = tempy(2) + boxwidth
             tempx(4) = tempx(3) - boxwidth
             tempy(4) = tempy(3)
          End If
          If state = 2 Then
             tempx(2) = tempx(1) - boxwidth
             tempy(2) = tempy(1)
             tempx(3) = tempx(2) - boxwidth
             tempy(3) = tempy(2)
             tempx(4) = tempx(3)
             tempy(4) = tempy(3) - boxwidth
          End If
          If state = 3 Then
             tempx(2) = tempx(1)
             tempy(2) = tempy(1) - boxwidth
             tempx(3) = tempx(2)
             tempy(3) = tempy(2) - boxwidth
             tempx(4) = tempx(3) + boxwidth
             tempy(4) = tempy(3)
          End If
          If state = 4 Then
             tempx(2) = tempx(1) + boxwidth
             tempy(2) = tempy(1)
             tempx(3) = tempx(2) + boxwidth
             tempy(3) = tempy(2)
             tempx(4) = tempx(3)
             tempy(4) = tempy(3) + boxwidth
          End If
       End If
       '****************************************
       If rnum = 4 Then
          If state = 1 Then
             tempx(2) = tempx(1)
             tempy(2) = tempy(1) + boxwidth
             tempx(3) = tempx(2) + boxwidth
             tempy(3) = tempy(2)
             tempx(4) = tempx(3)
             tempy(4) = tempy(3) + boxwidth
          End If
          If state = 2 Then
             tempx(2) = tempx(1) - boxwidth
             tempy(2) = tempy(1)
             tempx(3) = tempx(2)
             tempy(3) = tempy(2) + boxwidth
             tempx(4) = tempx(3) - boxwidth
             tempy(4) = tempy(3)
          End If
          If state = 3 Then
             tempx(2) = tempx(1)
             tempy(2) = tempy(1) - boxwidth
             tempx(3) = tempx(2) - boxwidth
             tempy(3) = tempy(2)
             tempx(4) = tempx(3)
             tempy(4) = tempy(3) - boxwidth
          End If
          If state = 4 Then
             tempx(2) = tempx(1) + boxwidth
             tempy(2) = tempy(1)
             tempx(3) = tempx(2)
             tempy(3) = tempy(2) - boxwidth
             tempx(4) = tempx(3) + boxwidth
             tempy(4) = tempy(3)
          End If
       End If
       '****************************
       If rnum = 5 Then
          If state = 1 Then
             tempx(2) = tempx(1)
             tempy(2) = tempy(1) + boxwidth
             tempx(3) = tempx(2) - boxwidth
             tempy(3) = tempy(2)
             tempx(4) = tempx(3)
             tempy(4) = tempy(3) + boxwidth
          End If
          If state = 2 Then
             tempx(2) = tempx(1) - boxwidth
             tempy(2) = tempy(1)
             tempx(3) = tempx(2)
             tempy(3) = tempy(2) - boxwidth
             tempx(4) = tempx(3) - boxwidth
             tempy(4) = tempy(3)
          End If
          If state = 3 Then
             tempx(2) = tempx(1)
             tempy(2) = tempy(1) - boxwidth
             tempx(3) = tempx(2) + boxwidth
             tempy(3) = tempy(2)
             tempx(4) = tempx(3)
             tempy(4) = tempy(3) - boxwidth
          End If
          If state = 4 Then
             tempx(2) = tempx(1) + boxwidth
             tempy(2) = tempy(1)
             tempx(3) = tempx(2)
             tempy(3) = tempy(2) + boxwidth
             tempx(4) = tempx(3) + boxwidth
             tempy(4) = tempy(3)
          End If
       End If
       If rnum = 6 Then
          If state = 1 Then
             tempx(2) = tempx(1)
             tempy(2) = tempy(1) + boxwidth
             tempx(3) = tempx(2) + boxwidth
             tempy(3) = tempy(2)
             tempx(4) = tempx(2) - boxwidth
             tempy(4) = tempy(2)
          End If
          If state = 2 Then
             tempx(2) = tempx(1) - boxwidth
             tempy(2) = tempy(1)
             tempx(3) = tempx(2)
             tempy(3) = tempy(2) + boxwidth
             tempx(4) = tempx(2)
             tempy(4) = tempy(2) - boxwidth
          End If
          If state = 3 Then
             tempx(2) = tempx(1)
             tempy(2) = tempy(1) - boxwidth
             tempx(3) = tempx(2) + boxwidth
             tempy(3) = tempy(2)
             tempx(4) = tempx(2) - boxwidth
             tempy(4) = tempy(3)
          End If
          If state = 4 Then
             tempx(2) = tempx(1) + boxwidth
             tempy(2) = tempy(1)
             tempx(3) = tempx(2)
             tempy(3) = tempy(2) - boxwidth
             tempx(4) = tempx(2)
             tempy(4) = tempy(2) + boxwidth
          End If
       End If
       If rnum = 7 Then
          If state = 1 Then
             tempx(2) = tempx(1)
             tempy(2) = tempy(1) + boxwidth
             tempx(3) = tempx(2)
             tempy(3) = tempy(2) + boxwidth
             tempx(4) = tempx(3)
             tempy(4) = tempy(3) + boxwidth
          End If
          If state = 2 Then
             tempx(2) = tempx(1) - boxwidth
             tempy(2) = tempy(1)
             tempx(3) = tempx(2) - boxwidth
             tempy(3) = tempy(2)
             tempx(4) = tempx(3) - boxwidth
             tempy(4) = tempy(3)
          End If
       End If
    End Sub

    timer.bas
    codice:
    Const KEY_LEFT = 37
    Const KEY_UP = 38
    Const KEY_RIGHT = 39
    Const KEY_DOWN = 40
    Const PAUSE = 80
    Const NEW_GAME = 78
    Const END_GAME = 27
    Public resize As Boolean
    
    Private Sub Form_KeyDown(KeyCode As Integer, Shift As Integer)
    
       If Timer1.Enabled = True Then
       
       With box(rnum)
            If KeyCode = KEY_RIGHT Then
               If hitright = True Then Exit Sub
               If hitbrixright = True Then Exit Sub
               clear
               For i = 1 To 4
                   .X(i) = .X(i) + boxwidth
               Next i
               display
           End If
           If KeyCode = KEY_LEFT Then
              If hitleft = True Then Exit Sub
              If hitbrixleft = True Then Exit Sub
              clear
              For i = 1 To 4
                  .X(i) = .X(i) - boxwidth
              Next i
              display
           End If
           If KeyCode = KEY_UP Then
              clear
              tempstate = state
              state = state + 1
              If state > .rot Then
                 state = 1
              End If
              If rotate = False Then state = tempstate
              display
           End If
           If KeyCode = KEY_DOWN Then
              For i = 1 To 7
                  clear
                  If Control = True Then Exit Sub
                  For j = 1 To 4
                      .Y(j) = .Y(j) + boxwidth
                  Next j
                  display
              Next i
              If Control = True Then Exit Sub
           End If
        End With
        End If
           
           If KeyCode = PAUSE Then
              Timer1.Enabled = Not (Timer1.Enabled)
           End If
           If KeyCode = NEW_GAME Then
              Form_Load
              Label2.Caption = "SCORE : " + Str(score)
           End If
           
           If KeyCode = END_GAME Then
              Form_Unload (1)
           End If
      
    End Sub
    
    Private Sub Form_Load()
       Formmain.Refresh
       box(1).rot = 4
       box(2).rot = 1
       For i = 3 To 6
           box(i).rot = 4
       Next i
       box(7).rot = 2
       boxwidth = 300: pos = 0
       fx = 2500
       fy = 2700     'posizione di partenza
       score = 0
       newbrix
       display
    End Sub
    
    Private Sub Form_Resize()
       resize = True
    End Sub
    
    Private Sub Form_Unload(Cancel As Integer)
       MsgBox "I hope you enjoyed the Game"
       End
    End Sub
    Private Sub Timer1_Timer()
       If resize = True Then
          For i = 1 To pos
              test (i)
          Next i
          resize = False
       End If
       With box(rnum)
            If Control = True Then Exit Sub
            clear
            For i = 1 To 4
                .Y(i) = .Y(i) - boxwidth    'cambiare segno per invertire senso di caduta
            Next i
            display
       End With
    End Sub
    
    Public Sub display()
       With box(rnum)
            For i = 1 To 4
                Line (.X(i), .Y(i))-(.X(i) + boxwidth, .Y(i) + boxwidth), RGB(.r, .g, .b), BF
                fill 0, 0, 0, i
            Next i
       End With
    End Sub
    Public Sub clear()
       With box(rnum)
            For i = 1 To 4
                Line (.X(i), .Y(i))-(.X(i) + boxwidth, .Y(i) + boxwidth), RGB(0, 0, 0), BF
                fill 0, 0, 0, i
            Next i
       End With
    End Sub
    
    Public Sub fill(rd, gr, bl, j)
       With box(rnum)
            Line (.X(j), .Y(j))-(.X(j) + boxwidth, .Y(j)), RGB(rd, gr, bl)
            Line (.X(j), .Y(j))-(.X(j), .Y(j) + boxwidth), RGB(rd, gr, bl)
            Line (.X(j), .Y(j) + boxwidth)-(.X(j) + boxwidth, .Y(j) + boxwidth), RGB(rd, gr, bl)
            Line (.X(j) + boxwidth, .Y(j))-(.X(j) + boxwidth, .Y(j) + boxwidth), RGB(rd, gr, bl)
       End With
    End Sub
    
    Public Function Control() As Boolean
       With box(rnum)
       For i = 1 To 4
           If .Y(i) - boxwidth = 0 Then    'cambiare  fy + (11 * boxwidth)  per cambiare punto di arrivo
              For k = 1 To 4
                  pos = pos + 1
                  old(pos).X = .X(k)
                  old(pos).Y = .Y(k)
                  old(pos).bl = True
                  old(pos).r = .r
                  old(pos).g = .g
                  old(pos).b = .b
              Next k
              display
              control2
              newbrix
              Control = True
              Exit Function
           End If
       Next i
           '****************************
       For i = 1 To 4
           For l = 1 To pos
               If .Y(i) + boxwidth = old(l).Y And .X(i) = old(l).X Then
                  For k = 1 To 4
                      If .Y(k) = fy Then
                         MsgBox Space(12) + "end": End
                      End If
                      pos = pos + 1
                      old(pos).X = .X(k)
                      old(pos).Y = .Y(k)
                      old(pos).bl = True
                      old(pos).r = .r
                      old(pos).g = .g
                      old(pos).b = .b
                  Next k
                  display
                  control2
                  newbrix
                  Control = True
                  Exit Function
               End If
           Next l
       Next i
       Control = False
       End With
    End Function
    Public Sub newbrix()
       Randomize Timer
       rnum = Int(Rnd * 7) + 1
       With box(rnum)
            .X(1) = fx + (4 * boxwidth)
            If rnum = 2 Then
               .Y(1) = fy - (2 * boxwidth)
            Else
               If rnum = 7 Then
                  .Y(1) = fy - (4 * boxwidth)
               Else
                  .Y(1) = fy - (3 * boxwidth)
               End If
            End If
            .r = Int(Rnd * 255) + 1
            .g = Int(Rnd * 255) + 1
            .b = Int(Rnd * 255) + 1
            tempx(1) = .X(1)
            tempy(1) = .Y(1)
            state = 1
       End With
       calc
       inputvar
    End Sub
    Public Sub control2()
       Dim fin(20)
       metr = 1
       For i = 1 To pos
           cn = 1
           For j = 1 To 10
               If old(j).Y = fy + (i * boxwidth) Then
                  cn = cn + 1
                  If cn = 10 Then
                     metr = metr + 1
                     fin(metr) = old(j).Y
                  End If
               End If
           Next j
       Next i
       '**********************
       If metr <> 0 Then
          score = score + (metr * 10)
          Label2.Caption = "SCORE : " + Str(score)
          For i = 1 To metr
              For j = 1 To pos
                  If old(j).Y = fin(i) Then
                     old(j).bl = False
                  End If
              Next j
          Next i
       '***********************
          Line (fx, fy)-(fx + (10 * boxwidth), fy + (20 * boxwidth)), RGB(0, 0, 0), BF
          For j = 1 To metr
              For i = 1 To pos
                  If old(i).bl = True And old(i).Y > fin(j) Then
                     old(i).Y = old(i).Y + boxwidth   'modificare qui per cumulo verso l'alto
                  End If
              Next i
          Next j
       '************************
          num = 1
          For i = 1 To pos
              If old(i).bl = True Then
                 num = num + 1
                 clean(num).X = old(i).X: clean(num).Y = old(i).Y
                 clean(num).r = old(i).r: clean(num).g = old(i).g: clean(num).b = old(i).b
                 test (i)
              End If
          Next i
       '***************************
          pos = num
          For i = 1 To num
              With old(i)
                   .X = clean(i).X
                   .Y = clean(i).Y
                   .bl = True
                   .r = clean(i).r
                   .g = clean(i).g
                   .b = clean(i).b
              End With
          Next i
       End If
    End Sub
    
    Public Sub test(i)
       With old(i)
            Line (.X, .Y)-(.X + boxwidth, .Y + boxwidth), RGB(.r, .g, .b), BF
            Line (.X, .Y)-(.X + boxwidth, .Y), RGB(0, 0, 0)
            Line (.X, .Y)-(.X, .Y + boxwidth), RGB(0, 0, 0)
            Line (.X, .Y + boxwidth)-(.X + boxwidth, .Y + boxwidth), RGB(0, 0, 0)
            Line (.X + boxwidth, .Y)-(.X + boxwidth, .Y + boxwidth), RGB(0, 0, 0)
     End With
    End Sub

    Con queste ultime modifiche riesco a far cadere la pedina verso l'alto ma quest'ultima fa cumulo sovrapponendosi alle altre.
    Nessuno mi può aiutare ad evitare le sovrapposizioni?

+ Rispondi al Thread

Permessi di invio

  • Non puoi inserire discussioni
  • Non puoi inserire repliche
  • Non puoi inserire allegati
  • Non puoi modificare i tuoi messaggi