Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System.Numerics;
- using Raylib_cs;
- namespace FlappyBird;
- public class PipeManager
- {
- private const int pipeWidth = 80;
- private const int spawnInterval = 90;
- private int frameCounter;
- private Color pipeColor;
- private bool passed;
- public List<Pipe> Pipes { get; private set; }
- public PipeManager()
- {
- pipeColor = Color.Green;
- Pipes = new List<Pipe>();
- frameCounter = 0;
- }
- private void AddPipe()
- {
- int pipeGap = Raylib.GetRandomValue(150, 250);
- int pipeHeight =
- Raylib.GetRandomValue(100, Game.screenHeight - pipeGap - 100);
- Vector2 pipePosition = new Vector2(Game.screenWidth, 0);
- var pipe = new Pipe(pipePosition, pipeWidth, pipeHeight, pipeGap, pipeColor);
- Pipes.Add(pipe);
- }
- public void Update()
- {
- frameCounter++;
- if (frameCounter >= spawnInterval)
- {
- AddPipe();
- frameCounter = 0;
- }
- for (int i = 0; i < Pipes.Count; i++)
- {
- Pipes[i].Update();
- if (Pipes[i].IsOffScreen())
- {
- Pipes.RemoveAt(i);
- }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement