GML How to select different arrays?

T

tijeseffff

Guest
I want to have a variable which has a name of array I want to use.
How I can do this?
 
T

tijeseffff

Guest
And how to refference to the array which is in the variable?
 

FrostyCat

Redemption Seeker
If you have a name reference in string form, use variable_global_get() or variable_instance_get() to get at the array, then subindex off it.

Assuming that you have something like this:
Code:
global.example = ["hello", "world"];
Example get using a string name:
Code:
var arr = variable_global_get("example");
show_message(arr[0]); // hello
Example set using a string name:
Code:
var arr = variable_global_get("example");
arr[@0] = "goodbye";
show_message(global.example[0]); // goodbye
 
T

tijeseffff

Guest
If you have a name reference in string form, use variable_global_get() or variable_instance_get() to get at the array, then subindex off it.

Assuming that you have something like this:
Code:
global.example = ["hello", "world"];
Example get using a string name:
Code:
var arr = variable_global_get("example");
show_message(arr[0]); // hello
Example set using a string name:
Code:
var arr = variable_global_get("example");
arr[@0] = "goodbye";
show_message(global.example[0]); // goodbye
Eh, I have a menu array,
menu[0] menu[1] but I will try that.
 
T

tijeseffff

Guest
If you have a name reference in string form, use variable_global_get() or variable_instance_get() to get at the array, then subindex off it.

Assuming that you have something like this:
Code:
global.example = ["hello", "world"];
Example get using a string name:
Code:
var arr = variable_global_get("example");
show_message(arr[0]); // hello
Example set using a string name:
Code:
var arr = variable_global_get("example");
arr[@0] = "goodbye";
show_message(global.example[0]); // goodbye
I am using GM:S 1.4 so I can't use global.exm = ["1", "2"]; vars.
 

Dupletor

Member
Code:
arr[@0] = "goodbye";
What does "@" do?
Edit: Found out about the accessor, but still not sure how it helps. It feels unnecessary unless for some optimization magic. I've worked with arrays without it naturally and it's not obligatory like the ds_list pipe.
 
If you are referencing a var array created in a script that pulls its data from another array stored somewhere else the @ accessor makes sure you're changing the values of the array stored somewhere else, rather than the values in the temp array you created in the script.
 
T

tijeseffff

Guest
If you are referencing a var array created in a script that pulls its data from another array stored somewhere else the @ accessor makes sure you're changing the values of the array stored somewhere else, rather than the values in the temp array you created in the script.
I am using GM:S 1.4. Array vars are not accessible to me. Do you know a different way?
 
What do you mean they are not accessible to you? Arrays are basically the same between gms1.4 and gms2...Do you know how arrays work properly? Do you know what a var is? (Also, I was responding to the person above my previous post, not to you).
 

Dupletor

Member
If you are referencing a var array created in a script that pulls its data from another array stored somewhere else the @ accessor makes sure you're changing the values of the array stored somewhere else, rather than the values in the temp array you created in the script.
It also happens without the @, if you call the script through an instance that contains the array. All the variables that are present in the calling instance are also present in the script.
I guess it was not always that way?
 
T

tijeseffff

Guest
What do you mean they are not accessible to you? Arrays are basically the same between gms1.4 and gms2...Do you know how arrays work properly? Do you know what a var is? (Also, I was responding to the person above my previous post, not to you).
I tried global.example = ["menu", "quitmenu"]; gm:s says unallowed character or something like that
 
Yes, that is not the correct way to reference an array in gms1.4.
Code:
global.example[0] = "menu";
global.example[1] = "quitmenu";
Don't assume that because the first code you try doesn't work that it's a problem with GMS or that GMS doesn't support that thing, it's far more likely to be a problem with your code ;)
 
T

tijeseffff

Guest
Yes, that is not the correct way to reference an array in gms1.4.
Code:
global.example[0] = "menu";
global.example[1] = "quitmenu";
Don't assume that because the first code you try doesn't work that it's a problem with GMS or that GMS doesn't support that thing, it's far more likely to be a problem with your code ;)
Eh, I mean I have two arrays. menu and quitmenu
When I am selected Quit game option I want to switch menu to quitmenu, to draw different selections.
 
