Example #1
0
        private void PlayBlock(Tetris.Tiles sbBlock, Boolean isNew)
        {
            if (isNew)
            {    // create a new block
                sbBlock = game.Block.blocks_generation(game.Difficulty);
            }
            else
            {
                game.blocksMovements(pt_obj, scren_dimensions);
            }
            game.Block.Assign(sbBlock);
            game.Block.Build();
            game.Block.set_block_position(ref scren_dimensions);
            // draw the block in center-x, top-y
            pt_obj.x = (picField.Width / game.Block.Block_Width - scren_dimensions.width) / 2;
            pt_obj.y = 0;

            ShowNextBlock(isNew);
            picField.Invalidate();

            if (game.check_for_collision(pt_obj, scren_dimensions))
            {
                check_for_game_over = true;
                if (mnuGameSettingsSound.Checked)
                {
                    using (SoundPlayer player = new SoundPlayer("C:\\GameOver.wav"))
                    {
                        player.PlaySync();
                    }
                }
            }
        }