Beispiel #1
0
        /// <summary>
        /// Allows the game to run logic such as updating the world,
        /// checking for collisions, gathering input, and playing audio.
        /// </summary>
        /// <param name="gameTime">Provides a snapshot of timing values.</param>
        public override void Update(GameTime gameTime)
        {
            // check the status of loading
            // if it is loading on any floating in the same line
            // the frog is alive

            if (myFrog.GetCurrentLine() < 3 || myFrog.GetCurrentLine() > 7)
            {
                return;
            }
            if (myFrog.GetCurrentLine() != ((Floatings)flArr[0]).GetLine())
            {
                return;
            }
            if (!myFrog.DoesMoveFinish())
            {
                return;
            }
            isLoaded = false;

            // get bounds of objects which will collide
            Rectangle frogRect = myFrog.GetBounds();

            for (int i = 0; i < cnt; i++)
            {
                Rectangle floatingRect = ((Floatings)flArr[i]).GetBounds();

                mSec += gameTime.ElapsedGameTime.Milliseconds;

                if (frogRect.Intersects(floatingRect))
                {
                    //soundEffect.Play();
                    isLoaded = true;
                }
                else
                {
                    if (!isLoaded)
                    {
                        isLoaded = false;
                    }
                }
            }

            if (!isLoaded)
            {
                myFrog.SetDead();
            }
            else
            {
                myFrog.SetLoaded(((Floatings)flArr[0]).GetSpeed());
            }

            base.Update(gameTime);
        }
Beispiel #2
0
        /// <summary>
        /// Allows the game to run logic such as updating the world,
        /// checking for collisions, gathering input, and playing audio.
        /// </summary>
        /// <param name="gameTime">Provides a snapshot of timing values.</param>
        public override void Update(GameTime gameTime)
        {
            // get bounds of objects which will collide
            Rectangle frogRect = myFrog.GetBounds();
            Rectangle carRect  = myCar.GetBounds();

            if (frogRect.Intersects(carRect))
            {
                //soundEffect.Play();
                myFrog.SetDead();
            }

            base.Update(gameTime);
        }