Store an array in each array slot.
Code:
var inner_menu;
inner_menu[0] = "New Game";
inner_menu[1] = "Load Game";
global.example[0] = inner_menu;
inner_menu = 0;
inner_menu[0] = "Quit Game";
inner_menu[1] = "Quit Options";
global.example[1] = inner_menu;
 
It also happens without the @, if you call the script through an instance that contains the array. All the variables that are present in the calling instance are also present in the script.
I guess it was not always that way?
Yes, there are many situations where only the temp array will be changed and not the other array that you want to be changed. Also note, it's not that the variable isn't present, it's that you are creating a temp array that references another array, the @ accessor makes sure you are changing the referenced array and not the temp one. It is not a useless function at all.
 
T

tijeseffff

Guest
Store an array in each array slot.
Code:
var inner_menu;
inner_menu[0] = "New Game";
inner_menu[1] = "Load Game";
global.example[0] = inner_menu;
inner_menu = 0;
inner_menu[0] = "Quit Game";
inner_menu[1] = "Quit Options";
global.example[1] = inner_menu;
And how to use it? o_O Well at least with array_length_1d. And how to switch between them?
 
Ok, so the only difference is that in order to access the inner array, you'll have to pull it into a temp variable first. And you only need another variable to between them. You'll have a variable that holds what slot you are in with the outer array and then you simply check through the inner array stored at the global.menu position you want.
Code:
menu_pos = 0;
var temp_arr = global.menu[menu_pos];
for (var i=0;i<array_length_1d(temp_arr);i++) {
  //Access each inner menu and what you want to do with it here. I'll just pull the value from the inner menu and store it in another array called string
   string[i] = string(temp_arr[i]);
}
Now if you increase or decrease menu_pos, you'll be switching between your outer arrays ("menu" and "quitmenu") and then you just need to store that global.menu[menu_pos] in a temp array like above to access it.
 
Last edited:
T

tijeseffff

Guest
Ok, so the only difference is that in order to access the inner array, you'll have to pull it into a temp variable first. And you don't need to 'switch' between them. You'll have a variable that holds what slot you are in with the outer array and then you simply check through the inner array stored at the global.menu position you want.
Code:
menu_pos = 0;
var temp_arr = global.menu[menu_pos];
for (var i=0;i<array_length_1d(temp_arr);i++) {
  //Access each inner menu and what you want to do with it here. I'll just pull the value from the inner menu and store it in another array called string
   string[i] = string(temp_arr[i]);
}
Now if you increase or decrease menu_pos, you'll be switching between your outer arrays ("menu" and "quitmenu") and then you just need to store that global.menu[menu_pos] in a temp array like above to access it.
It sort of works, it draws 5 positions, but I can select only between two. Like in quitmenu.
inner_menu[0] = "Начать игру";
inner_menu[1] = "Продолжить игру";
inner_menu[2] = "Выбрать уровень";
inner_menu[3] = "Настройка звука";
inner_menu[4] = "Выход из игры";
global.menuarray[0] = inner_menu;
inner_menu = 0;
inner_menu[0] = "Да";
inner_menu[1] = "Ньет";
global.menuarray[1] = inner_menu;
 
So if you run this code:
Code:
var temp_arr = global.menuarray[0];
var k =0;
for (var i=0;i<array_length_1d(temp_arr);i++) {
  k++;
}
show_debug_message("K = "+string(k));
Does the console output "K = 2" or "K = 5"?

EDIT: Ok, good.
 
T

tijeseffff

Guest
So if you run this code:
Code:
var temp_arr = global.menuarray[0];
var k =0;
for (var i=0;i<array_length_1d(temp_arr);i++) {
  k++;
}
show_debug_message("K = "+string(k));
Does the console output "K = 2" or "K = 5"?

