示例#1
0
        public override void Update(GameTime gameTime)
        {
            base.Update(gameTime);

            frameCounter++;

            if (frameCounter > 100)
            {
                this.pipes.Add(new Pipe());
                frameCounter = 0;
            }

            Boolean isGameOver = false;

            foreach (Pipe pipe in pipes.Objects)
            {
                if (bird.Position.Y > FlappyBird.Screen.Y || bird.Position.Y < 0 || bird.CollidesWith(pipe))
                {
                    isGameOver = true;
                }

                if (pipe.Position.X + pipe.Width < 0)
                {
                    this.pipes.Remove(pipe);
                    score.ScoreValue += 1;
                    break;
                }
            }

            if (isGameOver == true)
            {
                SetGameOver();
            }
        }
示例#2
0
        public override void Update(GameTime gameTime)
        {
            base.Update(gameTime);

            FrameCounter += 1;
            if (FrameCounter > 100)
            {
                this.pipes.Add(new Pipe());
                FrameCounter = 0;
            }

            Boolean IsGameOver = false;

            if (bird.Position.Y > FlappyBird.Screen.Y || bird.Position.Y < 0)
            {
                IsGameOver = true;
            }

            foreach (Pipe pipes in pipes.Objects)
            {
                if (bird.CollidesWith(pipes))
                {
                    IsGameOver = true;
                }

                if (pipes.Position.X + pipes.Width < bird.Width)
                {
                    score.ScoreValue++;
                }

                if (pipes.Position.X + pipes.Width < 0)
                {
                    this.pipes.Remove(pipes);
                    break;
                }
            }

            if (IsGameOver == true)
            {
                SetGameOver();
            }
        }