Tetris.Board.Initialize C# (CSharp) Method

Initialize() public method

public Initialize ( ) : void
return void
        public override void Initialize()
        {
            showNewBlock = true;
            movement = 0;
            speed = 0.1f;

            for (int i = 0; i < width; i++)
                for (int j = 0; j < height; j++)
                    ClearBoardField(i, j);
            
            base.Initialize();
        }

Usage Example

Ejemplo n.º 1
0
        /// <summary>
        /// LoadContent will be called once per game and is the place to load
        /// all of your content.
        /// </summary>
        protected override void LoadContent()
        {
            // Create a new SpriteBatch, which can be used to draw textures.
            spriteBatch = new SpriteBatch(GraphicsDevice);

            // Add the SpriteBatch service
            Services.AddService(typeof(SpriteBatch), spriteBatch);

            //Load 2D textures
            tetrisBackground = Content.Load <Texture2D> ("background");
            tetrisTextures   = Content.Load <Texture2D> ("tetris");

            // Load game font
            //gameFont = Content.Load<SpriteFont> ("font");
            gameFont = Content.Load <SpriteFont> ("Arial");

            // Create game field
            board = new Board(this, ref tetrisTextures, blockRectangles);
            board.Initialize();
            Components.Add(board);

            // Save player's score and game level
            score = new Score(this, gameFont);
            score.Initialize();
            Components.Add(score);

            // Load game record
            using (StreamReader streamReader = File.OpenText("record.dat")) {
                string player = null;
                if ((player = streamReader.ReadLine()) != null)
                {
                    score.RecordPlayer = player;
                }
                int record = 0;
                if ((record = Convert.ToInt32(streamReader.ReadLine())) != 0)
                {
                    score.RecordScore = record;
                }
            }
        }
All Usage Examples Of Tetris.Board::Initialize