PROGRAM Fire;
IMPORT "fire"

GLOBAL
a;
struct MyPal[255]
    byte r,g,b;
end
fireid, fireid2, fireid3;
m1,m2;
BEGIN
	full_screen=false;
	set_fps(0,0);
	Set_mode (640,480,8);
	m1=load_pcx("coolmap.pcx");
	m2=load_pcx("fuelmap.pcx");
	write(0,510,410,3,"FPS: ");
	write_int(0,550,410,3,&fps);
	write(0,0,60,3,"Fuego normal");
	write(0,50,260,3,"Fuego con fuelmap");
	write(0,350,160,3,"Fuego con coolmap");
	write(0,0,460,3,"Pulsa B para cambiar la paleta");

	// Paleta fuego rojo
	for(a=0; a<86; a++)
    		 mypal[a].r=a*3;
    		 mypal[a].g=0;
    		 mypal[a].b=0;
  	end
  	for(a=0; a<86; a++)
    		 mypal[a+85].r=255;
    		 mypal[a+85].g=a*3;
    		 mypal[a+85].b=0;
  	end
  	for(a=0; a<86; a++)
    		 mypal[a+170].r=255;
    		 mypal[a+170].g=255;
    		 mypal[a+170].b=a*3;
  	end
  	set_colors(0,256,&MyPal);
  	
  	
	fireid=new_fire(128,128);
	pos_fire(fireid,100,100);
	fueltype_fire(fireid,1);
	fuelmap_fire(fireid,0,m2);
	graph=graph_fire(fireid);
	x=128;
	y=180;	
	
  	fireid2=new_fire(128,50);
  	pos_fire(fireid2,0,0);
  	flag_fire(fireid2,2);
  	cooling_fire(fireid2,0);
  	fueling_fire(fireid2,30,10,30,-15,20);
  	start_fire(fireid2, 1);
  	
  	fireid3=new_fire(128,128);
  	pos_fire(fireid3,350,0);
  	cooltype_fire(fireid3,1);
	coolmap_fire(fireid3,0,m1);
  	fueling_fire(fireid3,0,2,1,-32,32);
  	start_fire(fireid3, 1);
REPEAT
	update_fire(fireid);
	if(key(_a))stop_fire(fireid2); end
	if(key(_b))
		// Paleta fuego azul
		for(a=0; a<86; a++)
	    		 mypal[a].b=a*3;
	    		 mypal[a].g=0;
	    		 mypal[a].r=0;
	  	end
	  	for(a=0; a<86; a++)
	    		 mypal[a+85].b=255;
	    		 mypal[a+85].g=a*3;
	    		 mypal[a+85].r=0;
	  	end
	  	for(a=0; a<86; a++)
	    		 mypal[a+170].b=255;
	    		 mypal[a+170].g=255;
	    		 mypal[a+170].r=a*3;
	  	end
	  	set_colors(0,256,&MyPal);
  	end
	update_fire(fireid2);
	update_fire(fireid3);
	FRAME;
UNTIL key(_esc);

delete_fire(fireid);
delete_fire(fireid2);
delete_fire(fireid3);
END
