Exemple #1
0
        public static void Update()
        {
            //Determine whether the player tapped the screen
            var touches = Touch.GetData(0);

            //If tapped, inform the bird.
            if (touches.Count > 0)
            {
                bird.Tapped();
            }

            //Update the bird.
            bird.Update(0.0f);

            if (bird.Alive)
            {
                //Move the background.
                background.Update(0.0f);

                //Update the obstacles.
                foreach (Obstacle obstacle in obstacles)
                {
                    obstacle.Update(0.0f);
                }
            }
        }
Exemple #2
0
        public static void Update()
        {
            //Determine whether the player tapped the screen.
            var touches = Touch.GetData(0);

            //If tapped, inform the bird.
            if (touches.Count > 0)
            {
                bird.Tapped();
            }

            // timer that decreases air supply of bird by one every 2 seconds.
            if (airLoss.Seconds() > 2)
            {
                air--;
                airLabel.Text = "Air: " + air.ToString();
                airLoss.Reset();
            }

            //Update the bird.
            bird.Update(0.0f);

            //Update the bubble.
            foreach (Bubble b in bubble)
            {
                b.Update(0.0f);
            }

            if (bird.Alive)
            {
                //Move the background.
                background.Update(0.0f);

                //Update chains and mines.
                for (int i = 0; i < OBSTACLE_COUNT; i++)
                {
                    chain[i].Update(0.0f);
                    seamine[i].SetPosition((chain[i].GetX - 60), (chain[i].GetY + chain[i].GetMaxY) - 20);
                    seamine[i].Update(0.0f);
                }
            }

            Collision();
        }
        public static void Update()
        {
            //Determine whether the player tapped the screen
            var touches = Touch.GetData(0);

            if (Director.Instance.CurrentScene == startScene)
            {
                scoreLabel.Text = "Touch to start";


                if (touches.Count > 0 && !keyPressed)
                {
                    Touch.GetData(0).Clear();
                    Director.Instance.ReplaceScene(gameScene);
                    keyPressed = true;
                }
            }
            else if (Director.Instance.CurrentScene == gameScene)
            {
                //If tapped, inform the bird.
                if (touches.Count > 0)
                {
                    bird.Tapped();
                }

                //Update the bird.
                bird.Update(0.0f);

                if (bird.Alive)
                {
                    //Move the background.
                    background.Update(0.0f);

                    //Update the obstacles.
                    foreach (Obstacle obstacle in obstacles)
                    {
                        obstacle.Update(0.0f);
                    }
                    foreach (Obstacle obstacle in obstacles)
                    {
                        if (obstacle.HasCollidedWith(bird.Sprite))
                        {
                            bird.Alive        = false;
                            bird.Sprite.Color = Colors.Black;
                        }
                        if (obstacle.HasPassed(bird.Sprite))
                        {
                            score++;
                        }
                    }
                    scoreLabel.Text = "" + score;
                }
                if (!bird.Alive)
                {
                    Director.Instance.ReplaceScene(endScene);
                }
            }
            else if (Director.Instance.CurrentScene == endScene)
            {
                scoreLabel.Text = "You dead";
                score           = 0;
                bird.reset();
                bird.Sprite.Color = Colors.White;

                obstacles[0].reset(Director.Instance.GL.Context.GetViewport().Width *0.5f);
                obstacles[1].reset(Director.Instance.GL.Context.GetViewport().Width);

                if (touches.Count > 0 && !keyPressed)
                {
                    Director.Instance.ReplaceScene(startScene);
                    keyPressed = true;
                }
            }
            if (touches.Count == 0 && keyPressed)
            {
                keyPressed = false;
            }
        }