public override void Rotate() { if (rState == RotationState.first) { Brick1.Rect.Y -= 16; Brick1.Coordinate -= 10; Brick3.Rect.X += 16; Brick3.Rect.Y -= 16; Brick3.Coordinate -= 9; Brick4.Rect.X += 16; Brick4.Coordinate++; rState = RotationState.second; } else if (rState == RotationState.second) { if (MovementFunctions.BounderyCoordinate(Brick1.Coordinate) > 0 && MovementFunctions.LeftBounderyCollision(this)) { Brick1.Rect.Y += 16; Brick1.Coordinate += 10; Brick3.Rect.X -= 16; Brick3.Rect.Y += 16; Brick3.Coordinate += 9; Brick4.Rect.X -= 16; Brick4.Coordinate--; rState = RotationState.first; } } }
void blockRotation() { if (MovementFunctions.RotationCollision(block, grid)) { block.Rotate(); } }
public void countRow(int row, ref int rowCounter) { if (MovementFunctions.BlockCoordinateCount(row, Coordinate) && !IsCounted) { rowCounter++; IsCounted = true; } }
public override void Rotate() { if (rState == RotationState.second) { if (MovementFunctions.BounderyCoordinate(Brick2.Coordinate) > 0) { Brick1.Rect.X -= 16; Brick1.Rect.Y += 16; Brick1.Coordinate += 9; Brick3.Rect.Y -= 16; Brick3.Rect.X += 32; Brick3.Coordinate -= 8; Brick4.Rect.X += 16; Brick4.Coordinate++; rState = RotationState.first; } } else if (rState == RotationState.first) { Brick1.Rect.X += 16; Brick1.Rect.Y -= 16; Brick1.Coordinate -= 9; Brick3.Rect.Y -= 16; Brick3.Coordinate -= 10; Brick4.Rect.X -= 16; Brick4.Coordinate--; rState = RotationState.third; } else if (rState == RotationState.third) { if (MovementFunctions.BounderyCoordinate(Brick2.Coordinate) > 1) { Brick1.Rect.X -= 16; Brick1.Coordinate--; Brick3.Rect.Y += 16; Brick3.Rect.X -= 32; Brick3.Coordinate += 8; Brick4.Rect.X += 16; Brick4.Rect.Y -= 16; Brick4.Coordinate -= 9; rState = RotationState.fourth; } } else if (rState == RotationState.fourth) { Brick1.Rect.X += 16; Brick1.Coordinate++; Brick3.Rect.Y += 16; Brick3.Coordinate += 10; Brick4.Rect.X -= 16; Brick4.Rect.Y += 16; Brick4.Coordinate += 9; rState = RotationState.second; } }
public void Drop(GameGrid grid) { if (Brick4.Rect.Y != 298 && MovementFunctions.BlockDropCollision(this, grid)) { Brick1.Rect.Y += 16; Brick2.Rect.Y += 16; Brick3.Rect.Y += 16; Brick4.Rect.Y += 16; } }
void failState() { if (block.Brick1.Coordinate <= 10 && !MovementFunctions.BlockDropCollision(block, grid)) { enableMenus(true); menus.Current = "Game Over"; gameOver.Play(); saveHighScore(); updateHighScore(); } }
public void FillGridCells(GameGrid grid) { int i, j; MovementFunctions.CalculateCoordinates(Brick1.Coordinate, out i, out j); Brick1.fillGridCell(grid.GetCell(i, j)); MovementFunctions.CalculateCoordinates(Brick2.Coordinate, out i, out j); Brick2.fillGridCell(grid.GetCell(i, j)); MovementFunctions.CalculateCoordinates(Brick3.Coordinate, out i, out j); Brick3.fillGridCell(grid.GetCell(i, j)); MovementFunctions.CalculateCoordinates(Brick4.Coordinate, out i, out j); Brick4.fillGridCell(grid.GetCell(i, j)); }
public void Move(int movementNumber, GameGrid grid) { if (MovementFunctions.LeftBounderyCollision(this) && movementNumber < 0 && MovementFunctions.LeftSideCollision(this, grid)) { Brick1.Rect.X -= 16; Brick2.Rect.X -= 16; Brick3.Rect.X -= 16; Brick4.Rect.X -= 16; } if (MovementFunctions.RightBounderyCollision(this) && movementNumber > 0 && MovementFunctions.RightSideCollision(this, grid)) { Brick1.Rect.X += 16; Brick2.Rect.X += 16; Brick3.Rect.X += 16; Brick4.Rect.X += 16; } }
//This region contains the code for the main game update mehtod, fail state checking, and level setup and update. #region Update, Fail State, and Level Data void update(GameTime gameTime) { //If the block has reached the bootom or hit another block, check counter if (block.Brick4.Rect.Y == 298 || !MovementFunctions.BlockDropCollision(block, grid)) { //If the update counter reaches 30, convert current block to grid, get new block, and check rows if (updateCounter == 30) { gridFill(); //Converts the block to the grid block = preview; //Sets the preview block to the main block preview = randomize(); //Randomizes the next preview block setNormalbool = true; countRows(); //Conts the number of blocks in a row deleteBlocks(); //Deletes any full rows updateMultiplier(gameTime); //Updates the multiplier updateScore(gameTime); //Updates the score levelUpdate(gameTime); //Update the level updateCounter = 0; //Resets the counter } //Else update the counter else { updateCounter++; } } //Else update counters else { reduceMultiplier(gameTime); dropCounter++; accelCounter++; } movementCounter++; failState(); }