private void ConfigureNewPipe(PipeColumn pipe) { pipe.HorizontalPosition = screenWidth; pipe.GapStart = random.Next(screenHeight - gapSize); pipe.IsScored = false; while (pipes.Count > 0 && pipes.Peek().GapStart == pipe.GapStart) { pipe.GapStart = random.Next(screenHeight - gapSize); } }
private void GenerateNewPipe() { var pipe = new PipeColumn(); if (pipes.Count > maxPipes && pipes.Peek().HorizontalPosition < 0 - thickness) { pipe = pipes.Dequeue(); } ConfigureNewPipe(pipe); pipes.Enqueue(pipe); }