Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- namespace WindowsFormsApplication1
- {
- public class Block
- {
- int posy = 0;
- int posx = 150;
- public void Form1_Paint(object sender, PaintEventArgs e)
- {
- posy += 20;
- e.Graphics.FillRectangle(Brushes.Red, posx, posy, 20, 20);
- e.Graphics.FillRectangle(Brushes.MediumOrchid, posx, posy - 20, 20, 20);
- }
- }
- public partial class Form1 : Form
- {
- Block block = new Block();
- Timer timer = new Timer();
- int TimeCounter = 0;
- public Form1()
- {
- InitializeComponent();
- timer.Interval = 1000;
- timer.Tick += new EventHandler(timer_Tick);
- timer.Start();
- }
- public void timer_Tick(object sender, EventArgs e)
- {
- this.label1.Text = (++TimeCounter).ToString();
- block.Form1_Paint(this, new PaintEventArgs(this.CreateGraphics(), this.Bounds));
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment