Exemplo n.º 1
0
        public void UpdateGame(int elapsedMilliseconds)
        {
            gamePhysics.Update(elapsedMilliseconds);
            if (gamePhysics.checkColision(test))
            {
                MessageBox.Show("You survived " + scoreWatch.ElapsedMilliseconds / 1000 + " seconds!\n\nChickenPanic will now close.", "Game Over", MessageBoxButton.OK);

                Application.Current.Terminate();
            }
            gameGenerator.UpdateObstacles(elapsedMilliseconds);
        }
Exemplo n.º 2
0
        private void addNormalObstacle()
        {
            double x      = resolution.Height;
            double y      = (double)new Random().Next(-200, -50);
            double width  = 50;
            double height = 300;

            /*
             * Rectangle representation = new Rectangle();
             * representation.Width = width;
             * representation.Height = height;
             * representation.Fill = new SolidColorBrush(Colors.Green);
             */

            double xSpeed = new Random().NextDouble() * -1;

            if (xSpeed > -0.5)
            {
                xSpeed = -0.5;
            }
            else if (xSpeed < -0.7)
            {
                xSpeed = -0.7;
            }

            double ySpeed = 0;
            double weight = 0;

            Obstacle obstacle1 = new Obstacle(x, y, width, height, xSpeed, ySpeed, weight, -1);

            obstacles.Add(obstacle1);
            physics.DynamicGraphicsList.Add(obstacle1);
            canvas.Children.Add(obstacle1.GetRepresentation());

            y += 500;
            Obstacle obstacle2 = new Obstacle(x, y, width, height, xSpeed, ySpeed, weight, 1);

            obstacles.Add(obstacle2);
            physics.DynamicGraphicsList.Add(obstacle2);
            canvas.Children.Add(obstacle2.GetRepresentation());

            physics.Update(0);
        }