public IGameState Update(InputStatifier inputStatifier) { frameTimer++; if (frameTimer >= framesPerStep) { if ((curPos <= -width + 1 && curDir == -1) || (curPos + 1 >= gameData.GridWidth && curDir == 1)) { curDir *= -1; } curPos += curDir; frameTimer = 0; } for (int x = 0; x < gameData.GridWidth; x++) { gameData.Gridje[x, gameData.CurrentRow] = x >= curPos && x < (curPos + width); } if (inputStatifier.UserDoesAction()) { return(new GravityState(gameData)); } return(this); }
public IGameState Update(InputStatifier inputStatifier) { framesDelay--; if (framesDelay <= 0 || inputStatifier.UserDoesAction()) { return(new PlayingState(new GameData())); } return(this); }
public IGameState Update(InputStatifier inputStatifier) { framesDelay--; if (framesDelay <= 0) { return(stateToActivate); } return(this); }
public IGameState Update(InputStatifier inputStatifier) { frameTimer++; if (frameTimer >= framesPerStep) { bool didSomething = false; for (int y = 1; y < gameData.GridHeight; y++) { for (int x = 0; x < gameData.GridWidth; x++) { if (gameData.Gridje[x, y] && !gameData.Gridje[x, y - 1]) { gameData.Gridje[x, y - 1] = true; gameData.Gridje[x, y] = false; didSomething = true; } } } if (!didSomething) { var blocksOnLastRow = BlocksOnLastRow(); if (blocksOnLastRow == 0) { //You loose return(new GameOver(gameData)); } else if (gameData.CurrentRow == gameData.GridHeight - 1) { //You win return(new YouWin(gameData)); } else { gameData.CurrentRow++; return(new DelayState(gameData, new PlayingState(gameData, blocksOnLastRow), 30)); } } frameTimer = 0; } return(this); }
public TheGame(IContentManagerExtension contentManagerExtension, IntSize?desiredScreenSize, Platform platform) : base() { _contentManagerExtension = contentManagerExtension; _desiredScreenSize = desiredScreenSize; _platform = platform; _graphics = new GraphicsDeviceManager(this); //This is required for Blazor since it loads assets in a custom way Content = new ExtendibleContentManager(this.Services, _contentManagerExtension); Content.RootDirectory = "Content"; IsMouseVisible = true; _inputStatifier = new InputStatifier(); _contentDistributionThing = new ContentDistributionThing(_graphics); _currentState = new NewGameState(); _platform = platform; _effectBlockDrawer = new EffectBlockDrawer(_contentDistributionThing); }