EDIT: Ok, good.
Eh, Now I can access 5 selections, but when I select Quit, nothing happens.
When I am clicking Quit it should global.menu_pos++; break;
 
I'd have to see more of the code to tell what's going on. Playing around with arrays stored in arrays can become difficult. You've got to make sure that you totally understand what is being stored where in order for it to work correctly.
 
T

tijeseffff

Guest
I'd have to see more of the code to tell what's going on. Playing around with arrays stored in arrays can become difficult. You've got to make sure that you totally understand what is being stored where in order for it to work correctly.
https://transfer.sh/Tag1Z/newtutorial_platformer2.gmz
The first option is New Game, the last is Quit game. Also in quitmenu the first option is yes, and the last is no. You'll understand why I wrote this.
I am storing all these vars in rm_initialize creation code.
 
Why did you make temp_arr global? It's explicitly in it's name "temp" array. And why are you using mpos in a switch statement? Also, where are you setting up global.temp_arr?
 
You didn't follow what I said at all, lol. That's the problem. I'm going to make a gmz with a demo of the way the menu system should work, because I can't make head nor tails of how your code is structured, tbh.
 
T

tijeseffff

Guest
Why did you make temp_arr global? It's explicitly in it's name "temp" array. And why are you using mpos in a switch statement? Also, where are you setting up global.temp_arr?
idk. just followed shaun's menu tutorial. rm_initialize creation code.
 
Well, oh 💩💩💩💩, GMS2 can't export to .gmz, oh well, here's the code:

Create Event
Code:
/// @description Create the arrays

// This stores whether you are on the New Game menu page or the Quit Game menu page.
menu_pos = 0;
// This stores which sub-menu option you have selected on the New Game or Quit Game menu page.
sub_menu_pos = 0;

/* First, we're creating a 2D array to store the top-level (New Game and Quit Game) of the menu.
We're using a 2D array because we want to have a title stored, plus an array of sub-menu options. */
menu_top[0,0] = "New Game"; //The title for the menu
menu_top[0,1] = array_create(1); //Create the array to store the sub-menu options and store it in the second slot of the 2D array.
menu_top[1,0] = "Quit Game"; // Not too sure why you want Quit Game as a menu header, but whatever.
menu_top[1,1] = array_create(1);

// Here we extract the above created array in order to populate it with sub-menu options for the New Game menu.
var temp_arr = menu_top[0,1];
temp_arr[@ 0] = "Quick Game"; // Because we're using a temp array, we make sure the use the accessor (@) to store the value, which makes sure the original array gets changed.
temp_arr[@ 1] = "Custom Game";
temp_arr[@ 2] = "Load Game";

// Here we extract the above created array in order to populate it with sub-menu options for the Quit Game menu.
var temp_arr = menu_top[1,1];
temp_arr[@ 0] = "Quick Quit";
temp_arr[@ 1] = "Save Then Quit";

menu_length = array_height_2d(menu_top); // Here we just store the length of the menu options because it will be useful later.
Step Event
Code:
/// @description Catch input

menu_pos += keyboard_check_released(ord("D"))-keyboard_check_released(ord("A")); // Get direction for menu switching.
if (menu_pos < 0) {
   menu_pos = menu_length-1; // Make sure we don't go below 0, which'll break the array.
}
menu_pos = menu_pos mod menu_length; // Mod the number to it's array length so it won't break the array.
var temp_arr = menu_top[menu_pos,1]; // Extract the current sub-menu array so we can figure out how big it is.

sub_menu_pos += keyboard_check_released(ord("S"))-keyboard_check_released(ord("W")); // Get direction for sub-menu switching.
var sub_length = array_length_1d(temp_arr); // Get the length of the sub-menu array.
if (sub_menu_pos < 0) {
   sub_menu_pos = sub_length-1; // Make sure we don't go below 0.
}
sub_menu_pos = sub_menu_pos mod sub_length; // Mod to cap max number as above.
Draw Event
Code:
/// @description Draw the menu

