Esempio n. 1
0
        virtual public void update(GameTime gameTime)
        {
            m_Animate.updatePosition(m_Position);

            CollisionType[,] temp = Level.backgroundCollisionCheck(Destination);

            int count = 0;

            for (int i = 0; i < temp.GetLength(0); i++)
            {
                for (int j = 0; j < temp.GetLength(1); j++)
                {
                    if (temp[i, j].m_WasThereACollision == true)
                    {
                        count++;
                        switch (temp[i, j].m_FirstObjectSideCollided)
                        {
                        case SideCollided.BOTTOM:
                            if (this is Player)
                            {
                                Player.setIsOnGround(true);
                            }
                            m_Position.Y -= temp[i, j].m_OverlapArea.Height;
                            break;

                        case SideCollided.TOP:
                            if (this is Player)
                            {
                                Player.setIsJumping(false);
                            }
                            m_Position.Y += temp[i, j].m_OverlapArea.Height;
                            break;

                        case SideCollided.LEFT:
                            m_Position.X += temp[i, j].m_OverlapArea.Width;
                            break;

                        case SideCollided.RIGHT:
                            m_Position.X -= temp[i, j].m_OverlapArea.Width;
                            break;
                        }
                        if (count >= 3)
                        {
                            break;
                        }
                    }
                }
                if (count >= 3)
                {
                    break;
                }
            }
            m_Animate.update(gameTime);
            m_Animate.updatePosition(m_Position);
        }
Esempio n. 2
0
        public void update(GameTime gameTime)
        {
            if (m_IsActive == true)
            {
                float elapsedTime = (float)gameTime.ElapsedGameTime.Milliseconds / 1000;

                m_Position.X -= m_Speed * elapsedTime;

                Rectangle temp = m_Animate.DestinationRectangle;

                if (temp.Width < MAX_WIDTH)
                {
                    temp.Width += (int)(MAX_WIDTH * INCREMENT_AMOUNT);
                }

                if (temp.Height < MAX_HEIGHT)
                {
                    temp.Height += (int)(MAX_HEIGHT * INCREMENT_AMOUNT);
                }

                m_Animate.DestinationRectangle = temp;

                m_Position.Y = m_StartIngPos.Y - m_Animate.DestinationRectangle.Height / 2;

                m_Animate.updatePosition(m_Position);

                if (CollisionCheck.collisionCheck(m_Animate.DestinationRectangle, m_LevelBounds) == false)
                {
                    m_IsActive = false;
                    reset();
                }

                collisionCheck();
            }
        }