#ifndef MINIMAP_H
#define MINIMAP_H

BITMAP *world;
//data = load_datafile("data.dat");

//world=create_bitmap(WORLD_X,WORLD_Y);
	//clear(world);


void create_world(int w,int h)
{
	shrunk=create_bitmap(24,32);
	if (world!=NULL)
	{
		destroy_bitmap(world);
	}
	world=create_bitmap(w,h);
	clear(world);

	stretch_blit((BITMAP*)data[TILES1].dat,shrunk,0,0,256,1024,0,0,8,32);
	stretch_blit((BITMAP*)data[TILES2].dat,shrunk,0,0,256,1024,8,0,8,32);
	stretch_blit((BITMAP*)data[TILES3].dat,shrunk,0,0,256,1024,16,0,8,32);
	
}

void deleteWorld()
{
	destroy_bitmap(shrunk);
}
// draw our condensed map
void drawWorld(BITMAP *bmp)
{
	int i,j,p,t,x,y,c;

	for (i=0; i<WORLD_X; i++)
	{
		for (j=0; j<WORLD_Y; j++)
		{
			p=worlds[0].layers[0].cells[j][i].get_value();
			t=worlds[0].layers[0].cells[j][i].get_tileset();
			x=p/32;
			y=p%32;
			c=getpixel(shrunk,t*8+x,y);
			if (getpixel(world,i,j)>0)
			{
				putpixel(bmp,508+i,360+j,c);				
			}
		}
	}
	drawRectangle(bmp,508,360,WORLD_X,WORLD_Y,makecol(255,255,255),0,0);

//I need to put this back on when i finshed
	//this the code for a play dot on the minnymap
//	putpixel(bmp,508+play_2.x/32,360+play_2.y/32,makecol(255,255,255));
	drawRectangle(bmp,508+screen_pos_x,360+screen_pos_y,GRID_WIDTH,GRID_WIDTH,makecol(255,255,255),0,0);
}

#endif