Guest User

Pause Code

a guest
Jan 27th, 2015
327
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. ///obj_pauaw
  2. //Create Event
  3. paused = false;
  4. option = 0;
  5. optionmax = 3;
  6. //Arrays
  7. options[0] = "Resume";
  8. options[1] = "Cake";
  9. options[2] = "Exit";
  10.  
  11. //Alarm0
  12. instance_deactivate_all(true);
  13. tile_layer_hide(1000000);
  14. tile_layer_hide(101);
  15. tile_layer_hide(100);
  16. tile_layer_hide(99);
  17. if surface_exists(light)
  18. {
  19.     surface_free(light);
  20. }
  21.  
  22. //Step Event
  23. player_pause = (keyboard_check_pressed(ord('P'))) or (gamepad_button_check_pressed(0, gp_start))
  24. player_enter = ((keyboard_check_pressed(vk_enter))) or (gamepad_button_check_pressed(0, gp_face1))
  25. player_up = ((keyboard_check_pressed(vk_up))) or (gamepad_button_check_pressed(0, gp_padu))
  26. player_down = ((keyboard_check_pressed(vk_down))) or (gamepad_button_check_pressed(0, gp_padd))
  27.  
  28. if (player_pause)
  29. {
  30.     pause();
  31. }
  32.  
  33. if (player_enter)
  34. {
  35. if (!paused) exit;
  36. switch (option) {
  37.  case 0: event_user(0); break; //Resumes the game by executing the code in "User Defined 0"
  38.  case 1: show_message("I like pie!"); break;
  39.  case 2: game_end(); break;
  40.  default: break;
  41. }
  42. option = 0;
  43. }
  44.  
  45. if (player_up)
  46. {
  47. if (paused)
  48. option = ((option-1 mod optionmax) + optionmax) mod optionmax;
  49. }
  50.  
  51. if (player_down)
  52. {
  53. if (paused)
  54. option = (option+1) mod optionmax;
  55. }
  56.  
  57. //Userdefined0 "unpaused" script
  58. //tile_layer_show(1000000);
  59. tile_layer_show(101);
  60. tile_layer_show(100);
  61. tile_layer_show(99);
  62. instance_activate_all();
  63. file_delete(working_directory + "\temp.png");
  64. background_visible[0] = true;
  65. paused = false;
  66. if (!surface_exists(light)) { //Checks to make sure surface exists and if not, then it makes one
  67. light = surface_create(view_wview, view_hview);
  68. }
  69.  
  70. //Draw Event
  71. if (!paused) exit;
  72. draw_set_valign(fa_center);
  73. draw_set_halign(fa_middle);
  74. draw_set_color(c_red);
  75.  
  76. draw_background_stretched(bac_pause, view_xview, view_yview, view_wview, view_hview);
  77. draw_set_alpha(0.75);
  78. draw_rectangle_color(view_xview, view_yview, view_xview+view_wview, view_yview+view_hview, c_black, c_black, c_black, c_black, false)
  79. draw_set_alpha(1);
  80. draw_text(view_xview[0] + view_wview[0] / 2 , view_yview[0] + view_hview[0] / 2 - 50, "PAUSED"); //The -50 is determining the placement of the PAUSED text, this way it is displayed above the menu.
  81.  
  82. //snip
  83.  var xx;
  84.  for (xx=0; xx<optionmax; xx+=1) {
  85.  if (xx == option)
  86.  draw_set_color(c_green);
  87.  else
  88.  draw_set_color(c_gray);
  89.  draw_text(view_xview[0] + view_wview[0] / 2, view_yview[0] + view_hview[0] / 2 + 16 + (xx * 60), options[xx]); //The 60 determines the seperation in pixels from each 'option'
  90. }
  91.  
  92. draw_set_color(c_black);
  93. //snip
  94.  
  95. draw_set_color(c_black);
  96. draw_set_valign(fa_left);
  97. draw_set_halign(fa_left);
Advertisement
Add Comment
Please, Sign In to add comment