private Stage SetupBorder(StageConfiguration playAreaConfig) { var config = new StageConfiguration() { Width = playAreaConfig.Width + 2, Height = playAreaConfig.Height + 2, }; var border = new Stage(config); // left and right wall. we're starting from 1 because we're not going to // add a top wall and so the top of the boundary aligns with the top of the // play area for (var y = 1; y < border.Height; y++) { border.SetCellColor(0, y, BlockColor.Gray); border.SetCellColor(border.Width - 1, y, BlockColor.Gray); } // bottom for (var x = 0; x < border.Width; x++) { border.SetCellColor(x, border.Height - 1, BlockColor.Gray); } return(border); }
public override void Initialize() { // initialize score _score = 0; // initialize gravity timer _gravityTimer = new Timer(0.5, true); _gravityTimer.OnTimeOut += GravityTick; // initialize the stage and its renderers var stageConfig = new StageConfiguration { Width = 10, Height = 20 }; _stage = new Stage(stageConfig); _preview = new Stage(stageConfig); _border = SetupBorder(stageConfig); var stageDrawerConfig = new StageDrawerConfiguration { Position = new Vector2(50, 50), Scale = 2f, }; _stageDrawer = new StageDrawer(stageDrawerConfig); _previewDrawer = new StageDrawer(stageDrawerConfig) { ColorMask = new Color(0.25f, 0.25f, 0.25f, 0.25f) }; _borderDrawer = SetupBorderDrawer(stageDrawerConfig); // initialize the next piece preview drawer var nextPieceConfig = new StageConfiguration { Width = 4, Height = 4 }; _nextPiece = new Stage(nextPieceConfig); var stageDrawEnd = _stageDrawer.Position + _stageDrawer.GetDrawDimensions(_stage); var nextPieceDrawerConfig = new StageDrawerConfiguration { Position = new Vector2(stageDrawEnd.X + 50, _stageDrawer.Position.Y), Scale = 2f, }; _nextPieceDrawer = new StageDrawer(nextPieceDrawerConfig); // initialize the random shape generator _randomGenerator = new RandomGenerator(); // initialize the first active tetromino and the next one CreateNewTetromino(); base.Initialize(); }
public Stage(StageConfiguration config) { _dimensions = new Vector2(config.Width, config.Height); InitializeBoard(); }