Ember

State machine

Oct 5th, 2012
143
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. //Step
  2. switch(Standing)
  3. {
  4.     case 1: //Standing
  5.       switch(State)
  6.       {
  7.           case 0: //Idle
  8.             if LeftButton
  9.             {
  10.                 Sprite = Attack1A;
  11.                 Frame = 0;
  12.                 State = 1;
  13.                 ComboLight = 0;
  14.                 ComboHeavy = 0;
  15.             }
  16.             if RightButton
  17.             {
  18.                 Sprite = Attack2A;
  19.                 Frame = 0;
  20.                 State = 1;
  21.                 ComboLight = 0;
  22.                 ComboHeavy = 0;
  23.             }
  24.         break;
  25.  
  26.         case 1: //Attacking
  27.           if LeftButton {ComboLight += 1;}
  28.           if RightButton {ComboHeavy += 1;}
  29.         break;
  30.       }
  31.     break;
  32. }
  33.  
  34. //Frame processing
  35. if Frame+FrameSpeed >= Frames
  36. {
  37.     switch(Sprite)
  38.     {
  39.         case Idle:
  40.           Frame = 0;
  41.         break;
  42.        
  43.         default:
  44.           Sprite = Idle;
  45.           Frame = 0;
  46.           Combo = 0;
  47.           State = 0;
  48.         break;
  49.     }
  50. }
  51. else
  52. {
  53.     Frame += 1/3;
  54.     switch(Sprite)
  55.     {
  56.         case Idle:
  57.           //Do nothing
  58.         break;
  59.        
  60.         case Attack1A:
  61.           if floor(Frame) = 5
  62.           {
  63.               if (ComboLight = 1 and ComboHeavy = 0)
  64.               {
  65.                   Sprite = Attack1B;
  66.                   Frame = 0;
  67.                   ComboLight = 0;
  68.                   ComboHeavy = 0;
  69.               }
  70.               else if (ComboLight = 0 and ComboHeavy = 1)
  71.               {
  72.                   Sprite = AttackCombo1A1;
  73.                   Frame = 0;
  74.                   ComboLight = 0;
  75.                   ComboHeavy = 0;
  76.               }
  77.           }
  78.         break;
  79.        
  80.         case Attack1B:
  81.           if floor(Frame) = 6
  82.               if (ComboLight = 1 and ComboHeavy = 0)
  83.               {
  84.                   Sprite = Attack1C;
  85.                   Frame = 0;
  86.                   ComboLight = 0;
  87.                   ComboHeavy = 0;
  88.               }
  89.               else if (ComboLight = 0 and ComboHeavy = 1)
  90.               {
  91.                   Sprite = AttackCombo1B;
  92.                   Frame = 0;
  93.                   ComboLight = 0;
  94.                   ComboHeavy = 0;
  95.               }
  96.         break;
  97.        
  98.         case Attack2A:
  99.           if floor(Frame) = 4
  100.               if (ComboLight = 1 and ComboHeavy = 0)
  101.               {
  102.                   Sprite = AttackCombo2A1;
  103.                   Frame = 0;
  104.                   ComboLight = 0;
  105.                   ComboHeavy = 0;
  106.               }
  107.               else if (ComboLight = 0 and ComboHeavy = 1)
  108.               {
  109.                   Sprite = Attack2B;
  110.                   Frame = 0;
  111.                   ComboLight = 0;
  112.                   ComboHeavy = 0;
  113.               }
  114.         break;
  115.        
  116.         case Attack2B:
  117.           if floor(Frame) = 4
  118.               /*if (ComboLight = 1 and ComboHeavy = 0)
  119.               {
  120.                   Sprite = AttackCombo2B1;
  121.                   Frame = 0;
  122.                   ComboLight = 0;
  123.                   ComboHeavy = 0;
  124.               }
  125.               else */if (ComboLight = 0 and ComboHeavy = 1)
  126.               {
  127.                   Sprite = Attack2B;
  128.                   Frame = 0;
  129.                   ComboLight = 0;
  130.                   ComboHeavy = 0;
  131.               }
  132.         break;
  133.        
  134.         case AttackCombo1A1:
  135.           if floor(Frame) = 7
  136.               if (ComboLight = 0 and ComboHeavy = 1)
  137.               {
  138.                   Sprite = AttackCombo1A2;
  139.                   Frame = 0;
  140.                   ComboLight = 0;
  141.                   ComboHeavy = 0;
  142.               }
  143.         break;
  144.        
  145.         case AttackCombo2A1:
  146.           if (floor(Frame) = 4 or floor(Frame) = 5 or floor(Frame) = 6 or floor(Frame) = 7)
  147.               if (ComboLight = 1 or ComboHeavy = 1)
  148.               {
  149.                   Sprite = AttackCombo2A2;
  150.                   Frame = 0;
  151.                   ComboLight = 0;
  152.                   ComboHeavy = 0;
  153.               }
  154.         break;
  155.     }
  156. }
Advertisement
Add Comment
Please, Sign In to add comment