コード例 #1
0
ファイル: path.c プロジェクト: sesc4mt/mvcdecoder
/* Function: al_make_path_canonical
 */
bool al_make_path_canonical(ALLEGRO_PATH *path)
{
   unsigned i;
   ASSERT(path);

   for (i = 0; i < _al_vector_size(&path->segments); ) {
      if (strcmp(get_segment_cstr(path, i), ".") == 0)
         al_remove_path_component(path, i);
      else
         i++;
   }

   /* Remove leading '..'s on absolute paths. */
   if (_al_vector_size(&path->segments) >= 1 &&
      al_ustr_size(get_segment(path, 0)) == 0)
   {
      while (_al_vector_size(&path->segments) >= 2 &&
         strcmp(get_segment_cstr(path, 1), "..") == 0)
      {
         al_remove_path_component(path, 1);
      }
   }

   return true;
}
コード例 #2
0
ファイル: Game.cpp プロジェクト: dradtke/battlechess
const char* getResource(const char* fmt, ...)
{
   va_list ap;
   static char res[512];
   static ALLEGRO_PATH *dir;
   static ALLEGRO_PATH *path;

   va_start(ap, fmt);
   memset(res, 0, 512);
   snprintf(res, 511, fmt, ap);

   if (!dir) {
      dir = al_get_standard_path(ALLEGRO_RESOURCES_PATH);
#ifdef ALLEGRO_MSVC
      {
         /* Hack to cope automatically with MSVC workspaces. */
         const char *last = al_get_path_component(dir, -1);
         if (0 == strcmp(last, "Debug")
            || 0 == strcmp(last, "RelWithDebInfo")
            || 0 == strcmp(last, "Release")
            || 0 == strcmp(last, "Profile")) {
            al_remove_path_component(dir, -1);
         }
      }
#endif
      al_append_path_component(dir, "data");
   }

   if (path)
      al_destroy_path(path);

   path = al_create_path(res);
   al_rebase_path(dir, path);
   return al_path_cstr(path, '/');
}
コード例 #3
0
ファイル: path.c プロジェクト: trezker/allua
static int allua_Path_remove_component(lua_State * L)
{
   ALLUA_path path = allua_check_path(L, 1);
   int i = luaL_checkint(L, 2);

   al_remove_path_component(path, i);

   return 0;
}
コード例 #4
0
ファイル: bolsadinero.cpp プロジェクト: angelmoro/Hormigas
BolsaDinero * BolsaDinero::crear_bolsa_dinero(ActorManager *actmgr,int mov_to_dead)
{
	  ALLEGRO_BITMAP *bmp;
	  MapaDeBits 	 *bitm;
	  BolsaDinero	 *bolsa_dinero_tmp;
	  ALLEGRO_PATH   *path;

	 /*
	 * para crear path relativos y poder distribuir el programa y ejecutarlo
	 * fuera del IDE
	 */

	 path = al_get_standard_path(ALLEGRO_RESOURCES_PATH);
	 al_remove_path_component(path,-1);
	 al_append_path_component(path, "resources");

	 al_set_path_filename(path, "bolsa-dinero.png");

	 bolsa_dinero_tmp = new BolsaDinero(actmgr,mov_to_dead);
	 bmp = al_load_bitmap(al_path_cstr(path, '/'));
	 if(bmp == NULL)
	 {
		al_show_native_message_box(al_get_current_display(), "Ventana de error",
								   "error fatal", "Error al cargar resource bitmap",
								   NULL, ALLEGRO_MESSAGEBOX_ERROR);
		exit(-1);
	 }
	 // Hacemos que no se vea el color negro en el bitmap de rana
	 al_convert_mask_to_alpha(bmp, al_map_rgb(0,0,0));


	 bitm=new MapaDeBits(bolsa_dinero_tmp, bmp);
	 bolsa_dinero_tmp->set_actor_graphic(bitm);

	 bolsa_dinero_tmp->set_x(Game::rnd(0,Game::gfx_w-bolsa_dinero_tmp->get_w()));
	 bolsa_dinero_tmp->set_y(Game::rnd(50,Game::gfx_h-bolsa_dinero_tmp->get_h()));
	 bolsa_dinero_tmp->set_is_detected(true);
	 bolsa_dinero_tmp->set_team(TEAM_BOLSA_DINERO);
	 bolsa_dinero_tmp->set_collision_method(CollisionManager::PP_COLLISION);

	 actmgr->add(bolsa_dinero_tmp);

	 al_destroy_path(path);

	 return bolsa_dinero_tmp;

}
コード例 #5
0
ファイル: path.c プロジェクト: sesc4mt/mvcdecoder
/* Function: al_drop_path_tail
 */
void al_drop_path_tail(ALLEGRO_PATH *path)
{
   if (al_get_path_num_components(path) > 0) {
      al_remove_path_component(path, -1);
   }
}
コード例 #6
0
ファイル: hormiga.cpp プロジェクト: angelmoro/Hormigas
void Hormiga::crear_hormiga(ActorManager *actmgr,int tipo,Hormiguero *hormiguero_tmp,
							int pos_x,int pos_y)
{
	  ALLEGRO_BITMAP *bmp;
	  MapaDeBits 	 *bitm;
	  Hormiga		 *hormiga_tmp;
	  ALLEGRO_PATH   *path;

	 /*
	 * para crear path relativos y poder distribuir el programa y ejecutarlo
	 * fuera del IDE
	 */

	 path = al_get_standard_path(ALLEGRO_RESOURCES_PATH);
	 al_remove_path_component(path,-1);
	 al_append_path_component(path, "resources");

	 if (tipo == kRedAnt)
	 {
		 al_set_path_filename(path, "HormigaRoja.png");
		 hormiga_tmp = new Hormiga(actmgr,hormiguero_tmp,kRedAnt);
	 }
	 else
	 {
		 al_set_path_filename(path, "HormigaVerde.png");
		 hormiga_tmp = new Hormiga(actmgr,hormiguero_tmp,kGreenAnt);
	 }

	 bmp = al_load_bitmap(al_path_cstr(path, '/'));
	 if(bmp == NULL)
	 {
		al_show_native_message_box(al_get_current_display(), "Ventana de error",
								   "error fatal", "Error al cargar resource bitmap",
								   NULL, ALLEGRO_MESSAGEBOX_ERROR);
		exit(-1);
	 }
	 // Hacemos que no se vea el color negro en el bitmap de hormiga
	 al_convert_mask_to_alpha(bmp, al_map_rgb(0,0,0));

	 bitm=new MapaDeBits(hormiga_tmp, bmp);
	 hormiga_tmp->set_actor_graphic(bitm);
	 if (pos_x == 0) {
		 hormiga_tmp->set_x(Game::rnd(50,Game::gfx_w-hormiga_tmp->get_w()));
	 } else {
		 hormiga_tmp->set_x(pos_x);
	 }
	 if (pos_y == 0) {
		 hormiga_tmp->set_y(Game::rnd(0,Game::gfx_h-hormiga_tmp->get_h()));
	 } else {
		 hormiga_tmp->set_y(pos_y);
	 }
	 hormiga_tmp->set_is_detected(true);

	 if (tipo == kRedAnt)
	 {
		 hormiga_tmp->set_team(TEAM_HORMIGAS_ROJAS);
	 }
	 else
	 {
		 hormiga_tmp->set_team(TEAM_HORMIGAS_VERDES);
	 }

	 hormiga_tmp->set_collision_method(CollisionManager::PP_COLLISION);

	 actmgr->add(hormiga_tmp);

	 al_destroy_path(path);

}
コード例 #7
0
ファイル: hormiga.cpp プロジェクト: angelmoro/Hormigas
void Hormiga::hit(Actor *who, int damage)
{
	 ALLEGRO_PATH   *path;

	 /*
	 * para crear path relativos y poder distribuir el programa y ejecutarlo
	 * fuera del IDE
	 */

	 path = al_get_standard_path(ALLEGRO_RESOURCES_PATH);
	 al_remove_path_component(path,-1);
	 al_append_path_component(path, "resources");

	switch (who->get_team())
	{
		case TEAM_HORMIGAS_ROJAS:
			break;
		case TEAM_HORMIGAS_VERDES:
			break;
		case TEAM_OSO:
			am->del(this);
			break;
		case TEAM_COMIDA:
			if (state == kForage) state=kGoHome;
			break;
		case TEAM_AGUA:
			if (state == kThirsty)	state=kForage;
			break;
		case TEAM_VENENO:
			if (tipo == kGreenAnt) {
				//creo la hormiga en la misma posicion de la que acaba de chocar con el veneno
				Hormiga::crear_hormiga(am,kRedAnt,Hm,x,y);
				am->del(this);
			}
			break;
		case TEAM_HORMIGUERO:

			if ((who->get_y()==Hm->get_y()) && (who->get_x()==Hm->get_x()) && (state == kGoHome))
    		{

			  /*
			   * Si he llegado a mi hormiguero creo una nueva hormiga de mi tipo y me
			   * pongo a buscara agua
			   */

			 	 state=kThirsty;
				 Hormiga::crear_hormiga(am,tipo,Hm);
    		}

			break;
		case TEAM_RANA:
			 if (tipo == kRedAnt)
			 {
				 am->del(this);
			 }
			break;
		case TEAM_SCORE:
/*
 * La envio al hormiguero
 */
			x = Hm->get_x();
			y = Hm->get_y();
			break;
		case TEAM_BOLSA_DINERO:
			break;
		default:
			break;
	}

	al_destroy_path(path);

}