Ejemplo n.º 1
0
        /// <summary>
        /// Updates the state of the game. This method checks the GameScreen.IsActive
        /// property, so the game will stop updating when the pause menu is active,
        /// or if you tab away to a different application.
        /// </summary>
        public override void Update(GameTime gameTime, bool otherScreenHasFocus,
            bool coveredByOtherScreen)
        {
            //BEGIN NEW XBOX LIVE GamerPicture code etc
            //You just need to get the GamerCard info if you don't have it already
            if (gamer == null && SignedInGamer.SignedInGamers.Count > 0)
            {
                //Get info for the 1st player
                gamer = SignedInGamer.SignedInGamers[0];
                profile = gamer.GetProfile();
                //place to draw the gamer picture (in the middle of the screen)
                GamerPictureRectangle = new Rectangle(
                                30,
                                150,
                                64,
                                64
                              );
                //place to write some info
                gamerTagVector = new Vector2(GamerPictureRectangle.X, 0);
            }
            //END NEW XBOX LIVE GamerPicture code etc
            //Get the current state of the keyboard (what keys are and are not being pressed)
            KeyboardState aKeyboard = Keyboard.GetState();
            if (aKeyboard.IsKeyDown(Keys.P))
            {
                //pause the game
                paused = !paused;

            }

            if (paused)
            {

            }
            else
            {
                CheckForRumble(gameTime);

                // TODO: Add your update logic here
                //The time since Update was called last
                float elapsed = (float)gameTime.ElapsedGameTime.TotalSeconds;

                //Update the game objects

                //Lets rotate both ways
                //Only Math.PI / 2( one quarter turn)
                const float quarterturn = (float)Math.PI / 2;

                if (rotation < quarterturn)
                {
                    // The grid is currently rotateing
                    // Just Draw
                }
                else
                    if (rotation > Math.PI / 2 && rotation_direction != 0)
                    {//Rotation completed
                        if (rotation_direction > 0) mPlayfield.Rotate_Grid();
                        else mPlayfield.Rotate_Grid_Clockwise();
                        rotation_direction = 0;
                        rotation = 3.14f;
                    }
                    else
                        if (mPlayfield.CheckCollision(mCurrentShape) == true && mCurrentShape.PositionY < 4)
                        {
                        gameover = true;
                        SaveHighScore();
                        }
                        else
                            UpdateGameObjects(elapsed, aKeyboard);

                base.Update(gameTime, otherScreenHasFocus, coveredByOtherScreen);

                if (IsActive)
                {

                }
            }
        }
Ejemplo n.º 2
0
        /// <summary>
        /// Updates the state of the game. This method checks the GameScreen.IsActive
        /// property, so the game will stop updating when the pause menu is active,
        /// or if you tab away to a different application.
        /// </summary>
        public override void Update(GameTime gameTime, bool otherScreenHasFocus,
            bool coveredByOtherScreen)
        {
            //BEGIN NEW CODE
            //You just need to get the GamerCard info if you don't have it already
            if (gamer == null && SignedInGamer.SignedInGamers.Count > 0)
            {
                //Get info for the 1st player
                gamer = SignedInGamer.SignedInGamers[0];
                profile = gamer.GetProfile();
                //place to draw the gamer picture (in the middle of the screen)
                GamerPictureRectangle = new Rectangle(
                                30,
                                150,
                                64,
                                64
                              );
                //place to write some info
                gamerTagVector = new Vector2(GamerPictureRectangle.X, 0);
            }
            //END NEW CODE

            Players[1].Update(gameTime);
            Players[0].Update(gameTime);
            Players[2].Update(gameTime);
            Players[3].Update(gameTime);

            //=======OLD CODE HERE===============
               // CheckForRumble(gameTime);

            // TODO: Add your update logic here
            //The time since Update was called last
             elapsed = (float)gameTime.ElapsedGameTime.TotalSeconds;

              //  //Get the current state of the keyboard (what keys are and are not being pressed)
              //  KeyboardState aKeyboard = Keyboard.GetState();

            /*
                    if (mPlayfield.CheckCollision(mCurrentShape) == true && mCurrentShape.PositionY < 4)
                    {//gameover}}
                        gameover = true;
                    }
                    else
                        UpdateGameObjects(elapsed);
            */
            //==========OLD CODE END HERE===================

            base.Update(gameTime, otherScreenHasFocus, coveredByOtherScreen);
        }
