Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- [CREATE CODE]
- blackAlpha = 0;
- blackAlphaIncrease = 0.2;
- blackAlphaTimer = 0;
- blackAlphaTimerMax = 2;
- iconFlash = false;
- iconFlashTimer = 0;
- iconFlashTimerMax = 18;
- phase = 0; //0: increasing the black rectangle's alpha
- option = global.currentWeapon;
- oldWeapon = global.weapon;
- resetWeapon = false; //Should we, after exiting the menu, reset our weapon to the weapon that was used before the pause menu was opened?
- with objMegaman event_user(0);
- [[[STEP CODE]]]
- iconFlashTimer ++;
- if iconFlashTimer > iconFlashTimerMax
- {
- switch iconFlash
- {
- case false:
- iconFlash = true;
- iconFlashTimer = 0;
- break;
- case true:
- iconFlash = false;
- iconFlashTimer = 0;
- break;
- }
- }
- switch phase
- {
- case 0: //Fading in
- blackAlphaTimer += 1;
- if blackAlphaTimer >= blackAlphaTimerMax
- {
- blackAlphaTimer = 0;
- blackAlpha += blackAlphaIncrease;
- if blackAlpha >= 1
- phase = 1;
- }
- break;
- case 1: //Fading out
- event_user(0); //Moving the selection
- blackAlphaTimer += 1;
- if blackAlphaTimer >= blackAlphaTimerMax
- {
- blackAlphaTimer = 0;
- blackAlpha -= blackAlphaIncrease;
- if blackAlpha <= 0
- phase = 2;
- }
- break;
- case 2: //Idle
- event_user(0); //Moving the selection
- //Select the weapon/tank
- if global.keyJumpPressed || global.keyPausePressed || global.keyShootPressed
- {
- if option != global.totalWeapons+1 && option != global.totalWeapons+2
- {
- phase = 3;
- global.currentWeapon = option;
- with prtPlayerProjectile instance_destroy();
- with objReflectedProjectile instance_destroy();
- with prtRush instance_destroy();
- with objRushJet instance_destroy(); //Could not be parented to prtRush since it's parented to prtMovingPlatformSolid
- with objMegaman
- {
- if onRushJet == true
- {
- onRushJet = false;
- canMove = true;
- }
- }
- playSFX(sfxMenuSelect);
- }
- else if option == global.totalWeapons+1
- {
- if global.eTanks > 0 && global._health < 28
- {
- option = 99; //Nothing selected
- phase = 5;
- global.eTanks -= 1;
- eTankTimer = 0;
- sound_loop(sfxEnergyRestore);
- }
- else
- {
- playSFX(sfxError);
- }
- }
- else if option == global.totalWeapons+2
- {
- if global.mTanks > 0
- {
- var proceed;
- proceed = false;
- for(i = 1; i <= global.totalWeapons; i += 1)
- {
- if ceil(global.ammo[i]) < 28
- proceed = true;
- }
- if ceil(global._health) < 28
- proceed = true;
- if proceed == true //If proceed is still false after the past calculations, it seems there is nothing to fill
- {
- option = 99; //Nothing selected
- phase = 6;
- global.mTanks -= 1;
- eTankTimer = 0;
- sound_loop(sfxEnergyRestore);
- }
- else
- {
- playSFX(sfxError);
- }
- }
- else
- {
- playSFX(sfxError);
- }
- }
- }
- break;
- case 3: //Fading out
- blackAlphaTimer += 1;
- if blackAlphaTimer >= blackAlphaTimerMax
- {
- blackAlphaTimer = 0;
- blackAlpha += blackAlphaIncrease;
- if blackAlpha >= 1
- {
- phase = 4;
- if resetWeapon == true
- {
- global.weapon = oldWeapon;
- with objMegaman event_user(0);
- }
- }
- }
- break;
- case 4: //Fading in
- blackAlphaTimer += 1;
- if blackAlphaTimer >= blackAlphaTimerMax
- {
- blackAlphaTimer = 0;
- blackAlpha -= blackAlphaIncrease;
- if blackAlpha <= 0
- {
- global.frozen = false;
- instance_destroy();
- }
- }
- break;
- case 5: //E-Tank restoring health
- if global._health < 28
- {
- eTankTimer += 1;
- if eTankTimer >= 3
- {
- global._health += 1;
- if global._health > 28
- global._health = 28;
- eTankTimer = 0;
- }
- }
- else
- {
- eTankTimer = 0;
- phase = 2;
- option = oldWeapon;
- global.weapon = oldWeapon;
- with objMegaman event_user(0);
- sound_stop(sfxEnergyRestore);
- }
- break;
- case 6: //M-Tank restoring energy
- 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
- if eTankTimer >= 3
- {
- eTankTimer = 0;
- var proceed;
- proceed = false;
- for(i = 1; i <= global.totalWeapons; i += 1)
- {
- if global.ammo[i] < 28
- {
- global.ammo[i] += 1;
- if global.ammo[i] > 28
- global.ammo[i] = 28;
- proceed = true;
- }
- }
- if global._health < 28
- {
- global._health += 1;
- if global._health > 28
- global._health = 28;
- proceed = true;
- }
- if proceed == false //If proceed is still false after all these calculations, it means everything has been filled
- {
- eTankTimer = 0;
- phase = 2;
- option = oldWeapon;
- global.weapon = oldWeapon;
- with objMegaman event_user(0);
- sound_stop(sfxEnergyRestore);
- }
- }
- break;
- }
- [[[USER DEFINED CODE 1]]]
- if global.keyDownPressed
- {
- playSFX(sfxMenuMove);
- iconFlash = true;
- iconFlashTimer = 0;
- var loops;
- loops = 0; //How many times the while-loop has been passed through
- while global.weaponUnlocked[option] == false || loops == 0
- {
- //The bottom of the left column and the right column;
- //when the bottom of the left column is selected and we press down, we want to select the E-tank
- //for the right column, we want to select the M-tank
- if option != 5 && option != global.totalWeapons
- {
- option += 1;
- if option < 0
- option = global.totalWeapons;
- else if option > global.totalWeapons
- option = 0;
- }
- else if option == 5 //The bottom of the left column
- {
- option = global.totalWeapons+1; //E-tank
- }
- else //The bottom of the right column
- {
- option = global.totalWeapons+2; //M-tank
- }
- if option != global.totalWeapons+1 && option != global.totalWeapons+2
- {
- global.weapon = global.weaponSlot[option];
- with objMegaman event_user(0);
- }
- loops += 1;
- }
- }
- else if global.keyUpPressed
- {
- playSFX(sfxMenuMove);
- iconFlash = true;
- iconFlashTimer = 0;
- var loops;
- loops = 0;
- while global.weaponUnlocked[option] == false || loops == 0
- {
- if option == global.totalWeapons+2 //M-tank
- {
- option = global.totalWeapons; //The bottom weapon of the right column
- }
- else if option == global.totalWeapons+1 //E-tank
- {
- if global.totalWeapons > 5
- option = 5; //The bottom weapon of the left column
- else
- option = global.totalWeapons;
- }
- else if option == 6 //The top weapon of the right column
- {
- option = global.totalWeapons+2; //M-tank
- }
- else if option == 0 //The top weapon of the left column
- {
- option = global.totalWeapons+1; //E-tank
- }
- else
- {
- option -= 1;
- if option < 0
- option = global.totalWeapons+1;
- else if option > global.totalWeapons+1
- option = 0;
- }
- if option != global.totalWeapons+1 && option != global.totalWeapons+2
- {
- global.weapon = global.weaponSlot[option];
- with objMegaman event_user(0);
- }
- loops += 1;
- }
- }
- if global.keyLeftPressed || global.keyRightPressed
- {
- if global.totalWeapons > 5 //If there is a right column of weapons
- && option != global.totalWeapons+1 && option != global.totalWeapons+2 //When the E-tank or M-tank is not selected
- {
- if option > 5
- option -= 6;
- else
- option += 6;
- if option > global.totalWeapons
- option = global.totalWeapons;
- else if option < 0
- option = 0;
- playSFX(sfxMenuMove);
- iconFlash = true;
- iconFlashTimer = 0;
- }
- //E-Tanks and M-Tanks
- if option == global.totalWeapons+1 || option == global.totalWeapons+2
- {
- if option == global.totalWeapons+1
- option = global.totalWeapons+2;
- else
- option = global.totalWeapons+1;
- playSFX(sfxMenuMove);
- iconFlash = true;
- iconFlashTimer = 0;
- }
- while global.weaponUnlocked[option] == false
- {
- if option == 6
- option = global.totalWeapons;
- else if option == 0
- {
- if global.totalWeapons > 5
- option = 5;
- else
- option = global.totalWeapons;
- }
- else
- option -= 1;
- }
- if option != global.totalWeapons+1 && option != global.totalWeapons+2
- {
- global.weapon = global.weaponSlot[option];
- with objMegaman event_user(0);
- }
- }
- [[[DRAW CODE]]]
- var oldCol, oldAlp;
- oldCol = draw_get_color();
- oldAlp = draw_get_alpha();
- //Menu
- if (phase >= 1 && phase <= 3) || phase == 5 || phase == 6
- {
- draw_set_font(global.MM3font);
- //BG
- draw_set_color(c_white);
- draw_set_alpha(1);
- draw_sprite(sprPauseMenuBG, 0, view_xview[0], view_yview[0]);
- //Life
- draw_sprite(sprLifeNumber,global._lives,112,0);
- //Icons, ammo bars and names
- var maxI;
- 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)
- maxI = 5;
- else
- maxI = global.totalWeapons;
- //Left column
- for(i = 0; i <= maxI; i += 1)
- {
- if global.weaponUnlocked[i] == true
- {
- //Icon
- if option == i
- if iconFlash = false
- draw_sprite_ext(sprWeaponIcons, global.weaponSlot[i], view_xview[0]+16, view_yview[0]+16+i*16, 1, 1, 0, c_white, 1);
- else
- draw_sprite_ext(sprWeaponIcons, global.weaponSlot[i], view_xview[0]+16, view_yview[0]+16+i*16, 1, 1, 0, c_white, 1);
- //Ammo bar (Fix?)
- var ammo;
- if i == 0
- ammo = global._health;
- else
- ammo = ceil(global.ammo[i]);
- if option == i
- draw_sprite_ext(sprPauseMenuBar, ammo, view_xview[0]+16+24, view_yview[0]+16+8+i*16, 1, 1, 0, c_white, 1);
- //else
- //draw_sprite_ext(sprPauseMenuBarGray, ammo, view_xview[0]+32+32, view_yview[0]+24+i*19+8, 1, 1, 0, c_white, 1);
- //The life bar at the bottom left
- if i == 0
- draw_sprite_ext(sprPauseMenuBarBig, global._health, view_xview[0]+56, view_yview[0]+0, 1, 1, 0, c_white, 1);
- }
- }
- //Right column (TODO)
- if global.totalWeapons > 5
- {
- for(i = 0; i < global.totalWeapons-5; i += 1)
- {
- if global.weaponUnlocked[i+6] == true
- {
- //Icon
- if option == i+6
- if iconFlash = false
- draw_sprite_ext(sprWeaponIcons, global.weaponSlot[i], view_xview[0]+88, view_yview[0]+16+i*16, 1, 1, 0, c_white, 1);
- else
- draw_sprite_ext(sprWeaponIcons, global.weaponSlot[i], view_xview[0]+88, view_yview[0]+16+i*16, 1, 1, 0, c_white, 1);
- //Ammo bar (TODO)
- var ammo;
- ammo = ceil(global.ammo[i+6]);
- if option == i+6
- draw_sprite_ext(sprPauseMenuBar, ammo, view_xview[0]+88+24, view_yview[0]+16+8+i*16, 1, 1, 0, c_white, 1);
- //else
- //draw_sprite_ext(sprPauseMenuBarGray, ammo, view_xview[0]+88+32, view_yview[0]+24+i*19+8, 1, 1, 0, c_white, 1);
- }
- }
- }
- //E-Tank (TODO)
- if option == global.totalWeapons+1
- {
- if iconFlash = false
- draw_sprite_ext(sprPauseETank, global.weaponSlot[i], view_xview[0]+88, view_yview[0]+132, 1, 1, 0, c_white, 1);
- else
- draw_sprite_ext(sprPauseETank, global.weaponSlot[i], view_xview[0]+88, view_yview[0]+132, 1, 1, 0, c_white, 1);
- }
- //M-Tank (TODO)
- else if option == global.totalWeapons+2
- {
- if iconFlash = false
- draw_sprite_ext(sprPauseMTank, global.weaponSlot[i], view_xview[0]+120, view_yview[0]+132, 1, 1, 0, c_white, 1);
- else
- draw_sprite_ext(sprPauseMTank, global.weaponSlot[i], view_xview[0]+120, view_yview[0]+132, 1, 1, 0, c_white, 1);
- }
- draw_text(view_xview[0]+104, view_yview[0]+132,string(global.eTanks));
- draw_text(view_xview[0]+136, view_yview[0]+132,string(global.mTanks));
- }
- //Black (MORE LIKE WHITE) rectangle
- draw_set_color(c_white);
- draw_set_alpha(blackAlpha);
- draw_rectangle(view_xview[0], view_yview[0], view_xview[0]+view_wview[0], view_yview[0]+view_hview[0], false);
- draw_set_color(oldCol);
- draw_set_alpha(oldAlp);
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement