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")){
disableStartButton();
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"));
}
//OPTIONS
if(menuPause == 1){
playsample(openborconstant("SAMPLE_BEEP2"), 0, volume, volume, speed, loop);
options();
}
//HOW TO PLAY
if(menuPause == 2){
playsample(openborconstant("SAMPLE_BEEP2"), 0, volume, volume, speed, loop);
setglobalvar("menuPause", 0);
playgif("data/scenes/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"));
}
}
//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 = "Options";align = (hRes-(strwidth(str, font1)))/2;
drawstring(align, yPos, font1, str, layer);
yPos = yPos+yAdd;
str = "How To Play";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();}
}
}
}
void disableStartButton()
{
void player1 = getplayerproperty(0, "entity");
void player2 = getplayerproperty(1, "entity");
void player3 = getplayerproperty(2, "entity");
void player4 = getplayerproperty(3, "entity");
void name1 = getentityproperty(player1, "defaultname");
void name2 = getentityproperty(player2, "defaultname");
void name3 = getentityproperty(player3, "defaultname");
void name4 = getentityproperty(player4, "defaultname");
int pIndex1 = getentityproperty(player1, "playerindex");
int pIndex2 = getentityproperty(player2, "playerindex");
int pIndex3 = getentityproperty(player3, "playerindex");
int pIndex4 = getentityproperty(player4, "playerindex");
if(name1 == "Axel"){
if(playerkeys(pIndex1, 0, "start")){
changeplayerproperty(pIndex1, "newkeys", 0);
}
}
if(name2 == "Axel"){
if(playerkeys(pIndex2, 0, "start")){
changeplayerproperty(pIndex2, "newkeys", 0);
}
}
if(name3 == "Axel"){
if(playerkeys(pIndex3, 0, "start")){
changeplayerproperty(pIndex3, "newkeys", 0);
}
}
if(name4 == "Axel"){
if(playerkeys(pIndex4, 0, "start")){
changeplayerproperty(pIndex4, "newkeys", 0);
}
}
}