Beispiel #1
0
 private void MovePineapple(pineapple thepineapple)
 {
     thepineapple.Position.Y += mVelocityY;
     if (thepineapple.Position.Y > graphics.GraphicsDevice.Viewport.Height && thepineapple.Visible == true)
     {
         thepineapple.Visible = false;
         thepineapple.isEated = true;
         existPineapple       = false;
         if (score >= 1000)
         {
             MediaPlayer.Pause();
             cheer.Play();
             mCurrentState  = State.Success;
             mExitCountDown = 10;
         }
     }
 }
Beispiel #2
0
        private int CheckPineappleCollision(pineapple thePineapple)
        {
            BoundingBox aPineappleBox = new BoundingBox(new Vector3(thePineapple.Position.X, thePineapple.Position.Y, 0), new Vector3(thePineapple.Position.X + (mPineapple.Width * .4f), thePineapple.Position.Y + ((mPineapple.Height - 50) * .4f), 0));
            BoundingBox aCarBox       = new BoundingBox(new Vector3(mCarPosition.X, mCarPosition.Y, 0), new Vector3(mCarPosition.X + (mCar.Width * .2f), mCarPosition.Y + (mCar.Height * .2f), 0));

            if (aPineappleBox.Intersects(aCarBox) == true && thePineapple.isEated == false)
            {
                ohno.Play();
                MovePineapple(thePineapple);
                thePineapple.Visible = false;
                thePineapple.isEated = true;
                existPineapple       = false;
                score -= 10;
                mVelocityY++;
                return(1);
            }
            return(0);
        }
Beispiel #3
0
        private void AddPineapple()
        {
            int aRoadPosition = mRandom.Next(1, 5);
            int aPosition     = 130;

            if (aRoadPosition == 2)
            {
                aPosition = 180;
            }
            else if (aRoadPosition == 3)
            {
                aPosition = 350;
            }
            else if (aRoadPosition == 4)
            {
                aPosition = 500;
            }
            bool aAddNewPineapple = true;

            foreach (pineapple aPineapple in mPineapples)
            {
                if (aPineapple.Visible == false)
                {
                    aAddNewPineapple    = false;
                    aPineapple.Visible  = true;
                    aPineapple.isEated  = false;
                    aPineapple.Position = new Vector2(aPosition, -mPineapple.Height);
                    break;
                }
            }
            if (aAddNewPineapple == true)
            {
                //Add a Pineapple to the left side of the Road
                pineapple aPineapple = new pineapple();
                aPineapple.Position = new Vector2(aPosition, -mPineapple.Height);

                mPineapples.Add(aPineapple);
            }
        }
Beispiel #4
0
 private void MovePineapple(pineapple thepineapple)
 {
     thepineapple.Position.Y += mVelocityY;
     if (thepineapple.Position.Y > graphics.GraphicsDevice.Viewport.Height && thepineapple.Visible == true)
     {
         thepineapple.Visible = false;
         thepineapple.isEated = true;
         existPineapple = false;
         if (score >= 1000)
         {
             MediaPlayer.Pause();
             cheer.Play();
             mCurrentState = State.Success;
             mExitCountDown = 10;
         }
     }
 }
Beispiel #5
0
        private int CheckPineappleCollision(pineapple thePineapple)
        {
            BoundingBox aPineappleBox = new BoundingBox(new Vector3(thePineapple.Position.X, thePineapple.Position.Y, 0), new Vector3(thePineapple.Position.X + (mPineapple.Width * .4f), thePineapple.Position.Y + ((mPineapple.Height - 50) * .4f), 0));
            BoundingBox aCarBox = new BoundingBox(new Vector3(mCarPosition.X, mCarPosition.Y, 0), new Vector3(mCarPosition.X + (mCar.Width * .2f), mCarPosition.Y + (mCar.Height * .2f), 0));

            if (aPineappleBox.Intersects(aCarBox) == true && thePineapple.isEated == false)
            {
                ohno.Play();
                MovePineapple(thePineapple);
                thePineapple.Visible = false;
                thePineapple.isEated = true;
                existPineapple = false;
                score -= 10;
                mVelocityY++;
                return 1;
            }
            return 0;
        }
Beispiel #6
0
        private void AddPineapple()
        {
            int aRoadPosition = mRandom.Next(1,5);
            int aPosition = 130;
            if (aRoadPosition == 2)
            {
                aPosition = 180;
            }
            else if (aRoadPosition == 3)
            {
                aPosition = 350;
            }
            else if (aRoadPosition == 4)
            {
                aPosition = 500;
            }
            bool aAddNewPineapple = true;
            foreach (pineapple aPineapple in mPineapples)
            {
                if (aPineapple.Visible == false)
                {
                    aAddNewPineapple = false;
                    aPineapple.Visible = true;
                    aPineapple.isEated = false;
                    aPineapple.Position = new Vector2(aPosition, -mPineapple.Height);
                    break;
                }
            }
            if (aAddNewPineapple == true)
            {
                //Add a Pineapple to the left side of the Road
                pineapple aPineapple = new pineapple();
                aPineapple.Position = new Vector2(aPosition, -mPineapple.Height);

                mPineapples.Add(aPineapple);
            }
        }