public void addToGrid(TetBlock block) { int x, y; foreach(TetSquare boundingSquare in block.boundingBox){ if(boundingSquare.isFilled) { Vector2 blockPos = boundingSquare.squarePosition; x = (int)blockPos.X / 30; y = (int)blockPos.Y / 30; try { tetBoard[y][x].isFilled = true; } catch(IndexOutOfRangeException i) { //empty catch } } } }
//checks if a block has been spawned, and if not, spawns one and shifts focus to it public void spawnBlock(GameTime gameTime) { elapsedTime += (float)gameTime.ElapsedGameTime.TotalMilliseconds; if(!blockSpawned) { currBlock = blockFactory.spawnBlock(); blockList.Add(currBlock); blockSpawned = true; } }