Ejemplo n.º 3
0
        public PlayerHUD( Player player, SignedInGamer gamer )
        {
            GameplayScreen screen = player.Screen;

              if ( gamer != null )
              {
            profile = gamer.GetProfile();
            Name = gamer.Gamertag;
              }
              else Name = "CPU";

              Player = player;
              Score = 0;
              Boost = 1f;

              Rectangle safeRect = ScreenRects.SafeRegion;

              screenScale = GameCore.Instance.GraphicsDevice.Viewport.Height / 1080f;
              float ss = screenScale;

              // base hud object
              hudCageTexture = screen.Content.Load<Texture2D>( "Textures/playerHUDCage" );
              hudTexture = screen.Content.Load<Texture2D>( "Textures/playerHUD" );
              int hudWidth  = (int)( hudTexture.Width * screenScale );
              int hudHeight = (int)( hudTexture.Height * screenScale );

              int x0 = xPadding + safeRect.X + Player.PlayerNumber * ( safeRect.Width - hudWidth - 2 * xPadding ) / 3;
              int y0 = -(int)( yPadding * screenScale + .5f ) + safeRect.Y + safeRect.Height - hudHeight;

              hudRect = new Rectangle( x0, y0, hudWidth, hudHeight );

              // profile picture
              profileRect = new Rectangle( x0 + (int)( 88 * ss + .5f ),
                                   y0 + (int)( 26 * ss + .5f ),
                                   (int)( 60 * ss + .5f ),
                                   (int)( 60 * ss + .5f ) );

              // boost meter
              boostRect = new Rectangle( x0 + (int)(  90 * ss + .5f ),
                                 y0 + (int)( 111 * ss + .5f ),
                                 (int)( 142 * ss + .5f ),
                                 (int)( 18 * ss + .5f ) );

              boostEffect = screen.Content.Load<Effect>( "Effects/meterEffect" );
              boostEffect.CurrentTechnique = boostEffect.Techniques[0];
              boostEffectParamBoost = boostEffect.Parameters["Boost"];
              boostEffectParamBoosting = boostEffect.Parameters["Boosting"];
              boostEffectParamTime = boostEffect.Parameters["Time"];
              boostTexture = new Texture2D( screen.ScreenManager.GraphicsDevice, boostRect.Width, boostRect.Height );

              // name
              namePos = new Vector2( x0 + 162 * ss, y0 + 12 * ss );
              nameFont = screen.Content.Load<SpriteFont>( "Fonts/HUDNameFont" );
              nameOrigin = nameFont.MeasureString( Name ) / 2;
              float nameLength = nameOrigin.X * 2;
              nameScale = ss * Math.Min( 150f / nameLength, 1f );

              // score
              scorePos = new Vector2( x0 + 230 * ss, y0 + 100 * ss );
              scoreFont = screen.Content.Load<SpriteFont>( "Fonts/HUDScoreFont" );
              scoreSpring = new SpringInterpolater( 1, 700f, .25f * SpringInterpolater.GetCriticalDamping( 700f ) );
              scoreSpring.SetSource( 1f );
              scoreSpring.SetDest( 1f );
              scoreSpring.Active = true;
              scoreString = new StringBuilder( 1 );

              //// score popup
              //scorePopup = new PopupText( ss, scorePos + new Vector2( -25f, -120f ) * screenScale,
              //                            scorePos + new Vector2( -15f, -15f ) * screenScale, 1f );
              // score popup
              //float yMax = GameCore.Instance.DisplayGamertags ? -50f : -10f;
              //float yMin = GameCore.Instance.DisplayGamertags ? 0f : 40f;
              float yMax = -50f;
              float yMin = 0f;
              scorePopup = new PopupText( ss, new Vector2( 0f, yMax ) * screenScale,
                                  new Vector2( 0, yMin ) * screenScale, 1f );

              // place
              placePos = new Vector2( x0 + 36 * ss, y0 + 91 * ss );
              placeFont = screen.Content.Load<SpriteFont>( "Fonts/HUDPlaceFont" );
              placeSmallFont = screen.Content.Load<SpriteFont>( "Fonts/HUDPlaceTagFont" );
              placeNumber = new StringBuilder( "0" );
              placeSpring = new SpringInterpolater( 1, 700f, .25f * SpringInterpolater.GetCriticalDamping( 700f ) );
              placeSpring.SetSource( 1f );
              placeSpring.SetDest( 1f );
              placeSpring.Active = true;
              Place = 1;
        }
Ejemplo n.º 4
0
        /// <summary>
        /// Updates the state of the game. This method checks the GameScreen.IsActive
        /// property, so the game will stop updating when the pause menu is active,
        /// or if you tab away to a different application.
        /// </summary>
        public override void Update(GameTime gameTime, bool otherScreenHasFocus,
            bool coveredByOtherScreen)
        {
            //BEGIN NEW XBOX LIVE GamerPicture code etc
            //You just need to get the GamerCard info if you don't have it already
            if (gamer == null && SignedInGamer.SignedInGamers.Count > 0)
            {
                //Get info for the 1st player
                gamer = SignedInGamer.SignedInGamers[0];
                profile = gamer.GetProfile();
                //place to draw the gamer picture (in the middle of the screen)
                GamerPictureRectangle = new Rectangle(
                                30,
                                150,
                                64,
                                64
                              );
                //place to write some info
                gamerTagVector = new Vector2(GamerPictureRectangle.X, 0);
            }
            //END NEW XBOX LIVE GamerPicture code etc

            CheckForRumble(gameTime);

            // TODO: Add your update logic here
            //The time since Update was called last
            float elapsed = (float)gameTime.ElapsedGameTime.TotalSeconds;

            //Get the current state of the keyboard (what keys are and are not being pressed)
            KeyboardState aKeyboard = Keyboard.GetState();

            //Update the game objects
            if (rotation < Math.PI / 2)
            {
                //rotateing
            }
            else
                if (rotation > Math.PI / 2 && rotation != 3.14f)
                {
                    mPlayfield.Rotate_Grid();
                    rotation = 3.14f;
                }
                else
                    if (mPlayfield.CheckCollision(mCurrentShape) == true && mCurrentShape.PositionY < 4)
                    {gameover = true;}
                    else
                        UpdateGameObjects(elapsed, aKeyboard);

            base.Update(gameTime, otherScreenHasFocus, coveredByOtherScreen);

            if (IsActive)
            {
                // Apply some random jitter to make the enemy move around.
                const float randomization = 10;

                enemyPosition.X += (float)(random.NextDouble() - 0.5) * randomization;
                enemyPosition.Y += (float)(random.NextDouble() - 0.5) * randomization;

                // Apply a stabilizing force to stop the enemy moving off the screen.
                Vector2 targetPosition = new Vector2(200, 200);

                enemyPosition = Vector2.Lerp(enemyPosition, targetPosition, 0.05f);

                // TODO: this game isn't very fun! You could probably improve
                // it by inserting something more interesting in this space :-)
            }
        }