I have a Menu program that executes the game program. Both work but when the Menu program calls the Execute command and the game program loads I am greated with a blue screen it seems no objects or terrain is visible but the sprites are.
If i go to my options menu first and then execute the program the game program works fine. So i have supplied some of the source.
At First i thought that the program wasnt closing and opening the Options text file correct but that dont appear to be the problem having tested it.
The Code for Loading the Game Program is below and you will note it passes a parameter known as continent this parameter is working.
void loadprogram(char continent[11]) {
//_fcloseall();
dbSetCurrentBitmap(0);
deletebitmaps();
freememory();
if (dbSpriteExist(99)){dbDeleteSprite(99);}
if (dbSpriteExist(22)){dbDeleteSprite(22);}
if (dbSpriteExist(23)){dbDeleteSprite(23);}
dbExecuteFile("Skudlaunch.exe",continent,"");
exit(EXIT_SUCCESS);
}
The Option code in the Menu Program that makes it work is
void options(void){
int mouseflag=0;int MousePoint;
freememory();dbSync();
dbSetCurrentBitmap(0);
dbCreateBitmap(21,800,600);
dbSetCurrentBitmap(0);
dbCopyBitmap(0,21);dbSync();
dbLoadBitmap("graphics/OptionsMenu.bmp",31);
dbSetCurrentBitmap(31);dbGetImage(30,0,0,799,599,1);
dbLoadBitmap("graphics/OptionsMenu.bmp",32);
dbLoadBitmap("graphics/OptionsSelect.bmp",33);
dbLoadBitmap("graphics/OptionsMouseMap.bmp",34);
dbSetCurrentBitmap(0);
int RESOLUTION=5,DETAIL=1,CRATERS=2,MISSILECAM=2,MUSIC=2,DIFFICULTY=1;
loadOptions(&RESOLUTION,&DETAIL,&CRATERS,&MISSILECAM,&MUSIC,&DIFFICULTY);
while (mouseflag==0 && dbEscapeKey()==0){
dbSetCurrentBitmap(34);
MousePoint=dbPoint(dbMouseX(),dbMouseY());
if (MousePoint==res1 && dbMouseClick()==1 && RESOLUTION!=1) {
dbSetCurrentBitmap(33);dbGetImage(101,34,172,243,215,1);
dbSetCurrentBitmap(32);dbGetImage(100,34,172,243,391,1);
dbSetCurrentBitmap(31);RESOLUTION=1;
dbPasteImage(100,34,172,1);dbPasteImage(101,34,172,1);
dbGetImage(30,0,0,799,599,1);dbSetCurrentBitmap(0);dbSync();
}
if (MousePoint==res2 && dbMouseClick()==1 && RESOLUTION!=2) {
dbSetCurrentBitmap(33);dbGetImage(101,34,216,243,259,1);
dbSetCurrentBitmap(32);dbGetImage(100,34,172,243,391,1);
dbSetCurrentBitmap(31);RESOLUTION=2;
dbPasteImage(100,34,172,1);dbPasteImage(101,34,216,1);
dbGetImage(30,0,0,799,599,1);dbSetCurrentBitmap(0);dbSync();
}
if (MousePoint==res3 && dbMouseClick()==1 && RESOLUTION!=3) {
dbSetCurrentBitmap(33);dbGetImage(101,34,260,243,303,1);
dbSetCurrentBitmap(32);dbGetImage(100,34,172,243,391,1);
dbSetCurrentBitmap(31);RESOLUTION=3;
dbPasteImage(100,34,172,1);dbPasteImage(101,34,260,1);
dbGetImage(30,0,0,799,599,1);dbSetCurrentBitmap(0);dbSync();
}
if (MousePoint==res4 && dbMouseClick()==1 && RESOLUTION!=4) {
dbSetCurrentBitmap(33);dbGetImage(101,34,304,243,347,1);
dbSetCurrentBitmap(32);dbGetImage(100,34,172,243,391,1);
dbSetCurrentBitmap(31);RESOLUTION=4;
dbPasteImage(100,34,172,1);dbPasteImage(101,34,304,1);
dbGetImage(30,0,0,799,599,1);dbSetCurrentBitmap(0);dbSync();
}
if (MousePoint==res5 && dbMouseClick()==1 && RESOLUTION!=5) {
dbSetCurrentBitmap(33);dbGetImage(101,34,348,243,391,1);
dbSetCurrentBitmap(32);dbGetImage(100,34,172,243,391,1);
dbSetCurrentBitmap(31);RESOLUTION=5;
dbPasteImage(100,34,172,1);dbPasteImage(101,34,348,1);
dbGetImage(30,0,0,799,599,1);dbSetCurrentBitmap(0);dbSync();
}
if (MousePoint==detail1 && dbMouseClick()==1 && DETAIL!=1) {
dbSetCurrentBitmap(33);dbGetImage(101,36,481,265,524,1);
dbSetCurrentBitmap(32);dbGetImage(100,36,481,265,568,1);
dbSetCurrentBitmap(31);DETAIL=1;
dbPasteImage(100,36,481,1);dbPasteImage(101,36,481,1);
dbGetImage(30,0,0,799,599,1);dbSetCurrentBitmap(0);dbSync();
}
if (MousePoint==detail2 && dbMouseClick()==1 && DETAIL!=2) {
dbSetCurrentBitmap(33);dbGetImage(101,36,525,265,568,1);
dbSetCurrentBitmap(32);dbGetImage(100,36,481,265,524,1);
dbSetCurrentBitmap(31);DETAIL=2;
dbPasteImage(100,36,481,1);dbPasteImage(101,36,525,1);
dbGetImage(30,0,0,799,599,1);dbSetCurrentBitmap(0);dbSync();
}
if (MousePoint==crater1 && dbMouseClick()==1 && CRATERS!=1) {
dbSetCurrentBitmap(33);dbGetImage(101,341,177,540,220,1);
dbSetCurrentBitmap(32);dbGetImage(100,341,177,540,264,1);
dbSetCurrentBitmap(31);CRATERS=1;
dbPasteImage(100,341,177,1);dbPasteImage(101,341,177,1);
dbGetImage(30,0,0,799,599,1);dbSetCurrentBitmap(0);dbSync();
}
if (MousePoint==crater2 && dbMouseClick()==1 && CRATERS!=2) {
dbSetCurrentBitmap(33);dbGetImage(101,341,221,540,264,1);
dbSetCurrentBitmap(32);dbGetImage(100,341,177,540,264,1);
dbSetCurrentBitmap(31);CRATERS=2;
dbPasteImage(100,341,177,1);dbPasteImage(101,341,221,1);
dbGetImage(30,0,0,799,599,1);dbSetCurrentBitmap(0);dbSync();
}
if (MousePoint==misscam1 && dbMouseClick()==1 && MISSILECAM!=1) {
dbSetCurrentBitmap(33);dbGetImage(101,345,350,424,393,1);
dbSetCurrentBitmap(32);dbGetImage(100,345,350,424,437,1);
dbSetCurrentBitmap(31);MISSILECAM=1;
dbPasteImage(100,345,350,1);dbPasteImage(101,345,350,1);
dbGetImage(30,0,0,799,599,1);dbSetCurrentBitmap(0);dbSync();
}
if (MousePoint==misscam2 && dbMouseClick()==1 && MISSILECAM!=2) {
dbSetCurrentBitmap(33);dbGetImage(101,345,394,424,437,1);
dbSetCurrentBitmap(32);dbGetImage(100,345,350,424,437,1);
dbSetCurrentBitmap(31);MISSILECAM=2;
dbPasteImage(100,345,350,1);dbPasteImage(101,345,394,1);
dbGetImage(30,0,0,799,599,1);dbSetCurrentBitmap(0);dbSync();
}
if (MousePoint==music1 && dbMouseClick()==1 && MUSIC!=1) {
dbSetCurrentBitmap(33);dbGetImage(101,345,503,424,546,1);
dbSetCurrentBitmap(32);dbGetImage(100,345,503,424,590,1);
dbSetCurrentBitmap(31);MUSIC=1;
dbPasteImage(100,345,503,1);dbPasteImage(101,345,503,1);
dbGetImage(30,0,0,799,599,1);dbSetCurrentBitmap(0);dbSync();
}
if (MousePoint==music2 && dbMouseClick()==1 && MUSIC!=2) {
dbSetCurrentBitmap(33);dbGetImage(101,345,547,424,590,1);
dbSetCurrentBitmap(32);dbGetImage(100,345,503,424,590,1);
dbSetCurrentBitmap(31);MUSIC=2;
dbPasteImage(100,345,503,1);dbPasteImage(101,345,547,1);
dbGetImage(30,0,0,799,599,1);dbSetCurrentBitmap(0);dbSync();
}
if (MousePoint==difficulty1 && dbMouseClick()==1 && DIFFICULTY!=1) {
dbSetCurrentBitmap(33);dbGetImage(101,591,174,770,218,1);
dbSetCurrentBitmap(32);dbGetImage(100,591,174,795,305,1);
dbSetCurrentBitmap(31);DIFFICULTY=1;
dbPasteImage(100,591,174,1);dbPasteImage(101,591,174,1);
dbGetImage(30,0,0,799,599,1);dbSetCurrentBitmap(0);dbSync();
}
if (MousePoint==difficulty2 && dbMouseClick()==1 && DIFFICULTY!=2) {
dbSetCurrentBitmap(33);dbGetImage(101,591,218,770,261,1);
dbSetCurrentBitmap(32);dbGetImage(100,591,174,795,305,1);
dbSetCurrentBitmap(31);DIFFICULTY=2;
dbPasteImage(100,591,174,1);dbPasteImage(101,591,218,1);
dbGetImage(30,0,0,799,599,1);dbSetCurrentBitmap(0);dbSync();
}
if (MousePoint==difficulty3 && dbMouseClick()==1 && DIFFICULTY!=3) {
dbSetCurrentBitmap(33);dbGetImage(101,591,262,795,305,1);
dbSetCurrentBitmap(32);dbGetImage(100,591,174,795,305,1);
dbSetCurrentBitmap(31);DIFFICULTY=3;
dbPasteImage(100,591,174,1);dbPasteImage(101,591,262,1);
dbGetImage(30,0,0,799,599,1);dbSetCurrentBitmap(0);dbSync();
}
if (MousePoint==exit1 && dbMouseClick()==1) {
mouseflag=1;
saveOptions(RESOLUTION,DETAIL,CRATERS,MISSILECAM,MUSIC,DIFFICULTY);
}
if (MousePoint==exit2 && dbMouseClick()==1) {
mouseflag=1;
//exit(EXIT_SUCCESS);
}
dbSetCurrentBitmap(0);//dbSync();
dbSprite(99,0,0,30);
dbSync();
}
dbSetCurrentBitmap(0);dbCopyBitmap(21,0);dbDeleteSprite(99);//dbDeleteObject(20);
dbSync();dbDeleteBitmap(21);dbDeleteImage(30);dbDeleteBitmap(31);
dbDeleteBitmap(32);dbDeleteBitmap(33);dbDeleteBitmap(34);
dbDeleteSprite(99);blob_effect_setup();
blob_effect_show();dbSync();
dbWait(100);
}
And I have Provided the Load options code that is called in the Menu program to show how im loading the Options just off of interest. The Load options Code in the Game program is quite similar but doesnt have bitmaps associated in there as well as these are only for display in the Menu Program.
void loadOptions(int* RESOLUTION,int *DETAIL,int *CRATERS,int *MISSILECAM,int *MUSIC,int *DIFFICULTY){
FILE* fpin;
char string [20];
char OPTIONS[20]="";
char file[30]="";
strcpy(file,"Objectmaps\\");strcat(file,"Options.txt");
fpin = fopen (file,"r");
if (fpin == NULL) perror ("Error opening file");
else {
if (fgets(string,100,fpin) != NULL){
strcpy(OPTIONS,string);
}
if (fgets(string,100,fpin) != NULL){
*RESOLUTION=atoi(string);
}
if (fgets(string,100,fpin) != NULL){
*DETAIL=atoi(string);
}
if (fgets(string,100,fpin) != NULL){
*CRATERS=atoi(string);
}
if (fgets(string,100,fpin) != NULL){
*MISSILECAM=atoi(string);
}
if (fgets(string,100,fpin) != NULL){
*MUSIC=atoi(string);
}
if (fgets(string,100,fpin) != NULL){
*DIFFICULTY=atoi(string);
}
}
fclose (fpin);
_fcloseall();
if (*RESOLUTION==1) {
dbSetCurrentBitmap(33);dbGetImage(101,34,172,243,215,1);
dbSetCurrentBitmap(32);dbGetImage(100,34,172,243,391,1);
dbSetCurrentBitmap(31);
dbPasteImage(100,34,172,1);dbPasteImage(101,34,172,1);
dbGetImage(30,0,0,799,599,1);dbSetCurrentBitmap(0);dbSync();
}
if (*RESOLUTION==2) {
dbSetCurrentBitmap(33);dbGetImage(101,34,216,243,259,1);
dbSetCurrentBitmap(32);dbGetImage(100,34,172,243,391,1);
dbSetCurrentBitmap(31);
dbPasteImage(100,34,172,1);dbPasteImage(101,34,216,1);
dbGetImage(30,0,0,799,599,1);dbSetCurrentBitmap(0);dbSync();
}
if (*RESOLUTION==3) {
dbSetCurrentBitmap(33);dbGetImage(101,34,260,243,303,1);
dbSetCurrentBitmap(32);dbGetImage(100,34,172,243,391,1);
dbSetCurrentBitmap(31);
dbPasteImage(100,34,172,1);dbPasteImage(101,34,260,1);
dbGetImage(30,0,0,799,599,1);dbSetCurrentBitmap(0);dbSync();
}
if (*RESOLUTION==4) {
dbSetCurrentBitmap(33);dbGetImage(101,34,304,243,347,1);
dbSetCurrentBitmap(32);dbGetImage(100,34,172,243,391,1);
dbSetCurrentBitmap(31);
dbPasteImage(100,34,172,1);dbPasteImage(101,34,304,1);
dbGetImage(30,0,0,799,599,1);dbSetCurrentBitmap(0);dbSync();
}
if (*RESOLUTION==5) {
dbSetCurrentBitmap(33);dbGetImage(101,34,348,243,391,1);
dbSetCurrentBitmap(32);dbGetImage(100,34,172,243,391,1);
dbSetCurrentBitmap(31);
dbPasteImage(100,34,172,1);dbPasteImage(101,34,348,1);
dbGetImage(30,0,0,799,599,1);dbSetCurrentBitmap(0);dbSync();
}
if (*DETAIL==1) {
dbSetCurrentBitmap(33);dbGetImage(101,36,481,265,524,1);
dbSetCurrentBitmap(32);dbGetImage(100,36,481,265,568,1);
dbSetCurrentBitmap(31);
dbPasteImage(100,36,481,1);dbPasteImage(101,36,481,1);
dbGetImage(30,0,0,799,599,1);dbSetCurrentBitmap(0);dbSync();
}
if (*DETAIL==2) {
dbSetCurrentBitmap(33);dbGetImage(101,36,525,265,568,1);
dbSetCurrentBitmap(32);dbGetImage(100,36,481,265,524,1);
dbSetCurrentBitmap(31);
dbPasteImage(100,36,481,1);dbPasteImage(101,36,525,1);
dbGetImage(30,0,0,799,599,1);dbSetCurrentBitmap(0);dbSync();
}
if (*CRATERS==1) {
dbSetCurrentBitmap(33);dbGetImage(101,341,177,540,220,1);
dbSetCurrentBitmap(32);dbGetImage(100,341,177,540,264,1);
dbSetCurrentBitmap(31);
dbPasteImage(100,341,177,1);dbPasteImage(101,341,177,1);
dbGetImage(30,0,0,799,599,1);dbSetCurrentBitmap(0);dbSync();
}
if (*CRATERS==2) {
dbSetCurrentBitmap(33);dbGetImage(101,341,221,540,264,1);
dbSetCurrentBitmap(32);dbGetImage(100,341,177,540,264,1);
dbSetCurrentBitmap(31);
dbPasteImage(100,341,177,1);dbPasteImage(101,341,221,1);
dbGetImage(30,0,0,799,599,1);dbSetCurrentBitmap(0);dbSync();
}
if (*MISSILECAM==1) {
dbSetCurrentBitmap(33);dbGetImage(101,345,350,424,393,1);
dbSetCurrentBitmap(32);dbGetImage(100,345,350,424,437,1);
dbSetCurrentBitmap(31);
dbPasteImage(100,345,350,1);dbPasteImage(101,345,350,1);
dbGetImage(30,0,0,799,599,1);dbSetCurrentBitmap(0);dbSync();
}
if (*MISSILECAM==2) {
dbSetCurrentBitmap(33);dbGetImage(101,345,394,424,437,1);
dbSetCurrentBitmap(32);dbGetImage(100,345,350,424,437,1);
dbSetCurrentBitmap(31);
dbPasteImage(100,345,350,1);dbPasteImage(101,345,394,1);
dbGetImage(30,0,0,799,599,1);dbSetCurrentBitmap(0);dbSync();
}
if (*MUSIC==1) {
dbSetCurrentBitmap(33);dbGetImage(101,345,503,424,546,1);
dbSetCurrentBitmap(32);dbGetImage(100,345,503,424,590,1);
dbSetCurrentBitmap(31);
dbPasteImage(100,345,503,1);dbPasteImage(101,345,503,1);
dbGetImage(30,0,0,799,599,1);dbSetCurrentBitmap(0);dbSync();
}
if (*MUSIC==2) {
dbSetCurrentBitmap(33);dbGetImage(101,345,547,424,590,1);
dbSetCurrentBitmap(32);dbGetImage(100,345,503,424,590,1);
dbSetCurrentBitmap(31);
dbPasteImage(100,345,503,1);dbPasteImage(101,345,547,1);
dbGetImage(30,0,0,799,599,1);dbSetCurrentBitmap(0);dbSync();
}
if (*DIFFICULTY==1) {
dbSetCurrentBitmap(33);dbGetImage(101,591,174,770,218,1);
dbSetCurrentBitmap(32);dbGetImage(100,591,174,795,305,1);
dbSetCurrentBitmap(31);
dbPasteImage(100,591,174,1);dbPasteImage(101,591,174,1);
dbGetImage(30,0,0,799,599,1);dbSetCurrentBitmap(0);dbSync();
}
if (*DIFFICULTY==2) {
dbSetCurrentBitmap(33);dbGetImage(101,591,218,770,261,1);
dbSetCurrentBitmap(32);dbGetImage(100,591,174,795,305,1);
dbSetCurrentBitmap(31);
dbPasteImage(100,591,174,1);dbPasteImage(101,591,218,1);
dbGetImage(30,0,0,799,599,1);dbSetCurrentBitmap(0);dbSync();
}
if (*DIFFICULTY==3) {
dbSetCurrentBitmap(33);dbGetImage(101,591,262,795,305,1);
dbSetCurrentBitmap(32);dbGetImage(100,591,174,795,305,1);
dbSetCurrentBitmap(31);
dbPasteImage(100,591,174,1);dbPasteImage(101,591,262,1);
dbGetImage(30,0,0,799,599,1);dbSetCurrentBitmap(0);dbSync();
}
}
This is a peculiar bug and just to show the pecularity if i compile in video Studio and run from there it seems to be fine and only does it from the standalone exe's and to make it real hard debugging a fresh reboot is when you find the problem.
fubar