Guest User

tetris

a guest
Sep 13th, 2015
109
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 1.00 KB | None | 0 0
  1. namespace WindowsFormsApplication1
  2. {
  3.     public class Block
  4.     {
  5.         int posy = 0;
  6.         int posx = 150;
  7.  
  8.         public void Form1_Paint(object sender, PaintEventArgs e)
  9.         {
  10.             posy += 20;
  11.             e.Graphics.FillRectangle(Brushes.Red, posx, posy, 20, 20);
  12.             e.Graphics.FillRectangle(Brushes.MediumOrchid, posx, posy - 20, 20, 20);
  13.         }
  14.     }    
  15.    
  16.     public partial class Form1 : Form
  17.     {
  18.         Block block = new Block();
  19.         Timer timer = new Timer();
  20.         int TimeCounter = 0;
  21.        
  22.         public Form1()
  23.         {
  24.             InitializeComponent();
  25.             timer.Interval = 1000;
  26.             timer.Tick += new EventHandler(timer_Tick);
  27.             timer.Start();
  28.         }
  29.  
  30.         public void timer_Tick(object sender, EventArgs e)
  31.         {
  32.             this.label1.Text = (++TimeCounter).ToString();
  33.             block.Form1_Paint(this, new PaintEventArgs(this.CreateGraphics(), this.Bounds));
  34.         }
  35.      
  36.     }
  37. }
Advertisement
Add Comment
Please, Sign In to add comment