Esempio n. 1
0
        /// <summary>
        /// Update the x axis movement.
        /// </summary>
        public void xAxisUpdate(float delta)
        {
            pos.X   += velocity.X * delta;
            recHit.X = (int)(pos.X - recHit.Width / 2);
            Blocker blocker = world.IsEntityCollidingBlocker(this);

            if (blocker != null)
            {
                if (velocity.X >= 0)
                {
                    pos.X = blocker.GetRecHit().X - recHit.Width / 2;
                }
                else
                {
                    pos.X = blocker.GetRecHit().X + blocker.GetRecHit().Width + recHit.Width / 2;
                }

                velocity.X = 0f;
                recHit.X   = (int)(pos.X - recHit.Width / 2);
            }
        }
Esempio n. 2
0
        /// <summary>
        /// Update the y axis movement.
        /// </summary>
        public void yAxisUpdate(float delta)
        {
            pos.Y   += velocity.Y * delta;
            recHit.Y = (int)(pos.Y - recHit.Height);
            Blocker blocker = world.IsEntityCollidingBlocker(this);

            if (blocker != null)
            {
                if (velocity.Y > 0)
                {
                    pos.Y       = blocker.GetRecHit().Y - 5;
                    velocity.Y *= -1f;
                }
                else
                {
                    pos.Y      = blocker.GetRecHit().Y + blocker.GetRecHit().Height + recHit.Height + 5;
                    velocity.Y = 0;
                }
                recHit.Y = (int)(pos.Y - recHit.Height);
            }
        }
Esempio n. 3
0
 /// <summary>
 /// Create the trampolines and the block in the middle.
 /// </summary>
 public void InitWorld()
 {
     leftTramp  = new Trampolin(this, new Vector2(320, 500), 120, 1.5f);
     rightTramp = new Trampolin(this, new Vector2(960, 500), 180, 2f);
     blocker    = new Blocker(this, new Vector2(Globals.screenWidth / 2, 500), 300);
 }