var menu_options = menu_top[menu_pos,1]; // Get the sub menu options.
var sub_length = array_length_1d(menu_options); // Get the length of the sub menu options array.
var base_col, temp_col; // Create a base and temp colour var for later.

draw_set_halign(fa_center); // Text setup
draw_set_valign(fa_middle);

for (var i=0;i<array_height_2d(menu_top);i++) { // Loop through all your entries in the top level menu.
   if (menu_pos == i) { // If menu_pos equals the menu option we are currently looping through
       base_col = c_white; // Then set the base_col to white
       for (var c=0;c<array_length_1d(menu_options);c++) { // And then draw the sub-menu options, by looping through them.
           if (sub_menu_pos == c) { // If the sub_menu_pos equals the sub menu option we are currently looping through.
               temp_col = c_orange; // Then set the temp_col to orange, which will be our colour to show currently selected options.
           }
           else {
               temp_col = c_white; // Else make it white.
           }
           draw_set_color(temp_col); // Set the colour to the temp_col variable.
           draw_text(room_width/2-150+(400*i),200+50*c,menu_options[c]); // Draw the the text for each sub-menu option. NOTE: This +(400*i) thing only works because there's two menu options, if there were more it'd have to be tweaked.
       }
   }
   else {
       base_col = c_gray; // If menu_pos doesn't equal i, then set the base_col to gray, to show that that menu option is not currently selected.
   }
   draw_set_color(base_col); // Set the draw colour.
   draw_rectangle(room_width/2-200+(400*i),100,room_width/2-100+(400*i),150,true); // Draw a rectangle for the top level menu options.
   draw_text(room_width/2-150+(400*i),125,menu_top[i,0]); // Draw the text for each top level menu option.
}
 
Last edited:
Put that into a fresh object and put that object into a new room and run that room. Play around with it and read through my code, I documented it as heavily as I could. It might not be exactly what you are looking for, but everything you need to know about storing things and extracting things from arrays is all there and you should be able to use it as a foundation for what you need moving forward.
 
T

tijeseffff

Guest
Put that into a fresh object and put that object into a new room and run that room. Play around with it and read through my code, I documented it as heavily as I could. It might not be exactly what you are looking for, but everything you need to know about storing things and extracting things from arrays is all there and you should be able to use it as a foundation for what you need moving forward.
Thanks!
 
T

tijeseffff

Guest
Put that into a fresh object and put that object into a new room and run that room. Play around with it and read through my code, I documented it as heavily as I could. It might not be exactly what you are looking for, but everything you need to know about storing things and extracting things from arrays is all there and you should be able to use it as a foundation for what you need moving forward.
Your code is pretty easy except one line
draw_rectangle(room_width/2-200+(400*i),100,room_width/2-100+(400*i),150,true); // Draw a rectangle for the top level menu options.
srsly I can't figure out how to make it larger. (to fit another font)
 
Just change the 200 to a large number. Or you can just rewrite all the maths for the positioning to get it wherever you want. I'll rewrite that section of code to better explain what I'm doing:
Code:
var centerx = room_width/2; // Get the center of the room
var leftx = centerx - 200; // Change this to a large number to make the rectangle larger
var rightx = centerx - 100; // There's 100px difference between the leftx and rightx, which is how large the rectangle will be
var step = 400*i; // The 400 here, is because from leftx, it takes 200 pixels to meet the center of the room, and then another 200 pixels to be properly positioned on the right hand side. If you change the leftx number, you have to make the 400 here double the leftx number
draw_rectangle(leftx+step,100,rightx+step,150,true);
 
T

tijeseffff

