Guest User

Untitled

a guest
Jan 19th, 2019
70
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.05 KB | None | 0 0
  1. Private Sub Timer1_Timer()
  2. enemy1.Left = enemy1.Left - 5
  3. End Sub
  4.  
  5. Private Sub Timer1_Timer()
  6. Do
  7. enemy1.Left = enemy1.Left - 5
  8. If enemy1.Left = < 5 Then
  9. Do
  10. enemy1.Right = enemy1.Right + 5
  11. Loop Until enemy1.Right = > 1000 'or whatever your size is
  12. End If
  13. Loop
  14. End Sub
  15.  
  16. Option Explicit
  17. Const nTwipsPerMove = 10
  18. Private Sub Timer1_Timer()
  19. Static strDirection As String
  20. If strDirection = "" Then strDirection = "left"
  21. If enemy.Left > 0 Then
  22. If strDirection = "left" Then
  23. enemy.Left = enemy.Left - nTwipsPerMove
  24. ElseIf strDirection = "right" Then
  25. enemy.Left = enemy.Left + nTwipsPerMove
  26. End If
  27. End If
  28. If enemy.Left = 0 Then
  29. If strDirection = "left" Then strDirection = "right"
  30. enemy.Left = enemy.Left + nTwipsPerMove
  31. End If
  32.  
  33. If enemy.Left + enemy.Width = Me.Width - nTwipsPerMove * 5 Then
  34. If strDirection = "right" Then strDirection = "left"
  35. enemy.Left = enemy.Left - nTwipsPerMove
  36. End If
  37. End Sub
Add Comment
Please, Sign In to add comment