Advertisement
Guest User

Untitled

a guest
Jan 10th, 2018
93
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. [CREATE CODE]
  2. blackAlpha = 0;
  3. blackAlphaIncrease = 0.2;
  4. blackAlphaTimer = 0;
  5. blackAlphaTimerMax = 2;
  6.  
  7. iconFlash = false;
  8. iconFlashTimer = 0;
  9. iconFlashTimerMax = 18;
  10.  
  11. phase = 0;  //0: increasing the black rectangle's alpha
  12. option = global.currentWeapon;
  13. oldWeapon = global.weapon;
  14. resetWeapon = false; //Should we, after exiting the menu, reset our weapon to the weapon that was used before the pause menu was opened?
  15.  
  16. with objMegaman event_user(0);
  17.  
  18. [[[STEP CODE]]]
  19. iconFlashTimer ++;
  20. if iconFlashTimer > iconFlashTimerMax
  21. {
  22.     switch iconFlash
  23.     {
  24.         case false:
  25.             iconFlash = true;
  26.             iconFlashTimer = 0;
  27.             break;
  28.            
  29.         case true:
  30.             iconFlash = false;
  31.             iconFlashTimer = 0;
  32.             break;
  33.     }
  34. }
  35.  
  36. switch phase
  37. {
  38.     case 0: //Fading in
  39.         blackAlphaTimer += 1;
  40.         if blackAlphaTimer >= blackAlphaTimerMax
  41.         {
  42.             blackAlphaTimer = 0;
  43.             blackAlpha += blackAlphaIncrease;
  44.             if blackAlpha >= 1
  45.                 phase = 1;
  46.         }
  47.     break;
  48.    
  49.     case 1: //Fading out
  50.         event_user(0); //Moving the selection
  51.            
  52.         blackAlphaTimer += 1;
  53.         if blackAlphaTimer >= blackAlphaTimerMax
  54.         {
  55.             blackAlphaTimer = 0;
  56.             blackAlpha -= blackAlphaIncrease;
  57.             if blackAlpha <= 0
  58.                 phase = 2;
  59.         }
  60.     break;
  61.    
  62.     case 2: //Idle
  63.         event_user(0); //Moving the selection
  64.            
  65.        
  66.         //Select the weapon/tank
  67.         if global.keyJumpPressed || global.keyPausePressed || global.keyShootPressed
  68.         {
  69.             if option != global.totalWeapons+1 && option != global.totalWeapons+2
  70.             {
  71.                 phase = 3;
  72.                 global.currentWeapon = option;
  73.                 with prtPlayerProjectile instance_destroy();
  74.                 with objReflectedProjectile instance_destroy();
  75.                 with prtRush instance_destroy();
  76.                 with objRushJet instance_destroy(); //Could not be parented to prtRush since it's parented to prtMovingPlatformSolid
  77.                 with objMegaman
  78.                 {
  79.                     if onRushJet == true
  80.                     {
  81.                         onRushJet = false;
  82.                         canMove = true;
  83.                     }
  84.                 }
  85.                
  86.                 playSFX(sfxMenuSelect);
  87.             }
  88.             else if option == global.totalWeapons+1
  89.             {
  90.                 if global.eTanks > 0 && global._health < 28
  91.                 {
  92.                     option = 99; //Nothing selected
  93.                     phase = 5;
  94.                     global.eTanks -= 1;
  95.                     eTankTimer = 0;
  96.                     sound_loop(sfxEnergyRestore);
  97.                 }
  98.                 else
  99.                 {
  100.                     playSFX(sfxError);
  101.                 }
  102.             }
  103.             else if option == global.totalWeapons+2
  104.             {
  105.                 if global.mTanks > 0
  106.                 {
  107.                     var proceed;
  108.                     proceed = false;
  109.                     for(i = 1; i <= global.totalWeapons; i += 1)
  110.                     {
  111.                         if ceil(global.ammo[i]) < 28
  112.                             proceed = true;
  113.                     }
  114.                    
  115.                     if ceil(global._health) < 28
  116.                         proceed = true;
  117.                        
  118.                     if proceed == true //If proceed is still false after the past calculations, it seems there is nothing to fill
  119.                     {
  120.                         option = 99; //Nothing selected
  121.                         phase = 6;
  122.                         global.mTanks -= 1;
  123.                         eTankTimer = 0;
  124.                         sound_loop(sfxEnergyRestore);
  125.                     }
  126.                     else
  127.                     {
  128.                         playSFX(sfxError);
  129.                     }
  130.                 }
  131.                 else
  132.                 {
  133.                     playSFX(sfxError);
  134.                 }
  135.             }
  136.         }
  137.     break;
  138.    
  139.     case 3: //Fading out
  140.         blackAlphaTimer += 1;
  141.         if blackAlphaTimer >= blackAlphaTimerMax
  142.         {
  143.             blackAlphaTimer = 0;
  144.             blackAlpha += blackAlphaIncrease;
  145.             if blackAlpha >= 1
  146.             {
  147.                 phase = 4;
  148.                 if resetWeapon == true
  149.                 {
  150.                     global.weapon = oldWeapon;
  151.                     with objMegaman event_user(0);
  152.                 }
  153.             }
  154.         }
  155.     break;
  156.    
  157.     case 4: //Fading in
  158.         blackAlphaTimer += 1;
  159.         if blackAlphaTimer >= blackAlphaTimerMax
  160.         {
  161.             blackAlphaTimer = 0;
  162.             blackAlpha -= blackAlphaIncrease;
  163.             if blackAlpha <= 0
  164.             {
  165.                 global.frozen = false;
  166.                 instance_destroy();
  167.             }
  168.         }
  169.     break;
  170.    
  171.     case 5: //E-Tank restoring health
  172.         if global._health < 28
  173.         {
  174.             eTankTimer += 1;
  175.             if eTankTimer >= 3
  176.             {
  177.                 global._health += 1;
  178.                 if global._health > 28
  179.                     global._health = 28;
  180.                 eTankTimer = 0;
  181.             }
  182.         }
  183.         else
  184.         {
  185.             eTankTimer = 0;
  186.             phase = 2;
  187.             option = oldWeapon;
  188.             global.weapon = oldWeapon;
  189.             with objMegaman event_user(0);
  190.             sound_stop(sfxEnergyRestore);
  191.         }
  192.     break;
  193.    
  194.     case 6: //M-Tank restoring energy
  195.         eTankTimer += 1; //While it's technically an M-tank, we can use the same timer as the E-tank without any problems, since the two can't fill at the same time
  196.         if eTankTimer >= 3
  197.         {
  198.             eTankTimer = 0;
  199.            
  200.             var proceed;
  201.             proceed = false;
  202.             for(i = 1; i <= global.totalWeapons; i += 1)
  203.             {
  204.                 if global.ammo[i] < 28
  205.                 {
  206.                     global.ammo[i] += 1;
  207.                     if global.ammo[i] > 28
  208.                         global.ammo[i] = 28;
  209.                        
  210.                     proceed = true;
  211.                 }
  212.             }
  213.            
  214.             if global._health < 28
  215.             {
  216.                 global._health += 1;
  217.                 if global._health > 28
  218.                     global._health = 28;
  219.                    
  220.                 proceed = true;
  221.             }
  222.            
  223.             if proceed == false //If proceed is still false after all these calculations, it means everything has been filled
  224.             {
  225.                 eTankTimer = 0;
  226.                 phase = 2;
  227.                 option = oldWeapon;
  228.                 global.weapon = oldWeapon;
  229.                 with objMegaman event_user(0);
  230.                 sound_stop(sfxEnergyRestore);
  231.             }
  232.         }              
  233.     break;
  234. }
  235.  
  236. [[[USER DEFINED CODE 1]]]
  237. if global.keyDownPressed
  238. {
  239.     playSFX(sfxMenuMove);
  240.     iconFlash = true;
  241.     iconFlashTimer = 0;
  242.    
  243.     var loops;
  244.     loops = 0; //How many times the while-loop has been passed through
  245.    
  246.     while global.weaponUnlocked[option] == false || loops == 0
  247.     {
  248.         //The bottom of the left column and the right column;
  249.         //when the bottom of the left column is selected and we press down, we want to select the E-tank
  250.         //for the right column, we want to select the M-tank
  251.         if option != 5 && option != global.totalWeapons
  252.         {
  253.             option += 1;
  254.             if option < 0
  255.                 option = global.totalWeapons;
  256.             else if option > global.totalWeapons
  257.                 option = 0;
  258.         }
  259.         else if option == 5 //The bottom of the left column
  260.         {
  261.             option = global.totalWeapons+1; //E-tank
  262.         }
  263.         else //The bottom of the right column
  264.         {
  265.             option = global.totalWeapons+2; //M-tank
  266.         }
  267.            
  268.         if option != global.totalWeapons+1 && option != global.totalWeapons+2
  269.         {
  270.             global.weapon = global.weaponSlot[option];
  271.             with objMegaman event_user(0);
  272.         }
  273.        
  274.         loops += 1;
  275.     }
  276. }
  277. else if global.keyUpPressed
  278. {
  279.     playSFX(sfxMenuMove);
  280.     iconFlash = true;
  281.     iconFlashTimer = 0;
  282.    
  283.     var loops;
  284.     loops = 0;
  285.    
  286.     while global.weaponUnlocked[option] == false || loops == 0
  287.     {
  288.         if option == global.totalWeapons+2 //M-tank
  289.         {
  290.             option = global.totalWeapons; //The bottom weapon of the right column
  291.         }
  292.         else if option == global.totalWeapons+1 //E-tank
  293.         {
  294.             if global.totalWeapons > 5
  295.                 option = 5; //The bottom weapon of the left column
  296.             else
  297.                 option = global.totalWeapons;
  298.         }
  299.         else if option == 6 //The top weapon of the right column
  300.         {
  301.             option = global.totalWeapons+2; //M-tank
  302.         }
  303.         else if option == 0 //The top weapon of the left column
  304.         {
  305.             option = global.totalWeapons+1; //E-tank
  306.         }
  307.         else
  308.         {
  309.             option -= 1;
  310.             if option < 0
  311.                 option = global.totalWeapons+1;
  312.             else if option > global.totalWeapons+1
  313.                 option = 0;
  314.         }
  315.            
  316.         if option != global.totalWeapons+1 && option != global.totalWeapons+2
  317.         {
  318.             global.weapon = global.weaponSlot[option];
  319.             with objMegaman event_user(0);
  320.         }
  321.        
  322.         loops += 1;
  323.     }
  324. }
  325.  
  326. if global.keyLeftPressed || global.keyRightPressed
  327. {
  328.     if global.totalWeapons > 5 //If there is a right column of weapons
  329.     && option != global.totalWeapons+1 && option != global.totalWeapons+2 //When the E-tank or M-tank is not selected
  330.     {
  331.         if option > 5
  332.             option -= 6;
  333.         else
  334.             option += 6;
  335.            
  336.         if option > global.totalWeapons
  337.             option = global.totalWeapons;
  338.         else if option < 0
  339.             option = 0;
  340.            
  341.         playSFX(sfxMenuMove);
  342.         iconFlash = true;
  343.         iconFlashTimer = 0;
  344.     }
  345.    
  346.     //E-Tanks and M-Tanks
  347.     if option == global.totalWeapons+1 || option == global.totalWeapons+2
  348.     {
  349.         if option == global.totalWeapons+1
  350.             option = global.totalWeapons+2;
  351.         else
  352.             option = global.totalWeapons+1;
  353.            
  354.         playSFX(sfxMenuMove);
  355.         iconFlash = true;
  356.         iconFlashTimer = 0;
  357.     }
  358.    
  359.    
  360.     while global.weaponUnlocked[option] == false
  361.     {
  362.         if option == 6
  363.             option = global.totalWeapons;
  364.         else if option == 0
  365.         {
  366.             if global.totalWeapons > 5
  367.                 option = 5;
  368.             else
  369.                 option = global.totalWeapons;
  370.         }
  371.         else    
  372.             option -= 1;
  373.     }
  374.    
  375.     if option != global.totalWeapons+1 && option != global.totalWeapons+2
  376.     {
  377.         global.weapon = global.weaponSlot[option];
  378.         with objMegaman event_user(0);
  379.     }
  380. }
  381.  
  382. [[[DRAW CODE]]]
  383. var oldCol, oldAlp;
  384. oldCol = draw_get_color();
  385. oldAlp = draw_get_alpha();
  386.  
  387.  
  388. //Menu
  389. if (phase >= 1 && phase <= 3) || phase == 5 || phase == 6
  390. {
  391.     draw_set_font(global.MM3font);
  392.    
  393.     //BG
  394.     draw_set_color(c_white);
  395.     draw_set_alpha(1);
  396.     draw_sprite(sprPauseMenuBG, 0, view_xview[0], view_yview[0]);
  397.    
  398.     //Life
  399.     draw_sprite(sprLifeNumber,global._lives,112,0);
  400.    
  401.     //Icons, ammo bars and names
  402.     var maxI;
  403.     if global.totalWeapons > 5 //a maximum of 6 weapons in the left column (0 is also a valid weapon ID, hence 5 instead of 6)
  404.         maxI = 5;
  405.     else
  406.         maxI = global.totalWeapons;
  407.        
  408.     //Left column
  409.     for(i = 0; i <= maxI; i += 1)
  410.     {
  411.         if global.weaponUnlocked[i] == true
  412.         {
  413.             //Icon
  414.             if option == i
  415.                 if iconFlash = false
  416.                     draw_sprite_ext(sprWeaponIcons, global.weaponSlot[i], view_xview[0]+16, view_yview[0]+16+i*16, 1, 1, 0, c_white, 1);
  417.             else
  418.                 draw_sprite_ext(sprWeaponIcons, global.weaponSlot[i], view_xview[0]+16, view_yview[0]+16+i*16, 1, 1, 0, c_white, 1);
  419.                
  420.             //Ammo bar (Fix?)
  421.             var ammo;
  422.             if i == 0
  423.                 ammo = global._health;
  424.             else
  425.                 ammo = ceil(global.ammo[i]);
  426.                
  427.             if option == i
  428.                 draw_sprite_ext(sprPauseMenuBar, ammo, view_xview[0]+16+24, view_yview[0]+16+8+i*16, 1, 1, 0, c_white, 1);
  429.             //else
  430.                 //draw_sprite_ext(sprPauseMenuBarGray, ammo, view_xview[0]+32+32, view_yview[0]+24+i*19+8, 1, 1, 0, c_white, 1);
  431.            
  432.             //The life bar at the bottom left
  433.             if i == 0
  434.                 draw_sprite_ext(sprPauseMenuBarBig, global._health, view_xview[0]+56, view_yview[0]+0, 1, 1, 0, c_white, 1);
  435.         }
  436.     }
  437.    
  438.     //Right column (TODO)
  439.     if global.totalWeapons > 5
  440.     {
  441.         for(i = 0; i < global.totalWeapons-5; i += 1)
  442.         {
  443.             if global.weaponUnlocked[i+6] == true
  444.             {
  445.                 //Icon
  446.                 if option == i+6
  447.                     if iconFlash = false
  448.                         draw_sprite_ext(sprWeaponIcons, global.weaponSlot[i], view_xview[0]+88, view_yview[0]+16+i*16, 1, 1, 0, c_white, 1);
  449.                     else
  450.                         draw_sprite_ext(sprWeaponIcons, global.weaponSlot[i], view_xview[0]+88, view_yview[0]+16+i*16, 1, 1, 0, c_white, 1);
  451.                    
  452.                 //Ammo bar (TODO)
  453.                 var ammo;
  454.                 ammo = ceil(global.ammo[i+6]);
  455.                    
  456.                 if option == i+6
  457.                     draw_sprite_ext(sprPauseMenuBar, ammo, view_xview[0]+88+24, view_yview[0]+16+8+i*16, 1, 1, 0, c_white, 1);
  458.                 //else
  459.                     //draw_sprite_ext(sprPauseMenuBarGray, ammo, view_xview[0]+88+32, view_yview[0]+24+i*19+8, 1, 1, 0, c_white, 1);
  460.             }
  461.         }
  462.     }
  463.    
  464.     //E-Tank (TODO)
  465.     if option == global.totalWeapons+1
  466.     {
  467.         if iconFlash = false
  468.             draw_sprite_ext(sprPauseETank, global.weaponSlot[i], view_xview[0]+88, view_yview[0]+132, 1, 1, 0, c_white, 1);
  469.         else
  470.             draw_sprite_ext(sprPauseETank, global.weaponSlot[i], view_xview[0]+88, view_yview[0]+132, 1, 1, 0, c_white, 1);
  471.     }
  472.    
  473.     //M-Tank (TODO)
  474.     else if option == global.totalWeapons+2
  475.     {
  476.         if iconFlash = false
  477.             draw_sprite_ext(sprPauseMTank, global.weaponSlot[i], view_xview[0]+120, view_yview[0]+132, 1, 1, 0, c_white, 1);
  478.         else
  479.             draw_sprite_ext(sprPauseMTank, global.weaponSlot[i], view_xview[0]+120, view_yview[0]+132, 1, 1, 0, c_white, 1);
  480.     }
  481.    
  482.     draw_text(view_xview[0]+104, view_yview[0]+132,string(global.eTanks));
  483.     draw_text(view_xview[0]+136, view_yview[0]+132,string(global.mTanks));
  484. }
  485.  
  486.  
  487. //Black (MORE LIKE WHITE) rectangle
  488. draw_set_color(c_white);
  489. draw_set_alpha(blackAlpha);
  490. draw_rectangle(view_xview[0], view_yview[0], view_xview[0]+view_wview[0], view_yview[0]+view_hview[0], false);
  491.  
  492.  
  493. draw_set_color(oldCol);
  494. draw_set_alpha(oldAlp);
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement