fork download
  1. Imports System
  2.  
  3. Public Class Main
  4.  
  5. Shared oX As Single = 30 'origin x'
  6. Shared oY As Single = 40 'origin y'
  7.  
  8. Shared dX As Single = 100 'destination x'
  9. Shared dY As Single = 100 'destination y'
  10.  
  11. Shared cX As Single 'current x'
  12. Shared cY As Single 'current y'
  13.  
  14. Shared CurTimeMs As Integer = 0
  15. Shared TargetTimeMs As Integer = 10000 'the longer the target time, the more time it will take'
  16.  
  17. Shared Steps As Integer = 10 'The more steps there are the smoother the movement will be'
  18.  
  19. Public Shared Sub Main()
  20. cX = oX
  21. cY = oY
  22. System.Console.WriteLine("x " + cX.ToString() + ", y " + cY.ToString())
  23. While CurTimeMs < TargetTimeMs 'while we havent reached TT yet...'
  24. 'it might be worth sleeping the thread here for TT/steps ms,'
  25. 'or using a timer instead of the loop'
  26. CurTimeMs += TargetTimeMs / Steps 'add TT/steps to CT'
  27. cX = UpdateLocation(oX, dX, CurTimeMs / TargetTimeMs) 'update x'
  28. cY = UpdateLocation(oY, dY, CurTimeMs / TargetTimeMs) 'update y'
  29. System.Console.WriteLine("x " + cX.ToString() + ", y " + cY.ToString())
  30. End While
  31. End Sub
  32.  
  33. Public Shared Function UpdateLocation(ByVal Origin As Single, ByVal Destination As Single, ByVal Time As Single) As Single
  34. Return (Origin + (Destination - Origin) * Time)
  35. End Function
  36. End Class
Success #stdin #stdout 0.08s 13480KB
stdin
Standard input is empty
stdout
x 30, y 40
x 37, y 46
x 44, y 52
x 51, y 58
x 58, y 64
x 65, y 70
x 72, y 76
x 79, y 82
x 86, y 88
x 93, y 94
x 100, y 100