document.write('
Data hosted with ♥ by Pastebin.com - Download Raw - See Original
  1. \' Gambas class file
  2.  
  3. Private colaDeshacer As New Comando[]
  4. Private colaRehacer As New Comando[]
  5. Private bandera As Integer \'movimiento pos inicial, 2 indica movimiento pos final, 3 significa que va a insertar vallas
  6. Private tab As New Tablero
  7.  
  8. Public Struct animal
  9.   icono As String
  10.   p As Point
  11. End Struct
  12. \'para usar una estructura antes debe de estar definida
  13.  
  14. Public animaltmp As Animal
  15.  
  16. Public Sub _new()
  17.  
  18. End
  19.  
  20. Public Sub Form_Open()
  21.  
  22.   Randomize
  23.   bandera = 1
  24.   Me.center
  25.   tab.AreaDibujo = DrawingArea1
  26.   tab.dibujalista()
  27.   TextLabelMensaje.text = "Mensaje: Haga click en algun animal, y muevelo a otra posicion"
  28.  
  29. End
  30.  
  31. Public Sub DrawingArea1_MouseDown()
  32.  
  33.   Dim movtemp As Mover
  34.   Dim insertatmp As Insertar
  35.  
  36.   Select Case bandera
  37.     Case 2
  38.        \'con la coordenada obtenida, crea la orden "mover" y la ejecuta
  39.       \'veo si existe algun animal en la posicion nueva...
  40.       If tab.busca(Mouse.x \\ 40, Mouse.y \\ 40) <> Null Then
  41.         \'existe un animal en esa posicion
  42.       Else
  43.         ListBoxDeshacer.Add("Mover " & Replace(animaltmp.icono, ".png", "") & " (" & Str$(animaltmp.p.x) & "," & Str$(animaltmp.p.y) & " a " & Str$(Mouse.x \\ 40) & "," & Str(Mouse.y \\ 40) & ")")
  44.        
  45.         \'hago el movimiento
  46.        
  47.         movtemp = New Mover(tab, animaltmp.p.X, animaltmp.p.y, Mouse.x \\ 40, Mouse.y \\ 40)
  48.         movtemp.ejecutar()
  49.         colaDeshacer.add(movtemp)
  50.        
  51.         colaRehacer.clear()
  52.        
  53.         ListBoxRehacer.Clear()
  54.        
  55.         animaltmp = Null
  56.         bandera = 1
  57.       Endif
  58.      
  59.       Return
  60.  
  61.     Case 1
  62.      
  63.       animaltmp = tab.busca(Mouse.x \\ 40, Mouse.y \\ 40)
  64.       If animaltmp = Null Then
  65.         Print "no encuntro nada"
  66.       Else
  67.         Print animaltmp.icono
  68.         bandera = 2
  69.       Endif
  70.      
  71.     Case 3
  72.       insertatmp = New Insertar(tab, Mouse.x \\ 40, Mouse.y \\ 40)
  73.       insertatmp.ejecutar()
  74.       colaDeshacer.Add(insertatmp)
  75.       ListBoxDeshacer.Add("insertado valla en x:" & Str$(Mouse.x \\ 40) & " y:" & Str(Mouse.y \\ 40))
  76.       colaRehacer.Clear()
  77.       ListBoxRehacer.Clear()
  78.   End Select    
  79.  
  80. End
  81.  
  82. Public Sub ToolButtonDeshacer_Click()
  83.  
  84.   Dim operacion As Comando
  85.  
  86.   If colaDeshacer.max > -1 Then
  87.     operacion = colaDeshacer.Pop()
  88.     operacion.deshacer()
  89.     colaRehacer.Push(operacion)
  90.    
  91.     \'lista donde se muestran las juegadas
  92.     \'pongo el cursor en la ultima linea
  93.     ListBoxDeshacer.Index = ListBoxDeshacer.count - 1
  94.     \'lo aƱado a la lista de rehacer
  95.     ListBoxRehacer.Add(ListBoxDeshacer.text)
  96.     \'lo borro de la lista de deshacer
  97.     ListBoxDeshacer.Remove(ListBoxDeshacer.count - 1)
  98.    
  99.   Else
  100.     Message.Info("No hay nada que deshacer")
  101.   Endif
  102.  
  103. End
  104.  
  105. Public Sub ToolButtonRehacer_Click()
  106.  
  107.   Dim operacion As Comando
  108.  
  109.   If colaRehacer.max > -1 Then
  110.     operacion = colaRehacer.Pop()
  111.    
  112.     operacion.ejecutar()
  113.    
  114.     colaDeshacer.Add(operacion)
  115.     \'listas
  116.     ListBoxRehacer.Index = ListBoxRehacer.count - 1
  117.     ListBoxDeshacer.Add(ListBoxRehacer.text)
  118.     ListBoxRehacer.Remove(ListBoxRehacer.count - 1)
  119.    
  120.   Else
  121.     Message.Info("No hay nada que rehacer")
  122.   Endif
  123.  
  124. End
  125.  
  126. Public Sub ToolButtonInsertar_Click()
  127.  
  128.   bandera = 3
  129.   TextLabelMensaje.Text = "Mensaje: Inserta una valla"
  130.  
  131. End
  132.  
  133. Public Sub ToolButtonMover_Click()
  134.  
  135.   bandera = 1
  136.   TextLabelMensaje.text = "Mensaje: Haga click en algun animal, y muevelo a otra posicion"
  137.  
  138. End
');