Guest
Just change the 200 to a large number. Or you can just rewrite all the maths for the positioning to get it wherever you want. I'll rewrite that section of code to better explain what I'm doing:
Code:
var centerx = room_width/2; // Get the center of the room
var leftx = centerx - 200; // Change this to a large number to make the rectangle larger
var rightx = centerx - 100; // There's 100px difference between the leftx and rightx, which is how large the rectangle will be
var step = 400*i; // The 400 here, is because from leftx, it takes 200 pixels to meet the center of the room, and then another 200 pixels to be properly positioned on the right hand side. If you change the leftx number, you have to make the 400 here double the leftx number
draw_rectangle(leftx+step,100,rightx+step,150,true);
Well I'm very bad at math, or even "complicated math" but you docummented this code very good so maybe I will understand.
 
T

tijeseffff

Guest
No, this is really hard, I can't move that damn rectangles, I just want to make them larger and move them a bit to left. I can't understand that damn math!
 
T

tijeseffff

Guest
No, your code doesn't help, this is REALLY HARD too many math.
 
Ok, here's something that should auto-resize:
Code:
/// @description Draw the menu

var menu_options = menu_top[menu_pos,1]; // Get the sub menu options.
var sub_length = array_length_1d(menu_options); // Get the length of the sub menu options array.
var base_col, temp_col; // Create a base and temp colour var for later.
var x_buffer = 50; // This is the space between your menu option boxes.
var x_start = 100; // This is the x coord the whole menu system will be aligned to
var text_width;
var y_buffer = 50; // How much space you want vertically between each sub-menu option.
var y_start = 200; // What y value you want the sub-menu options to start at.

draw_set_halign(fa_center); // Text setup
draw_set_valign(fa_middle);
draw_set_font(your_font); // Set the font you want here

for (var i=0;i<array_height_2d(menu_top);i++) { // Loop through all your entries in the top level menu.
   text_width[i] = string_width(menu_top[i,0])+25; // Get the width in pixels of the current menu option.
   var prev_width = 0; // Setup a variable to store all previous menu option sizes.
   for (var k=0;k<i;k++) { // Loop from 0 until i-1.
      prev_width += text_width[k]; // Add each previous menu option size to current_width
   }
   if (menu_pos == i) { // If menu_pos equals the menu option we are currently looping through
      base_col = c_white; // Then set the base_col to white
      for (var c=0;c<array_length_1d(menu_options);c++) { // And then draw the sub-menu options, by looping through them.
          if (sub_menu_pos == c) { // If the sub_menu_pos equals the sub menu option we are currently looping through.
              temp_col = c_orange; // Then set the temp_col to orange, which will be our colour to show currently selected options.
          }
          else {
              temp_col = c_white; // Else make it white.
          }
          draw_set_color(temp_col); // Set the colour to the temp_col variable.
          draw_text(x_start+prev_width+(x_buffer*i)+(text_width[i]/2),y_start+y_buffer*c,menu_options[c]); // Draw the the text for each sub-menu option. NOTE: This +(400*i) thing only works because there's two menu options, if there were more it'd have to be tweaked.
      }
   }
   else {
      base_col = c_gray; // If menu_pos doesn't equal i, then set the base_col to gray, to show that that menu option is not currently selected.
   }
   draw_set_color(base_col); // Set the draw colour.
   draw_rectangle(x_start+prev_width+(x_buffer*i),100,x_start+prev_width+(x_buffer*i)+text_width[i],150,true); // We start the left hand side of the rectangle at x_start, then add the width of all the previous menu items (which stored in current_width) then add a small buffer to make sure the boxes are separated. For the right side, we do the same as the left side, but also add the width of the menu option that is currently being looped through (text_width[i]).
   draw_text(x_start+prev_width+(x_buffer*i)+(text_width[i]/2),125,menu_top[i,0]); // Draw the text for each top level menu option at the some place as the rectangle above, but divide text_width[i] by half to get the center of the rectangle.
}
 
Last edited:
T

tijeseffff

Guest
Ok, here's something that should auto-resize:
Code:
/// @description Draw the menu

var menu_options = menu_top[menu_pos,1]; // Get the sub menu options.
var sub_length = array_length_1d(menu_options); // Get the length of the sub menu options array.
var base_col, temp_col; // Create a base and temp colour var for later.
var x_buffer = 50; // This is the space between your menu option boxes.
var x_start = 100; // This is the x coord the whole menu system will be aligned to
var text_width;
var y_buffer = 50; // How much space you want vertically between each sub-menu option.
var y_start = 200; // What y value you want the sub-menu options to start at.

