Exemple #1
0
        protected override void Update(GameTime gameTime)
        {
            if (started)
            {
                if (!player.alive)
                {
                    Platform.z_position    = 0;
                    Platform.last_platform = new int[, ] {
                        { -1, 0 }, { -1, 0 }, { -1, 0 }, { -1, 0 }, { -1, 0 }
                    };
                    Platform.next_platform = new int[, ] {
                        { 1, 0 }, { 1, 0 }, { 1, 0 }, { 1, 0 }, { 1, 0 }
                    };

                    Platform.standing_platform      = null;
                    Platform.next_standing_platform = null;
                    SetGameObjects();
                    started = false;
                    mainPage.EndGame(score);
                }
                else
                {
                    lightManager.Update();
                    keyboardState = keyboardManager.GetState();
                    flushAddedAndRemovedGameObjects();

                    // pass gameTime to let camera move along
                    camera.Update(gameTime, player.pos);

                    accelerometerReading = input.accelerometer.GetCurrentReading();

                    for (int i = 0; i < gameObjects.Count; i++)
                    {
                        gameObjects[i].Update(gameTime);
                    }

                    // Update score board on the game page
                    mainPage.UpdateScore(score);

                    // Update camera and player position for testing
                    mainPage.DisplayCameraPlayerPos(camera.Position, camera.cameraPos, player.pos, player.max_speed);
                    mainPage.UpdateShootButton(player.fireOn);

                    if (keyboardState.IsKeyDown(Keys.Escape))
                    {
                        this.Exit();
                        this.Dispose();
                        App.Current.Exit();
                    }
                    // Handle base.Update
                }
            }
            base.Update(gameTime);
        }
Exemple #2
0
        protected override void Update(GameTime gameTime)
        {
            if (started && !paused)
            {
                keyboardState = keyboardManager.GetState();
                flushAddedAndRemovedGameObjects();
                if (tilt)
                {
                    accelerometerReading = input.accelerometer.GetCurrentReading();
                }
                camera.Update();
                light.Update(gameTime);
                for (int i = 0; i < gameObjects.Count; i++)
                {
                    gameObjects[i].Update(gameTime);
                }

                mainPage.UpdateScore(score1, score2);
                if (score1 >= winScore)
                {
                    mainPage.GameOverPage(1);
                }
                if (score2 >= winScore)
                {
                    mainPage.GameOverPage(2);
                }

                if (keyboardState.IsKeyDown(Keys.Escape))
                {
                    this.Exit();
                    this.Dispose();
                    App.Current.Exit();
                }
                // Handle base.Update
            }
            base.Update(gameTime);
        }