// slides this background in, drawing the previous one behind it
 public void slideIn(KeysToInsanity.Boundary direction, ParallaxBackground previousBackground)
 {
     if (sliding == KeysToInsanity.Boundary.None)
     {
         previousBackgroundTexture = previousBackground.spriteTex;
         previousBackgroundTexture2 = previousBackground.background2Texture;
         previousRectangle = new Rectangle(0, 0, spriteSize.X, spriteSize.Y);
         previousRectangle2 = new Rectangle(0, 0, spriteSize.X + parallax, spriteSize.Y + parallax);
         sliding = direction;
         switch(sliding)
         {
             case KeysToInsanity.Boundary.Left:
                 spritePos = new Vector2(spritePos.X + spriteSize.X, spritePos.Y);
                 background2Rectangle = new Rectangle(previousRectangle2.X + previousRectangle2.Width, previousRectangle2.Y, spriteSize.X + parallax, spriteSize.Y + parallax);
                 break;
             case KeysToInsanity.Boundary.Right:
                 spritePos = new Vector2(spritePos.X - spriteSize.X, spritePos.Y);
                 background2Rectangle = new Rectangle(previousRectangle2.X - previousRectangle2.Width, previousRectangle2.Y, spriteSize.X + parallax, spriteSize.Y + parallax);
                 break;
             case KeysToInsanity.Boundary.Top:
                 spritePos = new Vector2(spritePos.X, spritePos.Y + spriteSize.Y);
                 background2Rectangle = new Rectangle(previousRectangle2.X, previousRectangle2.Y + previousRectangle2.Height, spriteSize.X + parallax, spriteSize.Y + parallax);
                 break;
             case KeysToInsanity.Boundary.Bottom:
                 spritePos = new Vector2(spritePos.X, spritePos.Y - spriteSize.Y);
                 background2Rectangle = new Rectangle(previousRectangle2.X, previousRectangle2.Y - previousRectangle2.Height, spriteSize.X + parallax, spriteSize.Y + parallax);
                 break;
             default:
                 break;
         }
         slide = true;
     }
 }
Exemple #2
0
 public void setStart(int x, int y, KeysToInsanity.Boundary b)
 {
     startX = x;
     startY = y;
     start = b;
 }
 public void Update(GameTime time)
 {
     int step = 20; // adjust the value here for background1 speed
     int step2 = 8; // adjust the value here for background2 speed
     switch (sliding)
     {
         case KeysToInsanity.Boundary.Left:
             spritePos = new Vector2(spritePos.X - step, spritePos.Y);
             background2Rectangle.X -= step2;
             previousRectangle.X -= step;
             previousRectangle2.X -= step2;
             if (spritePos.X <= 0)
             {
                 sliding = KeysToInsanity.Boundary.None;
                 slide = false;
                 spritePos = new Vector2(0, 0);
                 //background2Rectangle.Location = new Point(-parallax);
             }
             break;
         case KeysToInsanity.Boundary.Right:
             spritePos = new Vector2(spritePos.X + step, spritePos.Y);
             background2Rectangle.X += step2;
             previousRectangle.X += step;
             previousRectangle2.X += step2;
             if (spritePos.X >= 0)
             {
                 sliding = KeysToInsanity.Boundary.None;
                 slide = false;
                 spritePos = new Vector2(0, 0);
                 //background2Rectangle.Location = new Point(-parallax);
             }
             break;
         case KeysToInsanity.Boundary.Top:
             spritePos = new Vector2(spritePos.X, spritePos.Y - step);
             background2Rectangle.Y -= step2;
             previousRectangle.Y -= step;
             previousRectangle2.Y -= step2;
             if (spritePos.Y <= 0)
             {
                 sliding = KeysToInsanity.Boundary.None;
                 slide = false;
                 spritePos = new Vector2(0, 0);
                 //background2Rectangle.Location = new Point(-parallax);
             }
             break;
         case KeysToInsanity.Boundary.Bottom:
             spritePos = new Vector2(spritePos.X, spritePos.Y + step);
             background2Rectangle.Y += step2;
             previousRectangle.Y += step;
             previousRectangle2.Y += step2;
             if (spritePos.Y >= 0)
             {
                 sliding = KeysToInsanity.Boundary.None;
                 slide = false;
                 spritePos = new Vector2(0, 0);
                 //background2Rectangle.Location = new Point(-parallax);
             }
             break;
         default:
             break;
     }
 }
Exemple #4
0
 public void setEnd(int x, int y, KeysToInsanity.Boundary b)
 {
     endX = x;
     endY = y;
     end = b;
 }