int main(int argc, char *argv[])
{//start of main function

	//set gameover = true to stop the game from loading before the player plays
	GAMEOVER=true;

	//variable declerations
	int id;

	//variables used for the threads
	pthread_t pthread0;
    pthread_t pthread1;
    int threadid0 = 0;
	int threadid1 = 1;
	int threadid2 = 2;
	int threadid3 = 3;
	int threadid4 = 4;
	int threadid5 = 5;
	int threadid6 = 6;


	//set is intro to true to play the intro
	bool inIntro =true; 

	//variable used to display the players message
	char *playermessage;

	//map variables 
	int mapxoff = 0;
	int mapyoff = 0;

	//game speed variables declerations and initalization
	int frames_per_sec=0;
	int frames_done=0;
	int old_time =0;
	int totaltime=0;

	//declare allegro variables
	//BITMAP *buffer;
	BITMAP *intro;

	//initalize the classes
	//player *owl;
	sprite *hearts[3];
	sprhandler = new spritehandler();
	snake *snakeboss;

	//initalize allegro
	allegro_init();
	install_keyboard();
	install_timer();
	set_keyboard_rate(1000,1000);
	install_sound(DIGI_AUTODETECT,MIDI_AUTODETECT,NULL);

	//initalize the screen
	set_color_depth(COLORDEPTH);
	set_gfx_mode(MODE,WIDTH,HEIGHT,0,0);

	//lock both the varibale and the funciton to be used by the interrupt handler
	LOCK_VARIABLE(ticks);
	LOCK_FUNCTION(ticker);
	//install the interrupt handler which calls the ticker 60 times a second
	install_int_ex(ticker,BPS_TO_TIMER(FPS));
	
	//lock both the varibale and the funciton to be used by the interrupt handler
	//these 
	LOCK_VARIABLE(gametime);
	LOCK_FUNCTION(game_time_ticker);
	
	//install the interrupt handler which calls the game time ticker
	//game time ticker is in 10ths of seconds
	install_int_ex(game_time_ticker,BPS_TO_TIMER(10));

	//create back buffer
    buffer = create_bitmap(SCREEN_W, SCREEN_H);

	//create the intro screen by loading the bitmap into the intro buffer
	intro = load_bitmap("flightless title.bmp",NULL);
	if(!intro){
		allegro_message("Error loading intro image");
		return 1;
	}

	//seed the random function
	srand(time(NULL));
	
	//load fonts
	FONT *dicot_22_font;
	PALETTE palette;
	
	//load the the font for the header of the application
	dicot_22_font = load_font("dicot_22.pcx", palette, NULL);
	
	//load and display the intro screen
	while(inIntro)
	{
		//display the intro screen for the game
		blit(intro,screen,0,0,0,0,SCREEN_W,SCREEN_H);
		
		//wait for the player to press enter to start the game
		if(key[KEY_ENTER]){
			inIntro=false;
			GAMEOVER=false;
		}
		
		//if the player presses esc then exit the game and the intro
		if(key[KEY_ESC]){
			inIntro=false;
			GAMEOVER=true;
		}
	}
	//for as many badies make sprites to hold the bugs
	for(int i=0;i<BADIES;i++)
	{
			//initalize the bug sprite
			 bug[i] = new bugs();

			//load the bug sprite sheet
			if(!bug[i]->load("bug.bmp")){
			allegro_message("Error loading bug sprite");
			return 1;
			}

			//initalize the bug propertys
			bug[i]->init();
			
			//add sprites to the sprite handler
			sprhandler->addbugs(bug[i]);
	}
	//initalize the player
	owl = new player();

	//load the players sprite sheet
	if(!owl->load("owl sprite_new.bmp")){
		allegro_message("Error loading owl sprite");
		return 1;
	}
	
	//initalize the sprite properties
	owl->init();

	//add the player object to the sprite handler
	sprhandler->addsprite(owl);

	//create the new snake object
	snakeboss = new snake();

	//load the snake
	if(!snakeboss->load("snake_Tiles.bmp")){
		allegro_message("Error loading snake sprite");
		return 1;
	}
	//initalize the snake
	snakeboss->init();
	//snakeboss->alive=false;

	//add the snake to the sprite handler
	sprhandler->addboss(snakeboss);

	//create for loop to load the players health indicator
	for(int i=1;i<4;i++)
	{
		//create new sprite objects to hold the images
		hearts[i-1] = new sprite();

		//load the players health image
		if(!hearts[i-1]->load("FullHealth.bmp")){
			allegro_message("Error loading player Health");
			return 1;
		}
			//set sprite properties
			hearts[i-1]->x = SCREEN_W-35*i;
			hearts[i-1]->y = 10;
			hearts[i-1]->width = 30;
			hearts[i-1]->height = 30;
			hearts[i-1]->velx = 0;
			hearts[i-1]->vely = 0;
			hearts[i-1]->animcolumns = 0;
			hearts[i-1]->curframe = 0;
			hearts[i-1]->totalframes =1;
			hearts[i-1]->animdir = 0;
			//object type of non moving sprite
			hearts[i-1]->objecttype=2;
			hearts[i-1]->alive=0;

		//add the players health to the sprite handler
		sprhandler->addsprite(hearts[i-1]);
	}
	

	//create the music samples
	SAMPLE *ingamesong;

	//load the wav file into the samples
	//main game soundtrack
	ingamesong=load_sample("melo-24_Clip.wav");
	if(ingamesong==NULL){
			allegro_message("Error loading game soundtrack");
			return 1;
	}

	//use mappy.h global function MapLoad to load the .FMP file
	MapLoad("flightless.FMP");
	
	//play the sample music
	int playing = play_sample(ingamesong,150,125,1000,true);

	//start the clock to time the player
	startTime = time(NULL);

	//create the thread for player
    id = pthread_create(&pthread0, NULL, playerdraw_thread, (void*)&threadid5);

	//create the thread for the bugs
	id = pthread_create(&pthread1, NULL, wormdraw_thread, (void*)&threadid0);
	id = pthread_create(&pthread1, NULL, wormdraw_thread, (void*)&threadid1);
	id = pthread_create(&pthread1, NULL, wormdraw_thread, (void*)&threadid2);
	id = pthread_create(&pthread1, NULL, wormdraw_thread, (void*)&threadid3);
	id = pthread_create(&pthread1, NULL, wormdraw_thread, (void*)&threadid4);

	//create the thread to draw the snake
	id = pthread_create(&pthread1, NULL, snakedraw_thread, (void*)&threadid0);

	//main game loop
	while (!GAMEOVER)
	{		

		while (ticks==0)
		{
			rest(1);
		}
		while(ticks>0)
		{
			if(key[KEY_ESC])
			{
				playermessage="You quit :( Please come back again.";
				GAMEOVER=true;
			}
			
			//get the previous value of ticks and store them
			old_ticks=ticks;

			//each time we hit this loop we increment the mapxoffset +1 			
			if(mapxoff<mapwidth*mapblockwidth)
			{
				//if the player is not hiding update the map
				if(owl->state!=2)
				{
					mapxoff++;
				}
			}
			//draw the background tiles via the mappy global funciton MapDrawBG
			MapDrawBG(buffer,mapxoff,0,0,0,WIDTH-1,HEIGHT-1);
	
			//draw the players health indicator based on the owls health/30
			for (int i=0;i<((owl->health)/30);i++)
			{
				hearts[i]->draw(buffer);
			}
			
			//lock the varibales to protect them from the unsynced threads
			pthread_mutex_lock(&threadsafe);

			//get the player input
			owl->getinput();	

			sprhandler->updatebugs();
			sprhandler->updatesnake();

			//decrement the ticks
			ticks--;
			
			//unlock the mutex
			pthread_mutex_unlock(&threadsafe);
			//if the logic is taking too long abort and draw the screen
			if(old_ticks<=ticks)
				break;
		}
		//for every second that passess we need to call this function
		if(gametime - old_time >= 10)
		{
			//frames_per_sec holds the number of frames drawn in the last sec
			frames_per_sec = frames_done;

			//reset these variables for the next second
			frames_done =0;
			old_time=gametime;
		}
		//Decrement the players health
		if(gametime%120==0)
		{
 			owl->takedamage(2);
		}
		if(sprhandler->getsnakes(0)->alive==false && gametime%400==0)
		{
			sprhandler->getsnakes(0)->resurrect();
		}
		//check players health
		if(owl->health<=0)
		{
			playermessage="You have died...please remeber to eat next time.";
			GAMEOVER=true;
		}
		//stop the window from scrolling
		if(GAMEOVER==true ||mapxoff>=mapwidth*mapblockwidth-WIDTH)
		{
			if(mapxoff>=mapwidth*mapblockwidth-WIDTH)
				playermessage="Great job player you passed the game! Way to go.";
			//stop the map from moving
			mapxoff=mapwidth*mapblockwidth-WIDTH;
			
			//stop the music from playing
			stop_sample(ingamesong);

			//create the music samples
			SAMPLE *cheer=NULL;
	
			//load the wav file into the sample
			cheer=load_sample("app.wav");
			if(cheer==NULL){
					allegro_message("Error loading game soundtrack");
					return 1;
				}

			//play the sample music
			play_sample(cheer,255,125,1000,true);

			//message the player...even if they are a quiter!
			textprintf_ex(screen,dicot_22_font,200,SCREEN_H/2,makecol(255,0,0),-1,playermessage);

			rest(2000);
 	  	 	GAMEOVER=true;
		}
		//show frames fer second on the screen by pressing "cntrl f"
		if(key[KEY_F])
		{
			if(key_shifts & KB_CTRL_FLAG)
			{
				//switch the showFPS flag to display the FPS
				SHOWFPS=!SHOWFPS;
			}
			//SHOWFPS=SHOWFPS;
		}
		if(SHOWFPS==true)
			textprintf_ex(buffer,font,20,20,WHITE,0,"frames= :%d",frames_per_sec);

		if(key[KEY_H])
		{
			if(key_shifts & KB_CTRL_FLAG)
			{
				//switch the SHOWHEALTH flag to display the FPS
				SHOWHEALTH=!SHOWHEALTH;
			}
			//SHOWHEALTH=SHOWHEALTH;
		}
		
      
		//update the screen using a double buffering technique
		acquire_screen();

		blit(buffer,screen,0,0,0,0,WIDTH,HEIGHT);
		release_screen();
		
		//everytime we bilt from buffer to screen increase frames_done
		frames_done++;
    }
	
	//find the time that the game ended
	endTime = time(NULL);

		//kill the mutex (thread protection)
    pthread_mutex_destroy(&threadsafe);

	//call to create the final image to present to the user
 	create_close(buffer,dicot_22_font,owl);
	
	//Garbage Collection clean up all of the objects that are being used in memory
	remove_keyboard();
	remove_timer();
	
	//destory the bitmaps that we are using
	destroy_bitmap(buffer);
	destroy_bitmap(intro);

	//destroy the map
	MapFreeMem();

	//delete the sprites
	delete sprhandler;

	//call to allegro exit
	allegro_exit();
	return 0;

}//end of main
void updatehero(){
    tarma.animate();
    if(tarma.crouch)    tarma.height=35;
    else    tarma.height=70;
    if(tarma.jump==false){
        if(!collided(tarma.x+tarma.width/2,tarma.y+tarma.height+5)){
            tarma.jump=true;
            tarma.jumpfactor=-1;
        }
    }
    if(tarma.jump)  {
        tarma.lasty=tarma.y;
        tarma.y    -=  tarma.jumpfactor/5;
        if(tarma.y<20){
            tarma.y=20;
        }
        tarma.jumpfactor--;
    }
    if(tarma.jumpfactor<0){
        if(collided(tarma.x+tarma.width/2,tarma.y+tarma.height))
        {
            tarma.jump=false;
            lastjump=mils;
            while(collided(tarma.x+tarma.width/2,tarma.y+tarma.height))
                tarma.y-=2;
        }
    }
    if(tarma.facing==LEFT){
        if(collided(tarma.x,tarma.y+tarma.height)){
            tarma.x=tarma.lastx;
    }
    }
    if(tarma.facing==RIGHT){
        if(collided(tarma.x+tarma.width,tarma.y+tarma.height)){
            tarma.x=tarma.lastx;
    }
    }
    for(int i=0;i<20;i++){
         if(bulldogs[i].alive){
                if(met(tarma.x,tarma.y,bulldogs[i].x,bulldogs[i].y,tarma.width,bulldogs[i].width,tarma.height,bulldogs[i].height)){
                        tarma.x=tarma.lastx;

               }
        }
        if(i>=MAXBOMBERS)   continue;
        if(bombman[i].alive){
                if(met(tarma.x,tarma.y,bombman[i].x,bombman[i].y,tarma.width,bombman[i].width,tarma.height,bombman[i].height)){
                        tarma.x=tarma.lastx;

               }
        }

    }


    if(tarma.y>(mapheight*mapblockheight-tarma.height-50) ){
        resetplayer();
        if(gameover)    return;
    }

    if(tarma.x<5)  tarma.x=5;

    mapxoff=tarma.x+tarma.width/2-WIDTH/2+10;
    mapyoff=tarma.y+tarma.height/2-HEIGHT/2+10;
    if(mapxoff<0)   mapxoff=0;
    if(mapxoff>mapwidth*mapblockwidth-WIDTH)    mapxoff=mapwidth*mapblockwidth-WIDTH;
    if(mapyoff<0)   mapyoff=0;
    if(mapyoff>mapheight*mapblockheight-HEIGHT)    mapyoff=mapheight*mapblockheight-HEIGHT;
    MapDrawBG(buffer,mapxoff,mapyoff,0,0,WIDTH-1,HEIGHT-1);
    MapDrawFG(buffer,mapxoff,mapyoff,0,0,WIDTH-1,HEIGHT-1,0);

    tarma.draw();
}
示例#3
0
void MappyLevel::DrawBackground(){
	
	MapDrawBG(GraphicsCore::GetMapScrollingOffsetX(), GraphicsCore::GetMapScrollingOffsetY(), 0, 0, WIDTH, HEIGHT);
}
示例#4
0
//Main codee
//
int main(void){

	int mapxoff, mapyoff;
	int oldpy, oldpx;
	int titleX, titleY;
	int facing = 0;
	int jump = JUMPIT;
	int n, VOLUME = 128, PAN = 128, PITCH = 1000;

	//general initialize
	allegro_init();

	install_timer();

	install_keyboard();

	set_color_depth(16);

	set_gfx_mode(MODE, WIDTH, HEIGHT, 0, 0);
	
	set_window_title(" . . .J.U.M.P.E.R. . .     :: Ryan Bridglal ::");


	
	//
	//sound init
	install_sound(DIGI_AUTODETECT, MIDI_AUTODETECT, "");

	//load title
	title = load_bitmap("title.bmp", NULL);
	
	//gameOver = load_bitmap("gameover.bmp", NULL);

	// load the player sprite
	temp = load_bitmap("player.bmp", NULL);
	for (n=0; n < 8; n++)
	player_image[n] = grabframe(temp, 50, 64, 0, 0, 8, n);
	destroy_bitmap(temp);


	// load the sound file
	music = load_sample("music.wav");
	
	//jumpSound = load_sample("jump.wav");

	// initialize the sprite
	player = new SPRITE;
	player->x = 80;
	player->y = 100;
	player->curframe = 0;
	player->framecount = 0;
	player->framedelay = 6;
	player->maxframe = 7;
	player->width = player_image[0]->w;
	player->height = player_image[0]->h;


	// load the map
	MapLoad("map.FMP");

	// create the double buffer
	buffer = create_bitmap(WIDTH, HEIGHT);
	clear(buffer);
	
	//always play background music
	play_sample(music, VOLUME, PAN, PITCH, FALSE);



	// main loop
	while(!key[KEY_ESC]) {
		
		oldpy = player->y;
		oldpx = player->x;


		//
		// PLAYER controls
		//
		//right keypress
		if (key[KEY_RIGHT]) {
			clear_to_color(title, makecol(80, 80, 248));
			facing = 1;
			player->x += 2;
			
			if (++player->framecount > player->framedelay) {
				player->framecount = 0;
				
				if (++player->curframe > player->maxframe)
					player->curframe = 1;
			}
		}
		
		
		//left keypress
		else if (key[KEY_LEFT]) {
			clear_to_color(title, makecol(80, 80, 248));
			facing = 0;
			player->x -= 2;
			
			if (++player->framecount > player->framedelay) {
				player->framecount = 0;
				
				if (++player->curframe > player->maxframe)
					player->curframe = 1;
			}
		}
		
		
		else player->curframe = 0;

		// handle jumping
		if (jump == JUMPIT){
		
			if (!collided(player->x + player->width/2, player->y + player->height + 5))
				jump = 0;

			if (key[KEY_SPACE]) 
				jump = 30;
			//play_sample(jumpSound, VOLUME, PAN, PITCH, FALSE);
			    
		}
		
		else {
		     	player->y -= jump/3;
		     	jump--;
		}

		if (jump < 0){
			
			if (collided(player->x + player->width/2, player->y + player->height)) {
				jump = JUMPIT;
				while (collided(player->x + player->width/2, player->y + player->height))
					player->y -= 2;
			}
		}
		
		
		///
		//collision detection
		// player collision detect with map
		if (!facing) {
		
			if (collided(player->x, player->y + player->height))
				player->x = oldpx;
		}
		
		else {
		
			if (collided(player->x + player->width, player->y + player->height))
				player->x = oldpx;
		}


		// update the map scroll position
		mapxoff = player->x + player->width/2 - WIDTH/2 + 10;
		mapyoff = player->y + player->height/2 - HEIGHT/2 + 10;

		// avoid moving beyond the map edge
		if (mapxoff < 0) 
			mapxoff = 0;
		
		if (mapxoff > (mapwidth * mapblockwidth - WIDTH))
			mapxoff = mapwidth * mapblockwidth - WIDTH;
		
		if (mapyoff < 0) 
			mapyoff = 0;
		
		if (mapyoff > (mapheight * mapblockheight - HEIGHT))
			mapyoff = mapheight * mapblockheight - HEIGHT;


		//
		//Draw things

		// draw the background tiles
		MapDrawBG(buffer, mapxoff, mapyoff, 0, 0, WIDTH - 1, HEIGHT - 1);

		// draw the foreground tiles
		MapDrawFG(buffer, mapxoff, mapyoff, 0, 0, WIDTH - 1, HEIGHT - 1, 0);

		// draw the player's sprite
		if (facing)
			draw_sprite(buffer, player_image[player->curframe], (player->x - mapxoff), (player->y - mapyoff));
		
		else
			draw_sprite_h_flip(buffer, player_image[player->curframe], (player->x - mapxoff), (player->y - mapyoff));


		//load title
		//draw_sprite(screen, title, 160, 20);
		 //draw_sprite(buffer, title[titleSprite->curframe], (title->titleX - mapxoff), (title->y - mapyoff));
		blit(title, screen, 0, 0, 0, 0, 640, 480);


		// blit the double buffer
		vsync();
		acquire_screen();
		blit(buffer, screen, 0, 0, 0, 0, WIDTH - 1, HEIGHT - 1);
		release_screen();


		
	}// endwhile
	//	else {
	//				blit(gameOver, screen, 0, 0, 0, 0, 640, 480); 
	//}

	gameOver();


	// clean up
	for (n = 0; n < 8; n++)
		destroy_bitmap(player_image[n]);
		delete player;
		delete title;

	//	for (n=0; n<NUM_SOUNDS; n++)
	//		destroy_sample(sounds[n]);


		destroy_sample(music);
	//	destroy_sample(jumpSound);
		destroy_bitmap(title);
		destroy_bitmap(buffer);
		
		MapFreeMem();

		remove_sound();
		allegro_exit();

		return 0;

}
示例#5
0
int main (void)
{
// Golobal Integers
    extern int level;
    extern int lifes;
    extern int score;
    extern int health;
// Local Integers
   register int mapxoff, mapyoff;
   extern int oldpy, oldpx;
   extern int facing;
   extern int jump;
   int n, m;
  // DATAFILE *data;
//initilization    
	allegro_init();	
	install_timer();
	install_keyboard();
    set_color_depth(32);
	set_gfx_mode(MODE, WIDTH, HEIGHT, 0, 0);

//load data
data = load_datafile("test.dat");
    temp = (BITMAP *)data[NEWGUY_BMP].dat;
    for (n=0; n<4; n++)
    player_image[n] = grabframe(temp,43,77,0,0,4,n);
    destroy_bitmap(temp);
    temp2 = (BITMAP *)data[BAT1_BMP].dat;
    for (m=0; m<2; m++)
    bat_img[m] = grabframe(temp2,87,72,0,0,2,m);
    destroy_bitmap(temp2);

    test_img = load_bitmap("test.bmp", NULL);
gameover:
Start();
first:
//initilize Player
    player = malloc(sizeof(SPRITE));
    player->x = 80;
    player->y = 200;
    player->curframe=0;
    player->framecount=0;
    player->framedelay=11;
    player->maxframe=3;
    player->width=player_image[0]->w;
    player->height=player_image[0]->h;
//initilize Bat
    bat = malloc(sizeof(SPRITE));
    bat->x = 170;
    bat->y = 100;
    bat->curframe=0;
    bat->framecount=0;
    bat->framedelay=11;
    bat->maxframe=1;
    bat->width=bat_img[0]->w;
    bat->height=bat_img[0]->h;
    bat->dir = 0;
    bat->xspeed = 0;
//ini test
test = malloc(sizeof(SPRITE));
    test->x = 270;
    test->y = 400;
    test->curframe=0;
    test->framecount=0;
    test->framedelay=11;
    test->maxframe=1;
    test->width=bat_img[0]->w;
    test->height=bat_img[0]->h;
    test->dir = 0;
    test->xspeed = 0;

loadlevel();

    //main loop
	while (!key[KEY_ESC])
	{
      oldpy = player->y; 
      oldpx = player->x;

if (player->x > 3000)
        {level = 2;
		goto first;}

if (lifes == 0)
{lifes = 3;
          goto gameover;}

if (health < 1)
{lifes -=1;
  health =100;
  goto first;}

  updateEnemy(150, 300, test);
  updateEnemy(150, 300, bat);       
  enemycoll(player->x, player->y, bat);       
  keyinput();
//collition control
	if (!facing) 
        { 
            if (collided(player->x, player->y + player->height)) 
                player->x = oldpx; 
                if (collidedobj(player->x, player->y + player->height))
                   {ClearCell(player->x, player->y + player->height); 
                   AddScore();}
                      if (collidedkill(player->x+9, player->y + player->height))
                         {health -= 25;}        
        }
		else 
        { 
            if (collided(player->x + player->width, player->y + player->height)) 
                player->x = oldpx; 
                if (collidedobj(player->x + player->width, player->y + player->height))
                   {ClearCell(player->x + player->width, player->y + player->height);
                   AddScore();}
                      if (collidedkill(player->x + player->width-15, player->y + player->height))
                         {health -= 25;}        
        }
		
        //update the map scroll position
		mapxoff = player->x + player->width/2 - WIDTH/2 + 10;
		mapyoff = player->y + player->height/2 - HEIGHT/2 + 10;
        //avoid moving beyond the map edge
		if (mapxoff < 0) mapxoff = 0;
		if (mapxoff > (mapwidth * mapblockwidth - WIDTH))
            mapxoff = mapwidth * mapblockwidth - WIDTH;
		if (mapyoff < 0) 
            mapyoff = 0;
		if (mapyoff > (mapheight * mapblockheight - HEIGHT)) 
            mapyoff = mapheight * mapblockheight - HEIGHT;

        //draw the background tiles
		MapDrawBG(buffer, mapxoff, mapyoff, 0, 0, WIDTH-1, HEIGHT-1);
        //draw foreground tiles
		MapDrawFG(buffer, mapxoff, mapyoff, 0, 0, WIDTH-1, HEIGHT-1, 0);
        //draw the player's sprite
		if (facing) 
            draw_sprite(buffer, player_image[player->curframe], 
                (player->x-mapxoff), (player->y-mapyoff+1));
		else 
            draw_sprite_h_flip(buffer, player_image[player->curframe], 
                (player->x-mapxoff), (player->y-mapyoff));

        //blit the double buffer 
		vsync();
        acquire_screen();
		if (bat->dir == 1)
           draw_sprite(buffer, bat_img[bat->curframe],(bat->x-mapxoff),(bat->y-mapyoff));
        else
           draw_sprite_h_flip(buffer, bat_img[bat->curframe],(bat->x-mapxoff),(bat->y-mapyoff)); 
        
        draw_sprite(buffer, test_img,(test->x-mapxoff),(test->y-mapyoff));
        textprintf(buffer,font,0,0,9999999,"lifes = %d  Score = %d  Health = %d",lifes,score,health);
        blit(buffer, screen, 0, 0, 0, 0, WIDTH-1, HEIGHT-1);
       	release_screen();

	} //End of game loop




    for (n=0; n<4; n++)
        destroy_bitmap(player_image[n]);
    for (m=0; m<2; m++)
        destroy_bitmap(bat_img[m]);

destroy_bitmap(test_img);

    free(player);
	free(bat);
    free(test);
    destroy_bitmap(buffer);
	MapFreeMem ();
	MapFreeMem ();
    unload_datafile(data);
    allegro_exit();
	return 0;
}