Guest User

Untitled

a guest
May 24th, 2018
100
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.17 KB | None | 0 0
  1. using System;
  2. using System.Collections.Generic;
  3. using System.ComponentModel;
  4. using System.Data;
  5. using System.Drawing;
  6. using System.Linq;
  7. using System.Text;
  8. using System.Windows.Forms;
  9.  
  10. namespace Kulka
  11. {
  12. public partial class Form1 : Form
  13. {
  14. int x = 0, y = 0;
  15. int vX = 20, vY = 20;
  16.  
  17.  
  18. public Form1()
  19. {
  20. InitializeComponent();
  21. }
  22.  
  23. private void Form1_Paint(object sender, PaintEventArgs e)
  24. {
  25. Graphics g = e.Graphics;
  26. SolidBrush b = new SolidBrush(Color.Blue);
  27. g.FillEllipse(b, x, y, 80, 80);
  28. }
  29.  
  30. private void timer1_Tick(object sender, EventArgs e)
  31. {
  32. x += vX;
  33. y += vY;
  34.  
  35.  
  36. if (y + 80 >= this.ClientRectangle.Height)
  37. {
  38. vY = -vY;
  39. }
  40. if (y <= 0)
  41. {
  42. vY = 20;
  43. }
  44. else if (x + 80 >= this.ClientRectangle.Width)
  45. {
  46. vX = -vX;
  47. }
  48. if (x <= 0)
  49. {
  50. vX = 20;
  51. }
  52.  
  53. this.Invalidate();
  54. }
  55. }
  56. }
Add Comment
Please, Sign In to add comment