hola necesito ayuda con este ejercicio tngo que hacer que rebote por las 4 paredes pero solo logro hacer que rebote derecho
esto es lo que he echo
Private Sub Form_KeyPress(KeyAscii As Integer)
'Print "tecla:"; Chr$(KeyAscii)
'Print "valor"; KeyAscii
If KeyAscii = 119 And Shape1.Top > 100 Then
Shape1.Top = Shape1.Top - 100
End If
If KeyAscii = 120 And Shape1.Top < 8900 Then
Shape1.Top = Shape1.Top + 100
End If
If KeyAscii = 56 And Shape2.Top > 100 Then
Shape2.Top = Shape2.Top - 100
End If
If KeyAscii = 50 And Shape2.Top < 8800 Then
Shape2.Top = Shape2.Top + 100
End If
If KeyAscii = 115 Then
Shape1.Height = Shape1.Height - 50
Shape1.Top = Shape1.Top - 25
End If
If KeyAscii = 97 Then
Shape1.Height = Shape1.Height + 50
Shape1.Top = Shape1.Top + 25
End If
If KeyAscii = 53 Then
Shape2.Height = Shape2.Height - 50
Shape2.Top = Shape2.Top - 25
End If
If KeyAscii = 48 Then
Shape2.Height = Shape2.Height + 50
Shape2.Top = Shape2.Top + 25
End If
End Sub
Private Sub Timer1_Timer()
Randomize
x = Int(Rnd(30) * 20)
If i = 0 Then
Shape3.Left = Shape3.Left + (x * 10)
Else
Shape3.Left = Shape3.Left - (x * 10)
End If
If Shape3.Left < 100 Then
i = 1
End If
If Shape3.Left > 18378 Then
i = 1
End If
If Shape3.Left - 495 <= Shape1.Left And Shape3.Top > Shape1.Top And Shape3.Top < Shape1.Top + 1815 Then
i = 0
End If
End Sub