private StageDrawer SetupBorderDrawer(StageDrawerConfiguration playAreaConfig) { var config = new StageDrawerConfiguration() { Position = playAreaConfig.Position - new Vector2(StageDrawer.TileSize * playAreaConfig.Scale), Scale = playAreaConfig.Scale, }; return(new StageDrawer(config)); }
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 StageDrawer(StageDrawerConfiguration config) { Position = config.Position; Scale = config.Scale; }