Example #1
0
        public Form1()
        {
            InitializeComponent();

            BlockSize = Sheet.Width / 10;

            Draft = new Bitmap(Sheet.Width, Sheet.Height);
            painter = new Painter(Draft, BlockSize, Sheet.Width, Sheet.Height);


            board = new Board(Sheet.Height / BlockSize, Sheet.Width / BlockSize);

            StartPoint = new Point(4 * BlockSize, 0);

            RandomBlock = rand.Next(0, 4);
            GetRandomBlock();
            RandomBlock = rand.Next(0, 4);
            RImage = DrawRandomBlock();

            Board.ArrivedAtBottom += Board_ArrivedAtBottom;



            timer1.Interval = 700;
            timer1.Enabled = false;

        }
Example #2
0
        public Controller(Painter painter, List<Piece> pieces, bool[,] scene)
        {
            this.painter = painter;
            this.pieces = pieces;
            this.scene = scene;

            timer = new Timer()
            {
                Interval = timerInterval
            };
            timer.Tick += new EventHandler(timer_Tick);

            GameOver += new GameOverEventHandler(Controller_GameOver);

            Reset();
        }
Example #3
0
        private void Form1_Load(object sender, EventArgs e)
        {
            System.Threading.Thread.CurrentThread.Name = "FormThread";

            this.pictureBox1.Width = Piece.BLOCK_WIDTH * 11;
            this.pictureBox1.Height = Piece.BLOCK_WIDTH * 20;
            this.ActiveControl = this.textBox2;

            m_painter = new Painter(this.pictureBox1);
            m_painter.Start();
            m_tetris = new Tetris();
            m_tetris.Stage.AddUpdateListener(OnUpdateCanvas);
            m_tetris.Updated += new TetrisUpdateDelegate(OnUpdateStatus);

            o = new KeyStateBackgroundWatcher(50, OnKeyDown, Keys.Down, Keys.Left, Keys.Right, Keys.S);
            o2 = new KeyStateBackgroundWatcher(150, OnKeyDown, Keys.Space);
            o.Watch();
            o2.Watch();
        }
Example #4
0
        public void Init()
        {
            painter = new Painter()
            {
                Interval = interval,
                SceneSize = sceneSize,
                StartPosition = new Point(padding, padding)
            };

            ChangePainter();
            panel1.BackColor = painter.BackgroundColor;

            bool[,] scene = new bool[sceneSize.Width, sceneSize.Height];

            painter.DrawScene();

            List<Piece> pieces = Piece.LoadFromFile(configFile);

            controller = new Controller(painter, pieces, scene);

            recorder = new Recorder(label4);
            controller.Eliminated += recorder.AddScores;
            controller.GameOver += new Controller.GameOverEventHandler(controller_GameOver);
        }
Example #5
0
        Bitmap DrawRandomBlock()
        {
            Bitmap RandomDraft = new Bitmap(RandomBSheet.Width, RandomBSheet.Height);
            Painter @Painter = new Painter(RandomDraft, BlockSize, RandomDraft.Width, RandomDraft.Height);

            int RandomPosition = rand.Next(0, 4);

            Color RColor = Color.FromArgb(40, 40, 40);

            Point Position = new Point(2 * BlockSize, 2 * BlockSize);

            switch(RandomBlock)
            {
                case 0:
                    t_block = new T_Block(RandomDraft, Position, RandomPosition, BlockSize);
                    t_block.Draw();
                    @Painter.DrawArea(RColor);
                    return RandomDraft;
                case 1:
                    square = new Square(RandomDraft, Position, BlockSize);
                    square.Draw();
                    @Painter.DrawArea(RColor);
                    return RandomDraft;
                case 2:
                    stick = new Stick(RandomDraft, Position, RandomPosition, BlockSize);
                    stick.Draw();
                    @Painter.DrawArea(RColor);
                    return RandomDraft;
                case 3:
                    z_block = new Z_Block(RandomDraft, Position, RandomPosition, BlockSize);
                    z_block.Draw();
                    @Painter.DrawArea(RColor);
                    return RandomDraft;
                default:
                    return RandomDraft;
            }
        }