Exemplo n.º 1
0
        /*Deteta o toque entre 2 objetos*/
        public bool PrimitivesTouches(TexturedPrimitive otherPrim)
        {
            Vector2 v    = mPosition - otherPrim.mPosition;
            float   dist = v.Length();

            return(dist < ((mSize.X / 2f) + (otherPrim.mSize.X / 2f)));
        }
Exemplo n.º 2
0
 ///*Inicializar o personagem com uma certa textura,posição e tamanho*/
 //public MyGame()
 //{
 //    // Hero ...
 //    mHero = new TexturedPrimitive("Me", kHeroPosition, kHeroSize);
 //    // Basketballs
 //    mCreationTimeStamp = new TimeSpan(0);
 //    mBBallList = new List<BasketBall>();
 //}
 public MyGame()
 {
     // Create the primitives
     mBall = new TexturedPrimitive("Soccer",
                                   new Vector2(30, 30), new Vector2(10, 15));
     mUWBLogo = new TexturedPrimitive("UWB-JPG",
                                      new Vector2(60, 30), new Vector2(20, 20));
     mWorkPrim = mBall;
 }
Exemplo n.º 3
0
        /// <summary>
        /// LoadContent will be called once per game and is the place to load
        /// all of your content.
        /// </summary>
        protected override void LoadContent()
        {
            // Create a new SpriteBatch, which can be used to draw textures.
            Game1.sSpriteBatch = new SpriteBatch(GraphicsDevice);

            // Define camera window bounds
            Camera.SetCameraWindow(new Vector2(10f, 20f), 100f);

            // Create the primitives.
            mGraphicsObjects    = new TexturedPrimitive[kNumObjects];
            mGraphicsObjects[0] = new TexturedPrimitive(
                "Soccer",               // Image file name
                new Vector2(15f, 25f),  // Position to draw
                new Vector2(10f, 10f)); // Size to draw
            mGraphicsObjects[1] = new TexturedPrimitive(
                "UWB-JPG",
                new Vector2(35f, 60f),
                new Vector2(50f, 50f));
            mGraphicsObjects[2] = new TexturedPrimitive(
                "UWB-PNG",
                new Vector2(105f, 25f),
                new Vector2(10f, 10f));
            mGraphicsObjects[3] = new TexturedPrimitive(
                "UWB-PNG",
                new Vector2(90f, 60f),
                new Vector2(35f, 35f));
            // NOTE: Since the creation of TexturedPrimitive involves loading of textures,
            // the creation should occur in or after LoadContent()


            mUWBLogo = new TexturedPrimitive("UWB-PNG", new Vector2(30, 30), new Vector2(20, 20));
            mBall    = new SoccerBall(mSoccerPosition, mSoccerBallRadius * 2f);

            mTheGame = new MyGame();
            // TODO: use this.Content to load your game content here
        }
Exemplo n.º 4
0
        public void UpdateGame(GameTime gameTime)
        {
            //    /*Verifica se o jogo chegou ao final*/
            //    #region Step a.
            //    if (null != mFinal) // Done!!
            //        return;
            //    #endregion Step a.

            //    /*Remove as bolas que explodiram e atualiza o score*/
            //    #region Step b.
            //    // Hero movement: right thumb stick
            //    mHero.Update(InputWrapper.ThumbSticks.Right, InputWrapper.ThumbSticks.Left);
            //    // Basketball ...
            //    for (int b = mBBallList.Count - 1; b >= 0; b--)
            //    {
            //        if (mBBallList[b].UpdateAndExplode())
            //        {
            //            mBBallList.RemoveAt(b);
            //            mBBallMissed++;
            //            mScore += kBballMissedScore;
            //        }
            //    }
            //    #endregion Step b.

            //    /*Remove as bolas que foram tocadas pela personagem e atualiza o score*/
            //    #region Step c.
            //    for (int b = mBBallList.Count - 1; b >= 0; b--)
            //    {
            //        if (mHero.PrimitivesTouches(mBBallList[b]))
            //        {
            //            mBBallList.RemoveAt(b);
            //            mBBallHit++;
            //            mScore += kBballTouchScore;
            //        }
            //    }
            //    #endregion Step c.

            //    /*Dá spawn de novos inimigos*/
            //    #region Step d.
            //    // Check for new basketball condition
            //    TimeSpan timePassed = gameTime.TotalGameTime;
            //    timePassed = timePassed.Subtract(mCreationTimeStamp);
            //    if (timePassed.TotalMilliseconds > kBballMSecInterval)
            //    {
            //        mCreationTimeStamp = gameTime.TotalGameTime;
            //        BasketBall b = new BasketBall();
            //        mTotalBBallCreated++;
            //        mBBallList.Add(b);
            //    }
            //    #endregion Step d.

            //    /*Verifica se ganhou ou perdeu*/
            //    #region Step e.
            //    // Check for winning condition ...
            //    if (mScore > kWinScore)
            //        mFinal = new TexturedPrimitive("Winner",
            //        new Vector2(75, 50), new Vector2(30, 20));
            //    else if (mScore < kLossScore)
            //        mFinal = new TexturedPrimitive("Looser",
            //        new Vector2(75, 50), new Vector2(30, 20));
            //    #endregion Step e.
            //}
            /*Desenha o personagem e as bolas de basket*/

            #region Select which primitive to work on
            if (InputWrapper.Buttons.A == ButtonState.Pressed)
            {
                mWorkPrim = mBall;
            }
            else if (InputWrapper.Buttons.B == ButtonState.Pressed)
            {
                mWorkPrim = mUWBLogo;
            }
            #endregion
            #region Update the work primitive
            float rotation = 0;
            if (InputWrapper.Buttons.X == ButtonState.Pressed)
            {
                rotation = MathHelper.ToRadians(1f); // 1 degree pre-press
            }
            else if (InputWrapper.Buttons.Y == ButtonState.Pressed)
            {
                rotation = MathHelper.ToRadians(-1f); // 1 degree pre-press
            }
            mWorkPrim.Update(
                InputWrapper.ThumbSticks.Left,
                InputWrapper.ThumbSticks.Right,
                rotation);
            #endregion
        }