Foro de elhacker.net

Programación => Programación Visual Basic => Mensaje iniciado por: reeyesg en 16 Junio 2015, 21:28 pm



Título: Ayuda con movimientos de imagenes
Publicado por: reeyesg en 16 Junio 2015, 21:28 pm
Hola bnas tardes quisiera una pequeña ayuda cn mi progrma q es una simulacion de cajeros de una clinica

quisiera que cuando la imagen1 llegue a la posicion de las otras 3 imagenes ellas suban pero claro el image1 q regrese a su posicion inicial aqui lo q he hecho

Código
  1. Dim cont As Integer
  2. Dim contc As Integer
  3.  
  4. Private Sub Command1_Click()
  5. Dim num As Integer
  6. Randomize
  7. num = Int((3) * Rnd + 1)
  8. Text7.Text = num
  9. cont = 0
  10. Timer1.Enabled = True
  11. Timer1.Interval = 1000
  12.  
  13.  
  14. tiempo = InputBox("Escriba el tiempo de Simulacion", "Simulacion de Clinica")
  15. Label7.Caption = tiempo
  16. End Sub
  17.  
  18. Private Sub Timer1_Timer()
  19.  
  20.  
  21.  
  22. Select Case Val(Text7.Text)
  23.  
  24.   Case 1:
  25.   Image1.Left = Image1.Left - 20
  26.   If (Image1.Left = -3480) Then
  27.       Image2.Top = Image2.Top + 20
  28. End If
  29. Case 2:
  30.   Image1.Left = Image1.Left - 20
  31.   If (Image1.Left = 2160) Then
  32.       Image3.Top = Image2.Top + 20
  33. End If
  34. Case 3:
  35.   Image1.Left = Image1.Left - 20
  36.   If (Image1.Left = 840) Then
  37.       Image2.Top = Image2.Top + 20
  38. End If
  39.  End Select
  40.  

el boton q esta en la parte de arriba solo es referencia q ahi van ·cajeros, porfa una ayudita

(http://i61.tinypic.com/54g18m.jpg)


Título: Re: Ayuda con movimientos de imagenes
Publicado por: Jacknori en 16 Junio 2015, 22:57 pm
reyeesg el movimiento de la imagen 1 es vectorial, asi que para que vuelva a su sitio debes restar el módulo de la imagen 1 en la posicion final entre la inicial. Es decir, tienes que restar a la posicion después de haberse movido de la imagen 1 su posicion al principio, cuando no se ha movido.
El resultado es a distancia que ha recorrido la imaagen1, lo cual se lo vueles a restar a la posicion final para que te de su posicion antes de moverse por ultima vez.
Despues que la imagen se haya cambiado de posicion, la mueves al principio de esa manera


Título: Re: Ayuda con movimientos de imagenes
Publicado por: reeyesg en 17 Junio 2015, 17:43 pm
Código
  1. Private Sub Command1_Click()
  2. Dim num As Integer
  3.  
  4. Randomize
  5. num = Int((3) * Rnd + 1)
  6. Text1.Text = num
  7.  
  8. Timer1.Enabled = True
  9. Timer1.Interval = 300
  10.  
  11. tiempo = InputBox("Escriba el tiempo")
  12. Label1.Caption = tiempo
  13.  
  14.  
  15. End Sub
  16.  
  17.  
  18. Private Sub Label1_Change()
  19. 'contador de clientes
  20. Select Case (num)
  21. Case 1:
  22. If Image1.Left = 5000 Then
  23. Label2.Caption = Label2 + 1
  24. Image1.Left = 7000
  25. End If
  26. Case 2:
  27. If Image1.Left = 3000 Then
  28. Label2.Caption = Label2 + 1
  29. Image1.Left = 7000
  30. End If
  31.  
  32. Case 3:
  33. If Image1.Left = 1000 Then
  34. Label2.Caption = Label2 + 1
  35. Image1.Left = 7000
  36. End If
  37. End Select
  38.  
  39. End Sub
  40.  
  41.  
  42. Private Sub Label2_Change()
  43.  
  44. If Image1.Left = 5000 Then
  45. Randomize
  46. num = Int((3) * Rnd + 1)
  47. Text1.Text = num
  48. End If
  49.  
  50. If Image1.Left = 3000 Then
  51. Randomize
  52. num = Int((3) * Rnd + 1)
  53. Text1.Text = num
  54. End If
  55.  
  56. If Image1.Left = 1000 Then
  57. Randomize
  58. num = Int((3) * Rnd + 1)
  59. Text1.Text = num
  60. End If
  61.  
  62. End Sub
  63.  
  64.  
  65.  
  66. Private Sub Timer1_Timer()
  67.  
  68. Label1.Caption = Label1.Caption - 1
  69. Image1.Left = Image1.Left - 100
  70.  
  71. Select Case (num)
  72. Case 1:
  73.  If Image1.Left = -5000 Then
  74.      Image2.Visible = True
  75.      Image1.Left = Image1.Left - 100
  76.      ElseIf Image2.Visible = True Then
  77.      Image1.Left = -7000
  78. End If
  79.  
  80. Case 2:
  81.  
  82.  
  83.  If Image1.Left = -3000 Then
  84.      Image3.Visible = True
  85.      Image1.Left = Image1.Left - 100
  86.      ElseIf Image3.Visible = True Then
  87.      Image1.Left = -7000
  88. End If
  89.  
  90.  Case 3:
  91.  If Image1.Left = -1000 Then
  92.      Image4.Visible = True
  93.      Image1.Left = Image1.Left - 100
  94.      ElseIf Image4.Visible = True Then
  95.      Image1.Left = -7000
  96. End If
  97.  
  98. End Select
  99.  
  100.  
  101. End Sub

Ve la imagen1 es la inicial esta en la posicion 7000
imagen 2=5000
imagen 3=3000
imagen 4= 1000

ahi me enrede ya, :s no pedo hacer q me funcione al pelo porq la idea q tengo es q cuando este visible las imagenes 2,3 y 4 en el otro timer meterle lo del movimieento para q suban a los cajeros, una vez en los cajeros debo hacerle otra cosa aleatoria para q genere aleatoriamente tipo de cliente(regular o preferencia) tipo de poliza( particular, por seguro o exonerado)