Try replacing the openborconstant("SAMPLE_BEEP2") by openborvariant("global_sample_beep2"), v4 works on a different way.update smfh... i removed the sample beep lines and now it works...
i am not sure if those are the sound files but regardless it still the same even with the new one from other thread.Try replacing the openborconstant("SAMPLE_BEEP2") by openborvariant("global_sample_beep2"), v4 works on a different way.
Below there's an example of how you can apply the new code. It will fix the crash but if I'm not wrong there's no sound file in the sample I uploaded to the resources section, you need to add one manually.i am not sure if those are the sound files but regardless it still the same even with the new one from other thread.
//OPTIONS
if(menuPause == 1){
playsample(openborvariant("global_sample_beep2"), 0, volume, volume, speed, loop);
options();
}
Indeed I only added the "how to play" as an example, you can replace by other function or even remove if it's necessary in your project.tho as it is the only thing i dont like about this grea script is that when viewing the how to play , pressing any button throws you back into the game instead of the pause menu so you could manually do it.. other than that its awesome xD
still the same after manually adding one... i did that with the other tries before i posted first about it with same resultsBelow there's an example of how you can apply the new code. It will fix the crash but if I'm not wrong there's no sound file in the sample I uploaded to the resources section, you need to add one manually.
C://OPTIONS if(menuPause == 1){ playsample(openborvariant("global_sample_beep2"), 0, volume, volume, speed, loop); options(); }
Indeed I only added the "how to play" as an example, you can replace by other function or even remove if it's necessary in your project.
I didn't understand the problem exactly, is the sound not playing?still the same after manually adding one... i did that with the other tries before i posted first about it with same results
playsample(openborvariant("global_sample_beep_2"), 0, volume, volume, speed, loop);
"global_sample_beat",
"global_sample_beep",
"global_sample_beep_2",
"global_sample_bike",
"global_sample_block",
"global_sample_fall",
"global_sample_get",
"global_sample_get_2",
"global_sample_go",
"global_sample_indirect",
"global_sample_jump",
"global_sample_one_up",
"global_sample_pause",
"global_sample_punch",
"global_sample_time_over",
yeah that fixed the issue.. thanks it does makes a differenceI didn't understand the problem exactly, is the sound not playing?
EDIT: @AlexDC22 Sorry man, it's a small typo. I made some tests and saw that there's an underline between "beep" and "2" in this variant.
C:playsample(openborvariant("global_sample_beep_2"), 0, volume, volume, speed, loop);
Here are the other sounds in case you need too.
C:"global_sample_beat", "global_sample_beep", "global_sample_beep_2", "global_sample_bike", "global_sample_block", "global_sample_fall", "global_sample_get", "global_sample_get_2", "global_sample_go", "global_sample_indirect", "global_sample_jump", "global_sample_one_up", "global_sample_pause", "global_sample_punch", "global_sample_time_over",
void playGifSequence() {
// Play each GIF in sequence
playgif("data/scenes/intro/howto1.gif");
playgif("data/scenes/intro/howto2.gif");
playgif("data/scenes/intro/howto3.gif");
}
void main()
{
//NECESSARY STEP TO RESET THE "MENU OPTION" VARIABLE AT THE TITLE SCREEN
if(openborvariant("in_titlescreen")){
if(getglobalvar("menuPause") != 0){setglobalvar("menuPause", 0);}
}
//CHECK IF THE PLAYER IS IN A LEVEL
if(openborvariant("in_level")){
int volume = openborvariant("effectvol");
int speed = 100;
int loop = 0;
int menuPause = getglobalvar("menuPause");
int max = 3;
int min = 0;
int add = 1;
//CHECK IF THE GAME IS PAUSED BUT NOT IN OPTIONS
if(openborvariant("game_paused") && !openborvariant("in_options")){
//DETECT UP/DOWN BUTTON PRESS AND CHANGE THE HIGHLIGHTED OPTION
if( playerkeys(0, 1, "movedown")||
playerkeys(1, 1, "movedown")||
playerkeys(2, 1, "movedown")||
playerkeys(3, 1, "movedown")){
if(menuPause >= min && menuPause < max){setglobalvar("menuPause", menuPause+add);}
if(menuPause == max){setglobalvar("menuPause", min);}
}
if( playerkeys(0, 1, "moveup")||
playerkeys(1, 1, "moveup")||
playerkeys(2, 1, "moveup")||
playerkeys(3, 1, "moveup")){
if(menuPause > min && menuPause <= max){setglobalvar("menuPause", menuPause-add);}
if(menuPause == min){setglobalvar("menuPause", max);}
}
//DEFINE A FUNCTION TO BE EXECUTED WHEN EACH OPTION IS CONFIRMED BY PRESSING ACTION KEYS
//NOTE THAT SOME OPTIONS ALREADY PLAY SAMPLES NATIVELY, ONLY A FEW NEED TO BE MANUALLY PLAYED
if( playerkeys(0, 1, "anybutton")||
playerkeys(1, 1, "anybutton")||
playerkeys(2, 1, "anybutton")||
playerkeys(3, 1, "anybutton")){
//LOCK NATIVE KEYS
changeplayerproperty(0, "newkeys", 0);
changeplayerproperty(1, "newkeys", 0);
changeplayerproperty(2, "newkeys", 0);
changeplayerproperty(3, "newkeys", 0);
//CONTINUE
if(menuPause == 0){
changeplayerproperty(0, "newkeys", openborconstant("FLAG_ESC"));
changeplayerproperty(1, "newkeys", openborconstant("FLAG_ESC"));
changeplayerproperty(2, "newkeys", openborconstant("FLAG_ESC"));
changeplayerproperty(3, "newkeys", openborconstant("FLAG_ESC"));
}
//SETTINGS
if(menuPause == 1){
playsample(openborvariant("global_sample_beep_2"), 0, volume, volume, speed, loop);
options();
}
//MOVES LIST
if(menuPause == 2){
playsample(openborvariant("global_sample_beep_2"), 0, volume, volume, speed, loop);
setglobalvar("menuPause", 0);
playGifSequence();
}
//END GAME
if(menuPause == 3){
changeplayerproperty(0, "newkeys", openborconstant("FLAG_ESC"));
changeplayerproperty(1, "newkeys", openborconstant("FLAG_ESC"));
changeplayerproperty(2, "newkeys", openborconstant("FLAG_ESC"));
changeplayerproperty(3, "newkeys", openborconstant("FLAG_ESC"));
}
}
//TEXTS, IMAGES AND EFFECTS
void str;
float hRes = openborvariant("hresolution");
int align;
int yPos = 80;
int fontPause = 3;
int font0 = 0;
int font1 = 0;
int font2 = 0;
int font3 = 0;
int yAdd = 11;
int layer = -1000000003;
//DEFINE FONTS TO HIGHLIGHTED OPTIONS
if(getglobalvar("menuPause") == 0){font0 = 1;}else //IS CONTINUE HIGHLIGHTED??
if(getglobalvar("menuPause") == 1){font1 = 1;}else //IS OPTIONS HIGHLIGHTED??
if(getglobalvar("menuPause") == 2){font2 = 1;}else //IS HOW TO PLAY HIGHLIGHTED??
if(getglobalvar("menuPause") == 3){font3 = 1;} //IS END GAME HIGHLIGHTED??
str = "PAUSE";align = (hRes-(strwidth(str, fontPause)))/2;
drawstring(align, yPos, fontPause, str, layer);
yPos = yPos+yAdd*3;
str = "CONTINUE";align = (hRes-(strwidth(str, font0)))/2;
drawstring(align, yPos, font0, str, layer);
yPos = yPos+yAdd;
str = "SETTINGS";align = (hRes-(strwidth(str, font1)))/2;
drawstring(align, yPos, font1, str, layer);
yPos = yPos+yAdd;
str = "MOVES LIST";align = (hRes-(strwidth(str, font2)))/2;
drawstring(align, yPos, font2, str, layer);
yPos = yPos+yAdd;
str = "END GAME";align = (hRes-(strwidth(str, font3)))/2;
drawstring(align, yPos, font3, str, layer);
}
//LOCK ACTION KEYS, NECESSARY STEP TO QUIT FROM THE OPTIONS IGNORING THE NATIVE "END GAME" OPTION
if(openborvariant("game_paused") && openborvariant("in_options")){
changeplayerproperty(0, "newkeys", 0);
changeplayerproperty(1, "newkeys", 0);
changeplayerproperty(2, "newkeys", 0);
changeplayerproperty(3, "newkeys", 0);
}
//NECESSARY STEPS THAT NEED TO RUN AFTER SOME OPTIONS LIKE "END GAME" ARE CONFIRMED
//THERE'S A FEW ENGINE FUNCTIONS THAT ONLY RUN OUTSIDE OF THE PAUSE MENU
if(!openborvariant("game_paused") && !openborvariant("in_options")){
//END GAME
if(menuPause == 3){gameover();}
}
}
}
I suggest using a variable as a flag in order to activate a sub-menu on/off and then you can use it as reference to spawn entities, play sound or draw any sprite manually on the screen.can some one help with this?
instead of a gif file for the how to play part... can we use a text file like we do for intro? it would give us more options to add sound effects and stuff... i tried to modify the script below to at least maybe play the gifs is sequence, but it only plays the first one.
a text file where you can list the info for the animations and sounds to be played would be more ideal, but am a PS person lol... id settle for either tho
thanks
C:void playGifSequence() { // Play each GIF in sequence playgif("data/scenes/intro/howto1.gif"); playgif("data/scenes/intro/howto2.gif"); playgif("data/scenes/intro/howto3.gif"); } void main() { //NECESSARY STEP TO RESET THE "MENU OPTION" VARIABLE AT THE TITLE SCREEN if(openborvariant("in_titlescreen")){ if(getglobalvar("menuPause") != 0){setglobalvar("menuPause", 0);} } //CHECK IF THE PLAYER IS IN A LEVEL if(openborvariant("in_level")){ int volume = openborvariant("effectvol"); int speed = 100; int loop = 0; int menuPause = getglobalvar("menuPause"); int max = 3; int min = 0; int add = 1; //CHECK IF THE GAME IS PAUSED BUT NOT IN OPTIONS if(openborvariant("game_paused") && !openborvariant("in_options")){ //DETECT UP/DOWN BUTTON PRESS AND CHANGE THE HIGHLIGHTED OPTION if( playerkeys(0, 1, "movedown")|| playerkeys(1, 1, "movedown")|| playerkeys(2, 1, "movedown")|| playerkeys(3, 1, "movedown")){ if(menuPause >= min && menuPause < max){setglobalvar("menuPause", menuPause+add);} if(menuPause == max){setglobalvar("menuPause", min);} } if( playerkeys(0, 1, "moveup")|| playerkeys(1, 1, "moveup")|| playerkeys(2, 1, "moveup")|| playerkeys(3, 1, "moveup")){ if(menuPause > min && menuPause <= max){setglobalvar("menuPause", menuPause-add);} if(menuPause == min){setglobalvar("menuPause", max);} } //DEFINE A FUNCTION TO BE EXECUTED WHEN EACH OPTION IS CONFIRMED BY PRESSING ACTION KEYS //NOTE THAT SOME OPTIONS ALREADY PLAY SAMPLES NATIVELY, ONLY A FEW NEED TO BE MANUALLY PLAYED if( playerkeys(0, 1, "anybutton")|| playerkeys(1, 1, "anybutton")|| playerkeys(2, 1, "anybutton")|| playerkeys(3, 1, "anybutton")){ //LOCK NATIVE KEYS changeplayerproperty(0, "newkeys", 0); changeplayerproperty(1, "newkeys", 0); changeplayerproperty(2, "newkeys", 0); changeplayerproperty(3, "newkeys", 0); //CONTINUE if(menuPause == 0){ changeplayerproperty(0, "newkeys", openborconstant("FLAG_ESC")); changeplayerproperty(1, "newkeys", openborconstant("FLAG_ESC")); changeplayerproperty(2, "newkeys", openborconstant("FLAG_ESC")); changeplayerproperty(3, "newkeys", openborconstant("FLAG_ESC")); } //SETTINGS if(menuPause == 1){ playsample(openborvariant("global_sample_beep_2"), 0, volume, volume, speed, loop); options(); } //MOVES LIST if(menuPause == 2){ playsample(openborvariant("global_sample_beep_2"), 0, volume, volume, speed, loop); setglobalvar("menuPause", 0); playGifSequence(); } //END GAME if(menuPause == 3){ changeplayerproperty(0, "newkeys", openborconstant("FLAG_ESC")); changeplayerproperty(1, "newkeys", openborconstant("FLAG_ESC")); changeplayerproperty(2, "newkeys", openborconstant("FLAG_ESC")); changeplayerproperty(3, "newkeys", openborconstant("FLAG_ESC")); } } //TEXTS, IMAGES AND EFFECTS void str; float hRes = openborvariant("hresolution"); int align; int yPos = 80; int fontPause = 3; int font0 = 0; int font1 = 0; int font2 = 0; int font3 = 0; int yAdd = 11; int layer = -1000000003; //DEFINE FONTS TO HIGHLIGHTED OPTIONS if(getglobalvar("menuPause") == 0){font0 = 1;}else //IS CONTINUE HIGHLIGHTED?? if(getglobalvar("menuPause") == 1){font1 = 1;}else //IS OPTIONS HIGHLIGHTED?? if(getglobalvar("menuPause") == 2){font2 = 1;}else //IS HOW TO PLAY HIGHLIGHTED?? if(getglobalvar("menuPause") == 3){font3 = 1;} //IS END GAME HIGHLIGHTED?? str = "PAUSE";align = (hRes-(strwidth(str, fontPause)))/2; drawstring(align, yPos, fontPause, str, layer); yPos = yPos+yAdd*3; str = "CONTINUE";align = (hRes-(strwidth(str, font0)))/2; drawstring(align, yPos, font0, str, layer); yPos = yPos+yAdd; str = "SETTINGS";align = (hRes-(strwidth(str, font1)))/2; drawstring(align, yPos, font1, str, layer); yPos = yPos+yAdd; str = "MOVES LIST";align = (hRes-(strwidth(str, font2)))/2; drawstring(align, yPos, font2, str, layer); yPos = yPos+yAdd; str = "END GAME";align = (hRes-(strwidth(str, font3)))/2; drawstring(align, yPos, font3, str, layer); } //LOCK ACTION KEYS, NECESSARY STEP TO QUIT FROM THE OPTIONS IGNORING THE NATIVE "END GAME" OPTION if(openborvariant("game_paused") && openborvariant("in_options")){ changeplayerproperty(0, "newkeys", 0); changeplayerproperty(1, "newkeys", 0); changeplayerproperty(2, "newkeys", 0); changeplayerproperty(3, "newkeys", 0); } //NECESSARY STEPS THAT NEED TO RUN AFTER SOME OPTIONS LIKE "END GAME" ARE CONFIRMED //THERE'S A FEW ENGINE FUNCTIONS THAT ONLY RUN OUTSIDE OF THE PAUSE MENU if(!openborvariant("game_paused") && !openborvariant("in_options")){ //END GAME if(menuPause == 3){gameover();} } } }
i have actually...almost all day but as stated before... give me PS any day...I suggest using a variable as a flag in order to activate a sub-menu on/off and then you can use it as reference to spawn entities, play sound or draw any sprite manually on the screen.
I already posted some info related to the custom pause menu in this post, maybe it can be useful.
// Global variables
int continuePressed = 0;
int pauseMenuState = 1; // Flag to manage pause menu state
void main()
{
// NECESSARY STEP TO RESET THE "MENU OPTION" VARIABLE AT THE TITLE SCREEN
if(openborvariant("in_titlescreen")){
if(getglobalvar("menuPause") != 0){setglobalvar("menuPause", 0);}
}
// CHECK IF THE PLAYER IS IN A LEVEL
if(openborvariant("in_level")){
int volume = openborvariant("effectvol");
int speed = 100;
int loop = 0;
int menuPause = getglobalvar("menuPause");
int max = 3;
int min = 0;
int add = 1;
// CHECK IF THE GAME IS PAUSED BUT NOT IN OPTIONS
if(openborvariant("game_paused") && !openborvariant("in_options")){
// DETECT UP/DOWN BUTTON PRESS AND CHANGE THE HIGHLIGHTED OPTION
if(playerkeys(0, 1, "movedown")||
playerkeys(1, 1, "movedown")||
playerkeys(2, 1, "movedown")||
playerkeys(3, 1, "movedown")){
if(menuPause >= min && menuPause < max){setglobalvar("menuPause", menuPause + add);}
if(menuPause == max){setglobalvar("menuPause", min);}
}
if(playerkeys(0, 1, "moveup")||
playerkeys(1, 1, "moveup")||
playerkeys(2, 1, "moveup")||
playerkeys(3, 1, "moveup")){
if(menuPause > min && menuPause <= max){setglobalvar("menuPause", menuPause - add);}
if(menuPause == min){setglobalvar("menuPause", max);}
}
// DEFINE A FUNCTION TO BE EXECUTED WHEN EACH OPTION IS CONFIRMED BY PRESSING ACTION KEYS
if(playerkeys(0, 1, "anybutton")||
playerkeys(1, 1, "anybutton")||
playerkeys(2, 1, "anybutton")||
playerkeys(3, 1, "anybutton")){
// LOCK NATIVE KEYS
changeplayerproperty(0, "newkeys", 0);
changeplayerproperty(1, "newkeys", 0);
changeplayerproperty(2, "newkeys", 0);
changeplayerproperty(3, "newkeys", 0);
// CONTINUE
if(menuPause == 0){
continuePressed = 1; // Set flag to indicate continue was pressed
pauseMenuState = 1; // Ensure the game stays paused
}
// OPTIONS
if(menuPause == 1){
playsample(openborvariant("global_sample_beep_2"), 0, volume, volume, speed, loop);
options();
}
// MOVES LIST
if(menuPause == 2){
playsample(openborvariant("global_sample_beep_2"), 0, volume, volume, speed, loop);
setglobalvar("menuPause", 0);
playgif("data/scenes/intro/howto.gif");
}
// END GAME
if(menuPause == 3){
changeplayerproperty(0, "newkeys", openborconstant("FLAG_ESC"));
changeplayerproperty(1, "newkeys", openborconstant("FLAG_ESC"));
changeplayerproperty(2, "newkeys", openborconstant("FLAG_ESC"));
changeplayerproperty(3, "newkeys", openborconstant("FLAG_ESC"));
}
}
// HANDLE CONTINUE PRESS
if(continuePressed){
continuePressed = 0; // Reset flag
// Manage pause state by keeping the menu open
if (pauseMenuState) {
setglobalvar("menuPause", 0); // Ensure "CONTINUE" option is highlighted
// Optionally handle additional state management here if needed
}
}
// TEXTS, IMAGES AND EFFECTS
void str;
float hRes = openborvariant("hresolution");
int align;
int yPos = 80;
int fontPause = 3;
int font0 = 0;
int font1 = 0;
int font2 = 0;
int font3 = 0;
int yAdd = 11;
int layer = -1000000003;
// DEFINE FONTS TO HIGHLIGHTED OPTIONS
if(getglobalvar("menuPause") == 0){font0 = 1;}else // IS CONTINUE HIGHLIGHTED??
if(getglobalvar("menuPause") == 1){font1 = 1;}else // IS OPTIONS HIGHLIGHTED??
if(getglobalvar("menuPause") == 2){font2 = 1;}else // IS HOW TO PLAY HIGHLIGHTED??
if(getglobalvar("menuPause") == 3){font3 = 1;} // IS END GAME HIGHLIGHTED??
str = "PAUSE";
align = (hRes - (strwidth(str, fontPause))) / 2;
drawstring(align, yPos, fontPause, str, layer);
yPos = yPos + yAdd * 3;
str = "CONTINUE";
align = (hRes - (strwidth(str, font0))) / 2;
drawstring(align, yPos, font0, str, layer);
yPos = yPos + yAdd;
str = "SETTINGS";
align = (hRes - (strwidth(str, font1))) / 2;
drawstring(align, yPos, font1, str, layer);
yPos = yPos + yAdd;
str = "MOVES LIST";
align = (hRes - (strwidth(str, font2))) / 2;
drawstring(align, yPos, font2, str, layer);
yPos = yPos + yAdd;
str = "END GAME";
align = (hRes - (strwidth(str, font3))) / 2;
drawstring(align, yPos, font3, str, layer);
}
// LOCK ACTION KEYS, NECESSARY STEP TO QUIT FROM THE OPTIONS IGNORING THE NATIVE "END GAME" OPTION
if(openborvariant("game_paused") && openborvariant("in_options")){
changeplayerproperty(0, "newkeys", 0);
changeplayerproperty(1, "newkeys", 0);
changeplayerproperty(2, "newkeys", 0);
changeplayerproperty(3, "newkeys", 0);
}
// NECESSARY STEPS THAT NEED TO RUN AFTER SOME OPTIONS LIKE "END GAME" ARE CONFIRMED
// THERE'S A FEW ENGINE FUNCTIONS THAT ONLY RUN OUTSIDE OF THE PAUSE MENU
if(!openborvariant("game_paused") && !openborvariant("in_options")){
// END GAME
if(menuPause == 3){gameover();}
}
}
}
IMO you should emulate pause, do not use actual pause , if try to overwrite its functionality you get into chain of trouble, instead do your own fake menu.
Do something that kinda looks like pause - cover entire screen with your pic, slap some text objects and move between them .
I suggest using flags with local/global variables, they are more consistent and have proper ways to be cleared if it's necessary by using NULL() or clearlocalvar/clearglobalvar.so i added some flags to this so when i press any button when the howto gif is playing it takes me back to the pause menu, but no matter what i do i cant get it right,,, it either throws me back straight to gameplay( which is what i dont want) or it takes me back to pause menu which is what i want... but then i cant press on continue since escape is hardcoded for that... is it even possible? ive also tried with the images loading from a text file to no aval so i gave up on that... but is annoying to get thrown into the fray if you press a button by accident. this is giving me headaches and more gray hair lol
IMO you should emulate pause, do not use actual pause , if try to overwrite its functionality you get into chain of trouble, instead do your own fake menu.
Do something that kinda looks like pause - cover entire screen with your pic, slap some text objects and move between them .
To display different screens - move them offscreen temporarily or change their z order so they go behind other screens.
It depends on the usage. I'm currently using both ways and have the following considerations:+1 this.
Don't play Mother May I with native engine behaviors. You always lose. If you want custom stuff, you have to think of OpenBOR the way you would if it was another engine - As in, forget the native stuff exists. Ignore it, and make your own.
DC
yeah i went through all that already and am putting this off till later tho.... will check back again later tho thank you@AlexDC22 This is the closest part you want for your pause menu, according to how you want that menu to be like, right? Well, you don't have to just use the text. You can replace it with playgif of How-to. Plus, look at how many options that are available in the pause menu.
Let me know if you have trouble.