Esempio n. 1
0
        public void AdjustPlayerPosition(Player p, int tilesize, int incrementDecrement)
        {
            if (p.Position.X != 0 || p.Position.Y != 0)
              {
            // Get current tile coordinates
            // Calculate position from the right base of the player (center base is glitchy)
            Vector2 tilePosition = new Vector2(
              (p.Position.X + p.DestRect.Width) / tilesize,
              (p.Position.Y + p.DestRect.Height) / tilesize
              );

            p.Position.X = (tilePosition.X * (tilesize + incrementDecrement)) - p.DestRect.Width;
            p.Position.Y = (tilePosition.Y * (tilesize + incrementDecrement)) - p.DestRect.Height;
            p.DestRect.X = (int)Math.Round(p.Position.X);
            p.DestRect.Y = (int)Math.Round(p.Position.Y);
              }
        }
Esempio n. 2
0
 public void LoadCharacter(Texture2D sprite)
 {
     SpritePlayer = sprite;
       player = new Player(sprite, new Vector2(512, 0));
 }