BOOLEAN ErrorRaised(void) { char *errorString = abCalcGetError(); if (errorString == NULL) { return FALSE; } AlertWindow(awCString+awResource, (Pointer)&errorString, abCalcErrorAlert); abCalcClearError(); return TRUE; }
//Main Program****************************************************************************************************************** int ApiMain() { cout<<"*******************Welcome To The Game****************************"<<endl; cout<<"Enter Your Name "; cin>>username; sprintf(welcome,"Welcome To The Game %s",username); Game.Open(); AlertWindow("Loading","Your Game Will Load In A While.."); Game.RenderText(Position(14,7.5),"Loading Game Please Wait....!!!",Red,White); Game.RenderText(Position(14,3.5),"Star Wars",Red,Black); RectangleShape r(Game,Position(14,8.5),Black,28,1); r.Draw(); //loading all images***************************************************************************************************** background.Load("images/background.xpm"); assert(background.GetStatus() == BitMapOkay); background.SetPosition(Position(0,0)); background.Draw(); Game.RenderText(Position(14,3.5),"Star Wars",Red,Black); Game.RenderText(Position(15,7.5),"Loading Game Please Wait....!!!",Red,Black); r.Draw(); RectangleShape fill(Game,Position(1,8.5),White,2,1); fill.Draw(); Game.RenderText(Position(14,8.5),"Loading....",Black,White); ballimage.Load("images/ball.xpm"); assert(ballimage.GetStatus() == BitMapOkay); fill.SetPosition(Position(3,8.5)); fill.Draw(); Game.RenderText(Position(14,8.5),"Loading....",Black,White); exit1.Load("images/exitunpressed.xpm"); assert(exit1.GetStatus() == BitMapOkay); exit1.SetPosition(Position(26.3,14.5)); inst1.Load("images/instruction1.xpm"); assert(inst1.GetStatus() == BitMapOkay); inst1.SetPosition(Position(6,2)); fill.SetPosition(Position(5,8.5)); fill.Draw(); Game.RenderText(Position(14,8.5),"Loading1....",Black,White); exit2.Load("images/exitpressed.xpm"); assert(exit2.GetStatus() == BitMapOkay); exit2.SetPosition(Position(26.3,14.5)); inst2.Load("images/instruction2.xpm"); assert(inst2.GetStatus() == BitMapOkay); inst2.SetPosition(Position(6,2)); fill.SetPosition(Position(7,8.5)); fill.Draw(); Game.RenderText(Position(14,8.5),"Loading....",Black,White); obstacleimage.Load("images/obstacle.xpm"); assert(obstacleimage.GetStatus() == BitMapOkay); fill.SetPosition(Position(9,8.5)); fill.Draw(); Game.RenderText(Position(14,8.5),"Loading....",Black,White); starti.Load("images/start.xpm"); assert(starti.GetStatus() == BitMapOkay); fill.SetPosition(Position(11,8.5)); fill.Draw(); Game.RenderText(Position(14,8.5),"Loading....",Black,White); highscorei.Load("images/highscores.xpm"); assert(highscorei.GetStatus() == BitMapOkay); fill.SetPosition(Position(13,8.5)); fill.Draw(); Game.RenderText(Position(14,8.5),"Loading....",Black,White); leveli.Load("images/level.xpm"); assert(leveli.GetStatus() == BitMapOkay); fill.SetPosition(Position(15,8.5)); fill.Draw(); Game.RenderText(Position(14,8.5),"Loading....",Black,White); instructioni.Load("images/instructions.xpm"); assert(instructioni.GetStatus() == BitMapOkay); fill.SetPosition(Position(17,8.5)); fill.Draw(); Game.RenderText(Position(14,8.5),"Loading....",Black,White); crediti.Load("images/credit.xpm"); assert(crediti.GetStatus() == BitMapOkay); fill.SetPosition(Position(19,8.5)); fill.Draw(); Game.RenderText(Position(14,8.5),"Loading....",Black,White); exiti.Load("images/quit.xpm"); assert(exiti.GetStatus() == BitMapOkay); fill.SetPosition(Position(21,8.5)); fill.Draw(); Game.RenderText(Position(14,8.5),"Loading....",Black,White); starwar.Load("images/starwars.xpm"); assert(starwar.GetStatus() == BitMapOkay); fill.SetPosition(Position(23,8.5)); fill.Draw(); Game.RenderText(Position(14,8.5),"Loading....",Black,White); explode.Load("images/explode.xpm"); assert(explode.GetStatus() == BitMapOkay); explode.SetPosition(Position(-4,-4)); fill.SetPosition(Position(25,8.5)); fill.Draw(); Game.RenderText(Position(14,8.5),"Loading....",Black,White); next.Load("images/next.xpm"); assert(next.GetStatus() == BitMapOkay); next.SetPosition(Position(24,14.4)); fill.SetPosition(Position(27,8.5)); fill.Draw(); Game.RenderText(Position(14,8.5),"Loading....",Black,White); AlertWindow("Welcome",welcome); //Reading from highscore.txt and storing them in an array. fp=fopen("HighScore.txt","r"); char input[120]; for(int i=0;i<10;i++) { fgets(input,120,fp); sscanf(input,"%s%d",highscoreuser[i],&highscore[i]); } fclose(fp); start(); //Calling start function /*RectangleShape NewGame(Game,Position(14,4.5),Blue,8,2); NewGame.Draw(); Game.RenderText(Position(14,4.5),"New Game",Blue,Red); mouse();*/ //playgame(); return 0; }
Word error_dialog(Word error_message, Word error_code) { Word button; /* ************************************************************** * * Check for validity of the error code - if it is not a known * * error code then we will use the 'invalid error' message. * * ************************************************************** */ if ((error_message < 0) || (error_message > NUMBER_OF_ERROR_CODES)) { error_message = NUMBER_OF_ERROR_CODES+1; }; /* ************************************************************** * * Setup the substitution strings... * * ************************************************************** */ /* ************************************************************** * * Check if the window manager is active or not... * * ************************************************************** */ if (WindStatus() != 0) { /* ********************************************************** * * The window manager is available... so we are allowed to * * put up a simple alert window. Setup the substitution * * array and put up the dialog... * * ********************************************************** */ if (error_message == TOO_MANY_SPOOLFILES) { sprintf(error_string1, "32/FilePort error - *0/^#0", error_code); } else { sprintf(error_string1, "32/FilePort error - *0 (error code $%X)/^#0", error_code); }; substitute_array[0] = (Pointer) error_strings[ ((error_message >= 0) || (error_message < NUMBER_OF_ERROR_CODES)) ? error_message : (NUMBER_OF_ERROR_CODES+1)]; button = AlertWindow((Word) 0, (Pointer) &substitute_array, (Ref) error_string1); } else /* ********************************************************** * * The window manager isn't active... that means we can't * * put up a simple alertwindow... print the error strings * * out to standard out... lets hope a user sees it. * * ********************************************************** */ { printf("FilePort error - %s", (char *) error_strings[ ((error_message >= 0) || (error_message < NUMBER_OF_ERROR_CODES)) ? error_message : (NUMBER_OF_ERROR_CODES+1)]); if (error_message != TOO_MANY_SPOOLFILES) { printf(" (error code $%X)\n", error_code); }; button = 0; } /* ************************************************************** * * Return the button that was pressed. * * ************************************************************** */ return(button); } /* End of error_dialog() */