public void UpdateGrid() { if (timer > 0) { timer -= 0.5f; } else { Color color = activeBlock.getColor(); Vector2 activeBlockPosition = activeBlock.getLocation(); bool[,] blockArray = activeBlock.Read(); bool blockHit = checkBlockOnBlockCollision() || checkVerticalBoundCollision(); if (blockHit) { //create new active activeBlock //add 10 points to pointbuffer activeBlock = nextBlock; nextBlock = blockSelector.SelectNextBlock(random.Next(0, 7)); activeBlock.setLocation(new Vector2(4, 0)); pointbuffer.Add(10); //check if the game is over if (activeBlockPosition.Y == 0 && checkBlockOnBlockCollision()) { gameover = true; } //put the old activeblock into the grid for (int i = 0; i < 4; i++) { for (int j = 0; j < 4; j++) { if (blockArray[i, j]) { grid[i + (int)activeBlockPosition.Y, j + (int)activeBlockPosition.X] = color; } } } //index full rows indexFullRows(); //move rows down if a row has been cleared cascadeRows(); } else { moveTetrisBlock(input, ref activeBlock, activeBlockPosition); } timer = timerLength; } }