draw_set_halign(fa_center); // Text setup
draw_set_valign(fa_middle);
draw_set_font(your_font); // Set the font you want here

for (var i=0;i<array_height_2d(menu_top);i++) { // Loop through all your entries in the top level menu.
   text_width[i] = string_width(menu_top[i,0])+25; // Get the width in pixels of the current menu option.
   var prev_width = 0; // Setup a variable to store all previous menu option sizes.
   for (var k=0;k<i;k++) { // Loop from 0 until i-1.
      prev_width += text_width[k]; // Add each previous menu option size to current_width
   }
   if (menu_pos == i) { // If menu_pos equals the menu option we are currently looping through
      base_col = c_white; // Then set the base_col to white
      for (var c=0;c<array_length_1d(menu_options);c++) { // And then draw the sub-menu options, by looping through them.
          if (sub_menu_pos == c) { // If the sub_menu_pos equals the sub menu option we are currently looping through.
              temp_col = c_orange; // Then set the temp_col to orange, which will be our colour to show currently selected options.
          }
          else {
              temp_col = c_white; // Else make it white.
          }
          draw_set_color(temp_col); // Set the colour to the temp_col variable.
          draw_text(x_start+prev_width+(x_buffer*i)+(text_width[i]/2),y_start+y_buffer*c,menu_options[c]); // Draw the the text for each sub-menu option. NOTE: This +(400*i) thing only works because there's two menu options, if there were more it'd have to be tweaked.
      }
   }
   else {
      base_col = c_gray; // If menu_pos doesn't equal i, then set the base_col to gray, to show that that menu option is not currently selected.
   }
   draw_set_color(base_col); // Set the draw colour.
   draw_rectangle(x_start+prev_width+(x_buffer*i),100,x_start+prev_width+(x_buffer*i)+text_width[i],150,true); // We start the left hand side of the rectangle at x_start, then add the width of all the previous menu items (which stored in current_width) then add a small buffer to make sure the boxes are separated. For the right side, we do the same as the left side, but also add the width of the menu option that is currently being looped through (text_width[i]).
   draw_text(x_start+prev_width+(x_buffer*i)+(text_width[i]/2),125,menu_top[i,0]); // Draw the text for each top level menu option at the some place as the rectangle above, but divide text_width[i] by half to get the center of the rectangle.
}
Thanks. The last question, how the react at the enter button press? I found only vk_up,down,left,right in the step event.
 
Ok, I'm heading off to work now, but I'll give ya one last bit of help when I get back. While I'm gone, you can try on your own. The key is to make the sub-menu options array a 2D array instead of a 1D array and store a script that has the code you want to happen for each sub-menu option in the second slot (you'll have to go through all the code and make it so that everything that references the sub-menu array properly deals with a 2D array instead of a 1D array). But basically, you just check what sub-menu slot is selected when you hit enter and then you script_execute the script that's attached to the 2nd column of the array.
 
T

tijeseffff

Guest
Ok, I'm heading off to work now, but I'll give ya one last bit of help when I get back. While I'm gone, you can try on your own. The key is to make the sub-menu options array a 2D array instead of a 1D array and store a script that has the code you want to happen for each sub-menu option in the second slot (you'll have to go through all the code and make it so that everything that references the sub-menu array properly deals with a 2D array instead of a 1D array). But basically, you just check what sub-menu slot is selected when you hit enter and then you script_execute the script that's attached to the 2nd column of the array.
Yay! I did it myself. At first I copied push var from Shaun's code
Code:
var push = keyboard_check_released(vk_enter);
if (push == 1) scr_menu();
Then I wrote scr_menu
Code:
if (menu_pos == 0) {
switch (sub_menu_pos)
{
    case 0: room_goto(rm_1); break;
   
    case 1: game_end(); break;
   
    case 2: game_end(); break;
   
    default: break;
}
} else if (menu_pos == 1) {
switch (sub_menu_pos)
{
    case 0: room_goto(thisisanoptions_crashthegame); break;
   
    case 1: game_end(); break;
   
    default: break;
}
}
PS: I will finish scr_menu later.
 
