예제 #1
0
        public bool PrimitivesTouches(TexturedPrimitive otherPrim)
        {
            Vector2 v    = mPosition - otherPrim.mPosition;
            float   dist = v.Length();

            return(dist < ((mSize.X / 2f) + (otherPrim.mSize.X / 2f)));
        }
예제 #2
0
 public MyGame()
 {
     // Hero
     mHero = new TexturedPrimitive(Game1.sContent.Load <Texture2D>("Me"), kHeroPosition, kHeroSize);
     // Basketballs
     mCreationTimeStamp = new TimeSpan(0);
     mBBallList         = new List <BasketBall>();
 }
예제 #3
0
        static public CameraWindowCollisionStatus CollidedWithCameraWindow(TexturedPrimitive prim)
        {
            Vector2 min = CameraWindowLowerLeftPosition;
            Vector2 max = CameraWindowUpperRightPosition;

            if (prim.MaxBound.Y > max.Y)
            {
                return(CameraWindowCollisionStatus.CollideTop);
            }
            if (prim.MinBound.X < min.X)
            {
                return(CameraWindowCollisionStatus.CollideLeft);
            }
            if (prim.MaxBound.X > max.X)
            {
                return(CameraWindowCollisionStatus.CollideRight);
            }
            if (prim.MinBound.Y < min.Y)
            {
                return(CameraWindowCollisionStatus.CollideBottom);
            }
            return(CameraWindowCollisionStatus.InsideWindow);
        }
예제 #4
0
        public void UpdateGame(GameTime gameTime)
        {
            #region Step a.
            if (null != mFinal) // Done!!
            {
                return;
            }
            #endregion Step a.

            #region Step b.
            // Hero movement: right thumb stick
            mHero.Update2(InputWrapper.ThumbSticks.Right);
            // Basketball
            for (int b = mBBallList.Count - 1; b >= 0; b--)
            {
                if (mBBallList[b].UpdateAndExplode())
                {
                    mBBallList.RemoveAt(b);
                    mBBallMissed++;
                    mScore += kBballMissedScore;
                }
            }
            #endregion Step b.

            #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.

            #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(new Vector2(Game1.sRan.Next(25, 90), Game1.sRan.Next(25, 90)), mBBallBallRadius);
                mTotalBBallCreated++;
                mBBallList.Add(b);
            }
            #endregion Step d.

            #region Step e.
            // Check for winning condition
            if (mScore > kWinScore)
            {
                mFinal = new TexturedPrimitive(Game1.sContent.Load <Texture2D>("Winner"), new Vector2(75, 50), new Vector2(30, 20));
            }
            else if (mScore < kLossScore)
            {
                mFinal = new TexturedPrimitive(Game1.sContent.Load <Texture2D>("Loser"),
                                               new Vector2(75, 50), new Vector2(30, 20));
            }
            #endregion Step e
        }
