Advertisement
SteelGolem

Untitled

Jul 18th, 2019
168
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 4.28 KB | None | 0 0
  1.             // in WindowsGame1.LoadContent()
  2.             // ...
  3.             AnimationFrame[] frames;
  4.             animationLookup = new Dictionary<string, AnimationFrame[]>();
  5.             frames = new AnimationFrame[16];
  6.             for (int f = 0; f < 4; f++) frames[f] = new AnimationFrame("sword_se", +16, +10);
  7.             for (int f = 4; f < 8; f++) frames[f] = new AnimationFrame("sword_e", +16, +2);
  8.             for (int f = 8; f < 12; f++) frames[f] = new AnimationFrame("sword_ne", +10, -10);
  9.             for (int f = 12; f < 16; f++) frames[f] = new AnimationFrame("sword_n", +0, -16);
  10.             animationLookup.Add("sword_swinging_u", frames);
  11.             frames = new AnimationFrame[16];
  12.             for (int f = 0; f < 4; f++) frames[f] = new AnimationFrame("sword_nw", -14, -9);
  13.             for (int f = 4; f < 8; f++) frames[f] = new AnimationFrame("sword_w", -16, +0);
  14.             for (int f = 8; f < 12; f++) frames[f] = new AnimationFrame("sword_sw", -11, +12);
  15.             for (int f = 12; f < 16; f++) frames[f] = new AnimationFrame("sword_s", +0, 16);
  16.             animationLookup.Add("sword_swinging_d", frames);
  17.             frames = new AnimationFrame[16];
  18.             for (int f = 0; f < 4; f++) frames[f] = new AnimationFrame("sword_ne", +10, -8);
  19.             for (int f = 4; f < 8; f++) frames[f] = new AnimationFrame("sword_n", +0, -11);
  20.             for (int f = 8; f < 12; f++) frames[f] = new AnimationFrame("sword_nw", -14, -5);
  21.             for (int f = 12; f < 16; f++) frames[f] = new AnimationFrame("sword_w", -16, +3);
  22.             animationLookup.Add("sword_swinging_l", frames);
  23.             frames = new AnimationFrame[16];
  24.             for (int f = 0; f < 4; f++) frames[f] = new AnimationFrame("sword_nw", -10, -8);
  25.             for (int f = 4; f < 8; f++) frames[f] = new AnimationFrame("sword_n", +0, -11);
  26.             for (int f = 8; f < 12; f++) frames[f] = new AnimationFrame("sword_ne", +14, -5);
  27.             for (int f = 12; f < 16; f++) frames[f] = new AnimationFrame("sword_e", +16, +3);
  28.             animationLookup.Add("sword_swinging_r", frames);
  29.             frames = new AnimationFrame[12];
  30.             for (int f = 0; f < 4; f++) frames[f] = new AnimationFrame("sword_n", +2, -8);
  31.             for (int f = 4; f < 8; f++) frames[f] = new AnimationFrame("sword_n", +2, -16);
  32.             for (int f = 8; f < 12; f++) frames[f] = new AnimationFrame("sword_n", +2, -8);
  33.             animationLookup.Add("sword_stabbing_u", frames);
  34.             frames = new AnimationFrame[12];
  35.             for (int f = 0; f < 4; f++) frames[f] = new AnimationFrame("sword_s", -2, +8);
  36.             for (int f = 4; f < 8; f++) frames[f] = new AnimationFrame("sword_s", -2, +16);
  37.             for (int f = 8; f < 12; f++) frames[f] = new AnimationFrame("sword_s", -2, +8);
  38.             animationLookup.Add("sword_stabbing_d", frames);
  39.             frames = new AnimationFrame[12];
  40.             for (int f = 0; f < 4; f++) frames[f] = new AnimationFrame("sword_w", -8, +3);
  41.             for (int f = 4; f < 8; f++) frames[f] = new AnimationFrame("sword_w", -16, +3);
  42.             for (int f = 8; f < 12; f++) frames[f] = new AnimationFrame("sword_w", -8, +3);
  43.             animationLookup.Add("sword_stabbing_l", frames);
  44.             frames = new AnimationFrame[12];
  45.             for (int f = 0; f < 4; f++) frames[f] = new AnimationFrame("sword_e", +8, +3);
  46.             for (int f = 4; f < 8; f++) frames[f] = new AnimationFrame("sword_e", +16, +3);
  47.             for (int f = 8; f < 12; f++) frames[f] = new AnimationFrame("sword_e", +8, +3);
  48.             animationLookup.Add("sword_stabbing_r", frames);
  49.             // ...
  50.  
  51.         void UpdateSword()
  52.         {
  53.             if (sword.state == "swinging" && sword.stateFrames == 16)
  54.             {
  55.                 sword = null;
  56.                 return;
  57.             }
  58.  
  59.             if (sword.state == "stabbing" && sword.stateFrames == 12)
  60.             {
  61.                 sword = null;
  62.                 return;
  63.             }
  64.  
  65.             AnimationFrame[] frames = animationLookup["sword_" + sword.state + "_" + sword.dir];
  66.             AnimationFrame frame = frames[sword.stateFrames];
  67.             sword.srcRect = frame.srcRect;
  68.             sword.x = player.x + frame.x;
  69.             sword.y = player.y + frame.y;
  70.  
  71.             sword.stateFrames++;
  72.         }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement