#import "data/scripts/dc_bug_patch/continue_timer.c"
//#import "data/scripts/menu/pauseMenu.c"
//#import "data/scripts/spawn/musicplay.c"
//#import "data/scripts/spawn/musicmisc.c"
#import "data/scripts/music.c"
void oncreate()
{
}
void ondestroy()
{
}
void main()
{
/*
* Execute the bug patch function.
* The numeric value is allowed
* continue time in game seconds.
* Native engine default is 10.
*/
int continue_time = 20;
dc_continue_bug_patch(continue_time);
LastNumber();
//trainingPause();
//titleMusic();
pausingGo();
//Versus()
/*if(openborvariant("in_titlescreen")){
if(getglobalvar("musicStopped") != 1){
setglobalvar("musicStopped", 1);
}
}*/
goStartDaMusic();
}
void goStartDaMusic(){
if(openborvariant("in_titlescreen")){
//FLAG USED TO INDICATE IF THE LEVEL MUSIC IS STOPPED TO THE "MUSICSTAGE.C" FUNCTIONS
if(getglobalvar("musicStopped") != 1){
setglobalvar("musicStopped", 1);
}
}
if(openborvariant("in_level")){
//RESTART MUSICS EVERYTIME THE SOUND MENU IS ACCESSED
//USED BECAUSE SCRIPTED MUSICS DON'T RESTARTS AUTOMATICALLY IF THE PLAYER DISABLE/ENABLE IT IN THE SOUND MENU
if(openborvariant("pause") && openborvariant("in_sound_options")){
if(getglobalvar("soundMenu") == NULL()){
setglobalvar("soundMenu", 1);
}
}else if(!openborvariant("pause")){
if(getglobalvar("soundMenu") != NULL()){
musicReplay();
setglobalvar("soundMenu", NULL());
}
}
}
}
void titleMusic()
{
if(openborvariant("in_menuscreen") || openborvariant("in_titlescreen"))
{
if(getlocalvar("MusicMenu") == NULL())
{
playmusic("Data/Music/versus.bor", 1);
setlocalvar("MusicMenu", 1);
}
}
else {if(getlocalvar("MusicMenu") != NULL()) setlocalvar("MusicMenu", NULL());}
}
/*
void versus()
{//
if(openborvariant("in_menuscreen")==1){
setglobalvar("Plays", 0);
setglobalvar("Win1", 0);
setglobalvar("Win2", 0);
} else if(openborvariant("in_selectscreen")){
void set = openborvariant("current_set");
if(set==1){
setglobalvar("Plays", 2);
}
}
}
*/
void LastNumber()
{
if(openborvariant("in_level"))
{
int P1 = getplayerproperty(0, "entity");
int P2 = getplayerproperty(1, "entity");
int P1Life = getplayerproperty(0, "lives");
int P2Life = getplayerproperty(1, "lives");
if(P1)
{
drawstring(131, 2, 3, P1Life-1);
}
if(P2)
{
drawstring(311, 2, 3, P2Life-1);
}
}
}
void pausingGo()
{
//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") /*&& openborvariant("current_set") < 2*/){
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();}
}
}
}