Advertisement
Guest User

Untitled

a guest
Apr 27th, 2018
66
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.67 KB | None | 0 0
  1. bool patrollingLeft = false;
  2. DoubleBuffered = true;
  3. bool stay = false;
  4. long ticksThisTime = 0;
  5. Stopwatch timer = new Stopwatch();
  6. timer.Start();
  7.  
  8.  
  9. float t = 2;
  10. float s = 625;
  11.  
  12. float time = 0;
  13. while (true)
  14. {
  15. timer.Stop();
  16. label1.Text = time.ToString();
  17. ticksThisTime = timer.ElapsedMilliseconds;
  18. time = time + ticksThisTime / 1000.0F;
  19. timer.Reset();
  20. timer.Start();
  21. if (patrollingLeft && stay == false)
  22. {
  23. x = x - (s / t) * (ticksThisTime / 1000.0F);
  24. if (x <= 125)
  25. {
  26. patrollingLeft = false;
  27. time = 0;
  28. stay = true;
  29. }
  30. }
  31.  
  32. else if (patrollingLeft == false && stay == false)
  33. {
  34. x = x + (s / t) * (ticksThisTime / 1000.0F);
  35. if (x >= 750)
  36. {
  37. patrollingLeft = true;
  38. time = 0;
  39. stay = true;
  40. }
  41. }
  42.  
  43. else if (stay == true && time > 4)
  44. {
  45. stay = false;
  46. }
  47. gr.FillRectangle(fon, 0, 0, pictureBox1.Width, pictureBox1.Height);
  48. DrawCircle(x, y);
  49. Application.DoEvents();
  50. pictureBox1.Image = myBitmap;
  51. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement