/*
   Prueba de Ubicación de Bots del Proyecto FreeBound - v. 0.01
   
   Este programa es software libre y puede redistribuirlo, copiarlo y modificarlo
   bajo los términos de la licencia pública GNU General Public License versión 2
   o superior de su elección publicada por la Free Software Foundation 

   Puede leer la licencia en: http://www.gnu.org/licenses/gnu.txt
   
*/


#include "fbackground.cpp" //ya no incluimos allegro.h porque ya se hizo aquí

int main()
{
    fbackground ftest;
    int exit_n=0; 
    int my_pic_x=0;
    int my_pic_y=0;
    BITMAP* bot;
    BITMAP* buffer;
    //iniciamos Allegro
    allegro_init(); //inicialización
	install_keyboard();

	set_color_depth(16);
	set_gfx_mode(GFX_AUTODETECT_WINDOWED,640,480,0,0);
    bot = load_bitmap("carro.bmp",NULL);
    if (!bot) allegro_message("No cargo... ni se porque");
    ftest.loadbackground("background2.bmp");
    ftest.loadmaskedbackground("background1.bmp");
    
    buffer=create_bitmap(640,480);

    while (exit_n!=1) {

		if (key[KEY_ESC]) {
			exit_n=1;
		}
          if (key[KEY_RIGHT])
          {
             my_pic_x++;
          }
          else if (key[KEY_LEFT])
          {
               my_pic_x--;
          }
          else if (key[KEY_UP])
          {
               my_pic_y--;
          }
          else if (key[KEY_DOWN])
          {
               my_pic_y++;
          } 
          if (my_pic_x<0) {
                        my_pic_x=0;
                        }
           ftest.dumptobitmap(buffer);
           draw_sprite(buffer,bot,my_pic_x,my_pic_y);
           blit(buffer,screen,0,0,0,0,buffer->w,buffer->h);
           clear_bitmap(buffer);


  	}
  	destroy_bitmap(buffer);
	destroy_bitmap(bot);
    return 0;
}
END_OF_MAIN()
