Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- using System.Collections.Generic;
- using System.ComponentModel;
- using System.Data;
- using System.Drawing;
- using System.Linq;
- using System.Text;
- using System.Windows.Forms;
- namespace Kulka
- {
- public partial class Form1 : Form
- {
- int x = 0, y = 0;
- int vX = 20, vY = 20;
- public Form1()
- {
- InitializeComponent();
- }
- private void Form1_Paint(object sender, PaintEventArgs e)
- {
- Graphics g = e.Graphics;
- SolidBrush b = new SolidBrush(Color.Blue);
- g.FillEllipse(b, x, y, 80, 80);
- }
- private void timer1_Tick(object sender, EventArgs e)
- {
- x += vX;
- y += vY;
- if (y + 80 >= this.ClientRectangle.Height)
- {
- vY = -vY;
- }
- if (y <= 0)
- {
- vY = 20;
- }
- else if (x + 80 >= this.ClientRectangle.Width)
- {
- vX = -vX;
- }
- if (x <= 0)
- {
- vX = 20;
- }
- this.Invalidate();
- }
- }
- }
Add Comment
Please, Sign In to add comment