Last edited by a moderator:
T

tijeseffff

Guest
Also I wrote down this small code to handle sound
Code:
if (global.issoundstopped == 0) and audio_is_playing(snd_menu) {}
else if (global.issoundstopped == 1) and (audio_is_playing(snd_menu)) {audio_stop_all();}
else if (global.issoundstopped == 0) and (!audio_is_playing(snd_menu)) {audio_play_sound(snd_menu,1,true);}
else if (global.issoundstopped == 1) and (!audio_is_playing(snd_menu)) {}
 
Awesome job mate, I'm glad you were involved enough in understanding what I was doing to be able to adapt it. Next thing you know you'll be coding things like this without a second thought. Keep it up =)
 
T

tijeseffff

Guest
Awesome job mate, I'm glad you were involved enough in understanding what I was doing to be able to adapt it. Next thing you know you'll be coding things like this without a second thought. Keep it up =)
Thanks =) now it's time to implement Level Select, and also pause the whole game and displaying menu w/o going to rm_menu. Also I will need to design levels which is the bad part, my school "Art" grades are very bad, in some time my girlfriend helps me, but idk how long it will take to teach her the GM:S 1.4 Level Editor and the F5 button.
 
T

tijeseffff

Guest
Well the first I can implement very easy, just by creating another object and another room, but not w/ menu options nor with levels. The second, well, I can put if (global.paused == 1) into the step event of all objects. And If it is, do nothing and place the menu object. The third, I don't know how to program on Girlfriend Script Language so this will be hard.
 
T

tijeseffff

Guest
Awesome job mate, I'm glad you were involved enough in understanding what I was doing to be able to adapt it. Next thing you know you'll be coding things like this without a second thought. Keep it up =)
Code:
if (global.paused == 0) global.paused = 1; else if (global.paused == 1) global.paused = 0; // pause the whole frickin' game
if (global.paused == 1) {
instance_create(100,100,obj_menu);
} else if (global.paused == 0) instance_destroy(obj_menu);
This code really works. lol i was laughing really hard. Every object stops. Menu appears. Now maybe I can improve that code and draw a background after the objects, but behind the menu and text.
Sadly, I am not using GMS 2 which has layers. Because my Acer Aspire E1-571G can't handle it, YoYo optimize your tool plz.
 
As a tip to save a bit of typing,
Code:
if (global.pause) {
Functions identically to
Code:
if (global.pause == 1) {
And
Code:
if (!global.paused) {
Functions identically to
Code:
if (global.pause == 0) {
 
T

tijeseffff

Guest
As a tip to save a bit of typing,
Code:
if (global.pause) {
Functions identically to
Code:
if (global.pause == 1) {
And
Code:
if (!global.paused) {
Functions identically to
Code:
if (global.pause == 0) {
I already know that, from Shaun's tutorials.
I will send you the exe after ~30mins, it's really beautiful. (it will be YYC-compiled, I have VS2013 installed)
 
T

tijeseffff

Guest
As a tip to save a bit of typing,
Code:
if (global.pause) {
Functions identically to
Code:
if (global.pause == 1) {
And
Code:
if (!global.paused) {
Functions identically to
Code:
if (global.pause == 0) {
https://drive.google.com/open?id=1oui8WUX1woyIDPckGoPIMDtrddfWhSgD so here what I've done.
Insert - open up a pause menu w/o quitting room
Home - just room_goto(rm_menu);
So arrow keys is well controlling the menu and the player.
Space jump, rotating black thing is the checkpoint, blue thing is the powerup (you can jump waaay higher, higher than snoop dogg at 4am).
Red things are the enemys, jump on them.
 
Top