예제 #5
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);
            //mSpriteBatch = 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(
                Content.Load <Texture2D>("UWB-JPG"), // Image file name
                new Vector2(15f, 25f),               // Position to draw
                new Vector2(10f, 10f));              // Size to draw
                                                     //new Vector2(10, 10), // Position to draw
                                                     //new Vector2(30, 30)); // Size to draw
            mGraphicsObjects[1] = new TexturedPrimitive(
                Content.Load <Texture2D>("UWB-JPG"),
                new Vector2(35f, 60f),
                new Vector2(50f, 50f));
            //new Vector2(200, 200),
            //new Vector2(100, 100));
            mGraphicsObjects[2] = new TexturedPrimitive(
                Content.Load <Texture2D>("UWB-PNG"),
                new Vector2(105f, 25f),
                new Vector2(10f, 10f));
            //new Vector2(50, 10),
            //new Vector2(30, 30));
            mGraphicsObjects[3] = new TexturedPrimitive(
                Content.Load <Texture2D>("UWB-PNG"),
                new Vector2(90f, 60f),
                new Vector2(35f, 35f));
            //new Vector2(50, 200),
            //new Vector2(100, 100));
            mUWBLogo     = new TexturedPrimitive(Content.Load <Texture2D>("UWB-PNG"), new Vector2(30, 30), new Vector2(20, 20));
            vida         = 5;
            score        = 0;
            placarVida   = new TexturedPrimitive[10];
            blocosNaTela = 0;
            nivelAtual   = 1;
            int posicaoX = 13;
            int posicaoY = 92;
            int j        = 0;

            for (int i = 0; i < 10; i++)
            {
                placarVida[i]           = new TexturedPrimitive(Content.Load <Texture2D>("Block Breaker Esfera"), mVidaPosition, mVidaSize);
                placarVida[i].mPosition = new Vector2(posicaoX, posicaoY);
                posicaoX += 6;
            }
            mBall   = new SoccerBall(mSoccerPosition, mSoccerBallRadius * 2f);
            mEsfera = new Esfera(mEsferaPosition, mEsferaSize);
            mBastao = new Bastao(mBastaoPosition, mBastaoSize);
            //mBloco = new BlocoAzul(mBlocoPosition, mBlocoSize);
            //carrega Nivel 1
            mBlocoAzulNivel1 = new BlocoAzul[40];
            posicaoX         = 15;
            posicaoY         = 85;
            j = 0;
            for (int i = 0; i < 40; i++)
            {
                mBlocoAzulNivel1[i]           = new BlocoAzul(mBlocoPosition, mBlocoSize);
                mBlocoAzulNivel1[i].mPosition = new Vector2(posicaoX, posicaoY);
                posicaoX += 10;
                j++;
                if (j == 10)
                {
                    posicaoX  = 15;
                    posicaoY -= 5;
                    j         = 0;
                }
            }
            //carrega Nivel 2
            mBlocoAmareloNivel2             = new BlocoAmarelo[10];
            mBlocoAmareloQuebradoNivel2     = new BlocoAzul[10];
            timerBlocoAmareloNivel2         = new int[10];
            timerBlocoAmareloNivel2existing = new bool[10];
            posicaoX = 15;
            posicaoY = 85;
            j        = 0;
            for (int i = 0; i < 10; i++)
            {
                mBlocoAmareloNivel2[i]                   = new BlocoAmarelo(mBlocoPosition, mBlocoSize);
                mBlocoAmareloNivel2[i].mPosition         = new Vector2(posicaoX, posicaoY);
                mBlocoAmareloQuebradoNivel2[i]           = new BlocoAzul(mBlocoPosition, mBlocoSize);
                mBlocoAmareloQuebradoNivel2[i].mPosition = new Vector2(posicaoX, posicaoY);
                mBlocoAmareloQuebradoNivel2[i].existe    = false;
                timerBlocoAmareloNivel2[i]               = 0;
                timerBlocoAmareloNivel2existing[i]       = false;
                posicaoX += 10;
                j++;
            }
            mBlocoAzulNivel2 = new BlocoAzul[20];
            posicaoX         = 15;
            posicaoY         = 70;
            j = 0;
            for (int i = 0; i < 20; i++)
            {
                mBlocoAzulNivel2[i]           = new BlocoAzul(mBlocoPosition, mBlocoSize);
                mBlocoAzulNivel2[i].mPosition = new Vector2(posicaoX, posicaoY);
                posicaoX += 10;
                j++;
                if (j == 10)
                {
                    posicaoX  = 15;
                    posicaoY -= 15;
                    j         = 0;
                }
            }
            //carrega Nivel 3
            mBlocoAmareloNivel3             = new BlocoAmarelo[20];
            mBlocoAmareloQuebradoNivel3     = new BlocoAzul[20];
            timerBlocoAmareloNivel3         = new int[20];
            timerBlocoAmareloNivel3existing = new bool[20];
            mBlocoAzulNivel3 = new BlocoAzul[20];
            posicaoX         = 15;
            posicaoY         = 85;
            j = 0;
            for (int i = 0; i < 20; i++)
            {
                mBlocoAmareloNivel3[i]                   = new BlocoAmarelo(mBlocoPosition, mBlocoSize);
                mBlocoAmareloNivel3[i].mPosition         = new Vector2(posicaoX, posicaoY);
                mBlocoAmareloQuebradoNivel3[i]           = new BlocoAzul(mBlocoPosition, mBlocoSize);
                mBlocoAmareloQuebradoNivel3[i].mPosition = new Vector2(posicaoX, posicaoY);
                mBlocoAmareloQuebradoNivel3[i].existe    = false;
                timerBlocoAmareloNivel3[i]               = 0;
                timerBlocoAmareloNivel3existing[i]       = false;
                posicaoX += 10;
                j++;
                if (j == 10)
                {
                    posicaoX  = 15;
                    posicaoY -= 30;
                    j         = 0;
                }
            }
            posicaoX = 15;
            posicaoY = 70;
            j        = 0;
            for (int i = 0; i < 20; i++)
            {
                mBlocoAzulNivel3[i]           = new BlocoAzul(mBlocoPosition, mBlocoSize);
                mBlocoAzulNivel3[i].mPosition = new Vector2(posicaoX, posicaoY);
                posicaoX += 10;
                j++;
                if (j == 10)
                {
                    posicaoX  = 15;
                    posicaoY -= 5;
                    j         = 0;
                }
            }
            //carrega nivel 4
            mBlocoAzulNivel4                = new BlocoAzul[18];
            mBlocoAmareloNivel4             = new BlocoAmarelo[10];
            mBlocoAmareloQuebradoNivel4     = new BlocoAzul[10];
            timerBlocoAmareloNivel4         = new int[10];
            timerBlocoAmareloNivel4existing = new bool[10];
            mBlocoMarromNivel4              = new BlocoMarrom[4];
            mBlocoMarromQuebradoNivel4      = new BlocoAmarelo[4];
            timerBlocoMarromNivel4          = new int[4];
            timerBlocoMarromNivel4existing  = new bool[4];
            mBlocoMarromQuebrado2Nivel4     = new BlocoAzul[4];
            timerBlocoMarrom2Nivel4         = new int[4];
            timerBlocoMarrom2Nivel4existing = new bool[4];
            posicaoX = 15;
            posicaoY = 55;
            j        = 0;
            for (int i = 0; i < 18; i++)
            {
                mBlocoAzulNivel4[i]           = new BlocoAzul(mBlocoPosition, mBlocoSize);
                mBlocoAzulNivel4[i].mPosition = new Vector2(posicaoX, posicaoY);
                if (i == 13)
                {
                    posicaoX += 20;
                }
                posicaoX += 10;
                j++;
                if (j == 10)
                {
                    posicaoX  = 15;
                    posicaoY += 5;
                    j         = 0;
                }
            }
            posicaoX = 15;
            posicaoY = 65;
            j        = 0;
            for (int i = 0; i < 10; i++)
            {
                mBlocoAmareloNivel4[i]                   = new BlocoAmarelo(mBlocoPosition, mBlocoSize);
                mBlocoAmareloNivel4[i].mPosition         = new Vector2(posicaoX, posicaoY);
                mBlocoAmareloQuebradoNivel4[i]           = new BlocoAzul(mBlocoPosition, mBlocoSize);
                mBlocoAmareloQuebradoNivel4[i].mPosition = new Vector2(posicaoX, posicaoY);
                mBlocoAmareloQuebradoNivel4[i].existe    = false;
                timerBlocoAmareloNivel4[i]               = 0;
                timerBlocoAmareloNivel4existing[i]       = false;
                if (i == 2)
                {
                    posicaoX += 40;
                }
                if (i == 7)
                {
                    posicaoX += 60;
                }
                posicaoX += 10;
                j++;
                if (j == 6)
                {
                    posicaoX  = 15;
                    posicaoY += 5;
                    j         = 0;
                }
            }
            posicaoX = 15;
            posicaoY = 75;
            j        = 0;
            for (int i = 0; i < 4; i++)
            {
                mBlocoMarromNivel4[i]                    = new BlocoMarrom(mBlocoPosition, mBlocoSize);
                mBlocoMarromNivel4[i].mPosition          = new Vector2(posicaoX, posicaoY);
                mBlocoMarromQuebradoNivel4[i]            = new BlocoAmarelo(mBlocoPosition, mBlocoSize);
                mBlocoMarromQuebradoNivel4[i].mPosition  = new Vector2(posicaoX, posicaoY);
                mBlocoMarromQuebradoNivel4[i].existe     = false;
                timerBlocoMarromNivel4[i]                = 0;
                timerBlocoMarromNivel4existing[i]        = false;
                mBlocoMarromQuebrado2Nivel4[i]           = new BlocoAzul(mBlocoPosition, mBlocoSize);
                mBlocoMarromQuebrado2Nivel4[i].mPosition = new Vector2(posicaoX, posicaoY);
                mBlocoMarromQuebrado2Nivel4[i].existe    = false;
                timerBlocoMarrom2Nivel4[i]               = 0;
                timerBlocoMarrom2Nivel4existing[i]       = false;
                if (i == 0 || i == 2)
                {
                    posicaoX = 105;
                }
                j++;
                if (j == 2)
                {
                    posicaoX  = 15;
                    posicaoY += 5;
                }
            }
            //carrega nivel 5
            mBlocoAzulNivel5                  = new BlocoAzul[10];
            mBlocoAmareloNivel5               = new BlocoAmarelo[10];
            mBlocoAmareloQuebradoNivel5       = new BlocoAzul[10];
            timerBlocoAmareloNivel5           = new int[10];
            timerBlocoAmareloNivel5existing   = new bool[10];
            mBlocoMarromNivel5                = new BlocoMarrom[28];
            mBlocoMarromQuebradoNivel5        = new BlocoAmarelo[28];
            timerBlocoMarromNivel5            = new int[28];
            timerBlocoMarromNivel5existing    = new bool[28];
            mBlocoMarromQuebrado2Nivel5       = new BlocoAzul[28];
            timerBlocoMarrom2Nivel5           = new int[28];
            timerBlocoMarrom2Nivel5existing   = new bool[28];
            mBlocoVermelhoNivel5              = new BlocoVermelho[4];
            mBlocoVermelhoQuebradoNivel5      = new BlocoMarrom[4];
            timerBlocoVermelhoNivel5          = new int[4];
            timerBlocoVermelhoNivel5existing  = new bool[4];
            mBlocoVermelhoQuebrado2Nivel5     = new BlocoAmarelo[4];
            timerBlocoVermelho2Nivel5         = new int[4];
            timerBlocoVermelho2Nivel5existing = new bool[4];
            mBlocoVermelhoQuebrado3Nivel5     = new BlocoAzul[4];
            timerBlocoVermelho3Nivel5         = new int[4];
            timerBlocoVermelho3Nivel5existing = new bool[4];
            posicaoX = 15;
            posicaoY = 55;
            j        = 0;
            for (int i = 0; i < 10; i++)
            {
                mBlocoAzulNivel5[i]           = new BlocoAzul(mBlocoPosition, mBlocoSize);
                mBlocoAzulNivel5[i].mPosition = new Vector2(posicaoX, posicaoY);
                posicaoX += 10;
            }
            posicaoX = 15;
            posicaoY = 60;
            for (int i = 0; i < 10; i++)
            {
                mBlocoAmareloNivel5[i]                   = new BlocoAmarelo(mBlocoPosition, mBlocoSize);
                mBlocoAmareloNivel5[i].mPosition         = new Vector2(posicaoX, posicaoY);
                mBlocoAmareloQuebradoNivel5[i]           = new BlocoAzul(mBlocoPosition, mBlocoSize);
                mBlocoAmareloQuebradoNivel5[i].mPosition = new Vector2(posicaoX, posicaoY);
                mBlocoAmareloQuebradoNivel5[i].existe    = false;
                timerBlocoAmareloNivel5[i]               = 0;
                timerBlocoAmareloNivel5existing[i]       = false;
                posicaoX += 10;
            }
            posicaoX = 15;
            posicaoY = 65;
            for (int i = 0; i < 28; i++)
            {
                mBlocoMarromNivel5[i]                    = new BlocoMarrom(mBlocoPosition, mBlocoSize);
                mBlocoMarromNivel5[i].mPosition          = new Vector2(posicaoX, posicaoY);
                mBlocoMarromQuebradoNivel5[i]            = new BlocoAmarelo(mBlocoPosition, mBlocoSize);
                mBlocoMarromQuebradoNivel5[i].mPosition  = new Vector2(posicaoX, posicaoY);
                mBlocoMarromQuebradoNivel5[i].existe     = false;
                timerBlocoMarromNivel5[i]                = 0;
                timerBlocoMarromNivel5existing[i]        = false;
                mBlocoMarromQuebrado2Nivel5[i]           = new BlocoAzul(mBlocoPosition, mBlocoSize);
                mBlocoMarromQuebrado2Nivel5[i].mPosition = new Vector2(posicaoX, posicaoY);
                mBlocoMarromQuebrado2Nivel5[i].existe    = false;
                timerBlocoMarrom2Nivel5[i]               = 0;
                timerBlocoMarrom2Nivel5existing[i]       = false;
                if (i == 0 || i == 4 || i == 8 || i == 2 || i == 6 || i == 14)
                {
                    posicaoX += 20;
                }
                else if (i == 3 || i == 7 || i == 15 || i == 17)
                {
                    posicaoX  = 15;
                    posicaoY += 5;
                }
                else if (i == 1 || i == 5)
                {
                    posicaoX += 50;
                }
                else if (i == 16)
                {
                    posicaoX += 90;
                }
                else
                {
                    posicaoX += 10;
                }
            }
            posicaoX = 45;
            posicaoY = 80;
            for (int i = 0; i < 4; i++)
            {
                mBlocoVermelhoNivel5[i]                    = new BlocoVermelho(mBlocoPosition, mBlocoSize);
                mBlocoVermelhoNivel5[i].mPosition          = new Vector2(posicaoX, posicaoY);
                mBlocoVermelhoQuebradoNivel5[i]            = new BlocoMarrom(mBlocoPosition, mBlocoSize);
                mBlocoVermelhoQuebradoNivel5[i].mPosition  = new Vector2(posicaoX, posicaoY);
                mBlocoVermelhoQuebradoNivel5[i].existe     = false;
                timerBlocoVermelhoNivel5[i]                = 0;
                timerBlocoVermelhoNivel5existing[i]        = false;
                mBlocoVermelhoQuebrado2Nivel5[i]           = new BlocoAmarelo(mBlocoPosition, mBlocoSize);
                mBlocoVermelhoQuebrado2Nivel5[i].mPosition = new Vector2(posicaoX, posicaoY);
                mBlocoVermelhoQuebrado2Nivel5[i].existe    = false;
                timerBlocoVermelho2Nivel5[i]               = 0;
                timerBlocoVermelho2Nivel5existing[i]       = false;
                mBlocoVermelhoQuebrado3Nivel5[i]           = new BlocoAzul(mBlocoPosition, mBlocoSize);
                mBlocoVermelhoQuebrado3Nivel5[i].mPosition = new Vector2(posicaoX, posicaoY);
                mBlocoVermelhoQuebrado3Nivel5[i].existe    = false;
                timerBlocoVermelho3Nivel5[i]               = 0;
                timerBlocoVermelho3Nivel5existing[i]       = false;
                posicaoX += 10;
            }
            //fim dos niveis
            // Load the images.
            //mJPGImage = Content.Load<Texture2D>("UWB-JPG");
            //mPNGImage = Content.Load<Texture2D>("UWB-PNG");
            background = Content.Load <Texture2D>("Salty present 2015");
            levels     = new Texture2D[6];
            levels[0]  = Content.Load <Texture2D>("IPCA Nivel 1");
            levels[1]  = Content.Load <Texture2D>("IPCA Nivel 2");
            levels[2]  = Content.Load <Texture2D>("IPCA Nivel 3");
            levels[3]  = Content.Load <Texture2D>("IPCA Nivel 4");
            levels[4]  = Content.Load <Texture2D>("IPCA Nivel 5");
            levels[5]  = Content.Load <Texture2D>("IPCA");
            //lifeLost = Content.Load<SoundEffect>("Life Lost");
            //stageClear = Content.Load<SoundEffect>("Stage Clear");
            mTheGame = new MyGame();
            // TODO: use this.Content to load your game content here
        }