当前位置: 首页>>代码示例>>C++>>正文


C++ TCODList::end方法代码示例

本文整理汇总了C++中TCODList::end方法的典型用法代码示例。如果您正苦于以下问题:C++ TCODList::end方法的具体用法?C++ TCODList::end怎么用?C++ TCODList::end使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在TCODList的用法示例。


在下文中一共展示了TCODList::end方法的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: shouldStop

bool PlayerAI::shouldStop(Actor *me) {
   TCODList<Actor *> actors = engine.getActorList();

   // check if any potential attackers entered FOV
   for (Actor **iter = actors.begin(); iter != actors.end(); iter++) {
      Actor *actor = *iter;
      if (actor == NULL)                     continue;
      if (actor == me)                       continue;
      if ( !(actor->getAttacker()) )         continue;
      if (actor->isDead())                   continue;
      if (engine.getMap()->isInFov(actor->getX(), actor->getY()))
         return true;
   }

   int x = me->getX(), y = me->getY();
   Map *map = engine.getMap();

   // check if next tile is obstructed
   switch (aiState) {
      case AUTORUN_LEFT    : return !(map->canWalk(x - 1, y)); break;
      case AUTORUN_RIGHT   : return !(map->canWalk(x + 1, y)); break;
      case AUTORUN_UP      : return !(map->canWalk(x, y - 1)); break;
      case AUTORUN_DOWN    : return !(map->canWalk(x, y + 1)); break;
      default              : return false;
   }
}
开发者ID:rthoward,项目名称:avast_cpp,代码行数:26,代码来源:ai.cpp

示例2: con

Actor *PlayerAI::chooseFromInventory(Actor *me, string filter) {
   static const int INV_WIDTH = 50;
   static const int INV_HEIGHT = 28;
   static TCODConsole con(INV_WIDTH, INV_HEIGHT);
   string title = "";

   // determine title of menu based on filter type. defaults to "inventory"
   if (filter == "")
      title = "inventory";
   else
      title = filter;

   con.setDefaultForeground(TCODColor(200, 180, 50));
   con.printFrame(0, 0, INV_WIDTH, INV_HEIGHT, true, TCOD_BKGND_DEFAULT,
         title.c_str());
   con.setDefaultForeground(TCODColor::white);
   int shortcut = 'a';
   int y = 1;

   TCODList<Actor *> inventory = me->getContainer()->getInventory();
   Actor *item;

   for (Actor **iter = inventory.begin(); iter != inventory.end(); iter++) {
      item = *iter;
      
      if (item == NULL)       continue;

      // apply necessary filters
      if (filter == "equipment") {
         if (!item->isEquipment())
            continue;
      } else if (filter == "equipped") {
         if (!me->getEquipment()->isEquipped(me, item))
            continue;
      }

      string itemName = item->getName();
      if (me->getEquipment()->isEquipped(me, item))
         itemName += " [equipped]";
      con.print(2, y, "(%c) - %s", shortcut, itemName.c_str());
      y++;
      shortcut++;
   }

   TCODConsole::blit(&con, 0, 0, INV_WIDTH, INV_HEIGHT, TCODConsole::root,
         engine.getScreenWidth() / 2 - INV_WIDTH / 2,
         engine.getScreenHeight() / 2 - INV_HEIGHT / 2);
   TCODConsole::flush();

   TCOD_key_t key;
   TCODSystem::waitForEvent(TCOD_EVENT_KEY_PRESS, &key, NULL, true);

   if (key.vk == TCODK_CHAR) {
      int itemIndex = key.c - 'a';
      if (itemIndex >= 0 && itemIndex < inventory.size())
         return inventory.get(itemIndex);
   }

   return NULL;
}
开发者ID:rthoward,项目名称:avast_cpp,代码行数:60,代码来源:ai.cpp

示例3:

// return the subpage # kidNum
PageData *getKidByNum(PageData *father, int kidNum) {
	for (PageData **it=pages.begin(); it != pages.end(); it++) {
		if ( (*it)->father == father && (*it)->order == kidNum ) {
			return *it;
		}
	}
	return NULL;
}
开发者ID:dethmuffin,项目名称:BrogueTiles,代码行数:9,代码来源:doctcod.cpp

示例4: genDoc

// export to HTML
void genDoc() {		
	// generates the doc for each page
	for (PageData **it=pages.begin();it!=pages.end();it++) {
		printf ("Generating %s - %s...\n",(*it)->pageNum,(*it)->title);
		genPageDocFromTemplate(*it);
	}
	genPageDocFromTemplate(root);
}
开发者ID:dethmuffin,项目名称:BrogueTiles,代码行数:9,代码来源:doctcod.cpp

示例5: printColorTable

// generate the color table from parsed colors
void printColorTable(FILE *f) {
	fprintf(f,"<table class=\"color\">\n");
	bool needHeader=true;
	int categ=0;
	for ( Color *col=colors.begin(); col!=colors.end(); col++) {
		if ( col->category ) {
			// a color category
			fprintf(f,"<tr><td></td><th colspan=\"8\">%s</th></tr>\n",col->name);
			needHeader=true;
			categ++;
		} else if ( categ == 1 ){
			// computed colors
			if ( needHeader ) fprintf(f,"<tr><td></td><td>desaturated</td><td>lightest</td><td>lighter</td><td>light</td><td>normal</td><td>dark</td><td>darker</td><td>darkest</td></tr>\n");
			needHeader=false;
			fprintf(f,"<tr><td>%s</td>",col->name);
			for (int cm =0; cm < NB_COLOR_MOD; cm++ ) {
				if ( colorModifiers[cm].name[0] != 0 ) col->name[0]=toupper(col->name[0]);
				float h,s,v;
				col->col.getHSV(&h,&s,&v);
				s *= colorModifiers[cm].satCoef;
				v *= colorModifiers[cm].valCoef;
				TCODColor modcol;
				modcol.setHSV(h,s,v);
				fprintf(f,"<td title=\"%s%s: %d,%d,%d\" style=\"background-color: rgb(%d,%d,%d)\"></td>",
					colorModifiers[cm].name,col->name,modcol.r,modcol.g,modcol.b,
					modcol.r,modcol.g,modcol.b);
				col->name[0]=tolower(col->name[0]);	
			}
			fprintf(f,"</tr>\n");
		} else if (strcmp(col->name,"grey")==0 ) {
			// grey colors
			fprintf(f,"<tr><td colspan=\"2\">&nbsp;</td><td>lightest</td><td>lighter</td><td>light</td><td>normal</td><td>dark</td><td>darker</td><td>darkest</td></tr>\n");
			fprintf(f,"<tr><td>grey</td><td>&nbsp;</td><td title=\"lightestGrey: 223,223,223\" style=\"background-color: rgb(223, 223, 223);\"></td><td title=\"lighterGrey: 191,191,191\" style=\"background-color: rgb(191, 191, 191);\"></td><td title=\"lightGrey: 159,159,159\" style=\"background-color: rgb(159, 159, 159);\"></td><td title=\"grey: 127,127,127\" style=\"background-color: rgb(127, 127, 127);\"></td><td title=\"darkGrey: 95,95,95\" style=\"background-color: rgb(95, 95, 95);\"></td><td title=\"darkerGrey: 63,63,63\" style=\"background-color: rgb(63, 63, 63);\"></td><td title=\"darkestGrey: 31,31,31\" style=\"background-color: rgb(31, 31, 31);\"></td></tr>\n");
		} else if ( strcmp(col->name,"sepia") == 0 ) {
			// sepia colors
			fprintf(f,"<tr><td>sepia</td><td>&nbsp;</td><td title=\"lightestSepia: 222,211,195\" style=\"background-color: rgb(222, 211, 195);\"></td><td title=\"lighterSepia: 191,171,143\" style=\"background-color: rgb(191, 171, 143);\"></td><td title=\"lightSepia: 158,134,100\" style=\"background-color: rgb(158, 134, 100);\"></td><td title=\"sepia: 127,101,63\" style=\"background-color: rgb(127, 101, 63);\"></td><td title=\"darkSepia: 94,75,47\" style=\"background-color: rgb(94, 75, 47);\"></td><td title=\"darkerSepia: 63,50,31\" style=\"background-color: rgb(63, 50, 31);\"></td><td title=\"darkestSepia: 31,24,15\" style=\"background-color: rgb(31, 24, 15);\"></td></tr>");
		} else {
			// miscellaneous colors
			fprintf(f,"<tr><td>%s</td><td title=\"%s: %d,%d,%d\" style=\"background-color: rgb(%d,%d,%d)\"></td></tr>\n",
				col->name,
				col->name,col->col.r,col->col.g,col->col.b,
				col->col.r,col->col.g,col->col.b);
		}
	}
	fprintf(f,"</table>");
}
开发者ID:dethmuffin,项目名称:BrogueTiles,代码行数:47,代码来源:doctcod.cpp

示例6: use

bool Pickable::use(Actor *owner, Actor *wearer) {
    TCODList<Actor *> list;
    if (selector) {
        selector->selectTargets(wearer, list);
    }

    bool succeed = false;
    for (Actor **it = list.begin(); it != list.end(); it++) {
        if (effect->applyTo(*it)) {
            succeed = true;
        }
    }

    if (succeed) {
        if (wearer->container) {
            wearer->container->remove(owner);
            delete owner;
        }
    }

    return succeed;
}
开发者ID:davidhouchin,项目名称:m7rogue,代码行数:22,代码来源:Pickable.cpp

示例7: apply

void DamagingAura::apply(Actor *target){
	TCODRandom *rng = TCODRandom::getInstance();
	int realDamage = rng->getInt(bonus*0.8,bonus*1.25);

	TCODList<Actor *> inRadius;
	if (!smart){
		engine.getAllActorsInRadius(inRadius,target->x, target->y, radius);
	} else {
		engine.getAllActorsInRadius(inRadius,target->x, target->y, radius, SpellCastingConstants::ENEMY, target->hostile);
	}

	if (!inRadius.isEmpty()){

		for (Actor **iter = inRadius.begin();
			iter != inRadius.end(); iter++) {
			Actor *act1 = *iter;

			if (act1->destructible) act1->destructible->takeDamage(act1, target, realDamage);
		}
	}

	inRadius.clearAndDelete();
}
开发者ID:cottog,项目名称:CASTER-EDITION,代码行数:23,代码来源:Aura.cpp

示例8: use

bool Pickable::use(Actor *owner, Actor *wearer){
    bool succeed = false;
    if(!effect){
        engine.gui->message(TCODColor::lightGrey, "This item does nothing");
        return false;
    }

    if(effect->targetType == Effect::ACTOR){
        TCODList<Actor *> list;
        if(selector){
            selector->selectTargets(wearer, list);
        }else{
            list.push(wearer);
        }
        for(Actor **it = list.begin(); it != list.end(); it++){
            if(effect->applyTo(*it)){
                succeed = true;
            }
        }
    }else if(effect->targetType == Effect::POSITION){
        int x,y;
        printf("%d, %d", x, y);
        if(selector){
            if(selector->selectPosition(x,y)){
                if(effect->applyTo(x,y))
                    succeed = true;
            }
        }
    }
    if(succeed){
        if(wearer->container){
            wearer->container->remove(owner);
            delete owner;
        }
    }
    return succeed;
}
开发者ID:pthurston,项目名称:Roguelike-Game-Engine,代码行数:37,代码来源:Pickable.cpp

示例9: buildTree

// computes the page tree and auto-numbers pages
void buildTree() {
	// get the list of root (level 0) pages
	TCODList<PageData *>rootPages;
	for (PageData **it=pages.begin();it!=pages.end();it++) {
		// page requires at least a @PageName and @PageTitle
		if (! (*it)->name ) {
			printf ("ERROR : page #%d (%s) in %s has no @PageName\n",
				(*it)->fileOrder,(*it)->name ? (*it)->name : "null", (*it)->filename);
			it=pages.remove(it);
			continue;
		}
		if (! (*it)->title ) {
			printf ("ERROR : page #%d (%s) in %s has no @PageTitle\n",
				(*it)->fileOrder,(*it)->name ? (*it)->name : "null",(*it)->filename);
			it=pages.remove(it);
			continue;
		}
		if ( (*it)->fatherName == NULL ) rootPages.push(*it);
	}
	// first, order the level 0 pages according to their category
	int categId=0;
	while ( categs[categId] ) {	
		for (PageData **it=pages.begin();it!=pages.end();it++) {
			if ( (*it)->fatherName == NULL && strcmp((*it)->categoryName,categs[categId]) == 0 ) {
				// new root page
				root->numKids++;
				(*it)->father=root;
				(*it)->order=root->numKids;
				char tmp[1024];
				sprintf(tmp,"%d",(*it)->order);
				(*it)->pageNum=strdup(tmp);
				sprintf(tmp,"doc/html2/%s.html",(*it)->name);
				(*it)->url=strdup(tmp);
				sprintf(tmp,"<a onclick=\"link('../index2.html')\">Index</a> &gt; <a onclick=\"link('%s.html')\">%s. %s</a>",
					(*it)->name,(*it)->pageNum,(*it)->title);
				(*it)->breadCrumb=strdup(tmp);						
				rootPages.remove(*it);
			}
		}
		categId++;
	}
	// pages with unknown categories
	for ( PageData **it=rootPages.begin(); it != rootPages.end(); it++) {
		printf ("ERROR : unknown category '%s' in page '%s'\n",(*it)->categoryName,(*it)->name);
		pages.remove(*it);
	}
	// build the subpages tree
	for (PageData **it=pages.begin();it!=pages.end();it++) {
		if ( (*it)->fatherName != NULL ) {
			// sub-page. find its daddy and order
			(*it)->father=getPage((*it)->fatherName);
			if ( ! (*it)->father ) {
				printf ("ERROR : unknown father '%s' for page '%s'\n",
					(*it)->fatherName,(*it)->name);
				it=pages.remove(it);
				continue;
			}
			(*it)->father->numKids++;
			(*it)->order=(*it)->father->numKids;
		}
	}
	// now compute sub-page numbers 
	TCODList<PageData *> hierarchy;
	bool missing=true;
	while ( missing ) {
		missing=false;
		for (PageData **it=pages.begin();it!=pages.end();it++) {
			if ((*it)->pageNum == NULL ) {
				PageData *page=*it;
				if ( page->father->pageNum == NULL ) {
					missing=true;
				} else {                
					char tmp[256];
					sprintf(tmp,"%s.%d", page->father->pageNum,page->order);
					page->pageNum = strdup(tmp);
					sprintf(tmp,"doc/html2/%s.html",page->name);
					page->url=strdup(tmp);
				}
			}
		}
	}
	// now compute prev/next links and breadcrumbs for sub pages
	for (PageData **it=pages.begin();it!=pages.end();it++) {
		PageData *page=*it;
		page->prev=getPrev(page);
		// prev link
		if ( page->prev ) {
			char tmp[1024];
			sprintf (tmp,
				"<a class=\"prev\" onclick=\"link('%s.html')\">%s. %s</a>",
				page->prev->name,page->prev->pageNum,page->prev->title);
			page->prevLink=strdup(tmp);
		}
		// next link
		page->next=getNext(page);
		if ( page->next ) {
			char tmp[1024];
			sprintf (tmp,
				"%s<a class=\"next\" onclick=\"link('%s.html')\">%s. %s</a>",
//.........这里部分代码省略.........
开发者ID:dethmuffin,项目名称:BrogueTiles,代码行数:101,代码来源:doctcod.cpp

示例10: addAll

	/**
	@PageName list_list
	@FuncTitle Concatenating two lists
	@FuncDesc You can concatenate two lists. Every element of l2 will be added to current list (or l in the C version) :
	@Cpp template <class T> void TCODList::addAll(const TCODList &l2)
	@C void TCOD_list_add_all(TCOD_list_t l, TCOD_list_t l2)
	@Param l	The list inside which elements will be added.
	@Param l2	the list handler containing elements to insert.
	@CppEx 
		TCODList<int> intList;
		intList.set(1,3); // intList contains 2 elements : 0, 3
		TCODList<int> intList2; // intList2 is empty
		intList2.set(0,1); // intList2 contains 1 element : 1
		intList2.addAll(intList); // intList2 contains 3 elements : 1, 0, 3
	@CEx 
		TCOD_list_t intList = TCOD_list_new();
		TCOD_list_set(intList,1,(const void *)3);
		TCOD_list_t intList2 = TCOD_list_new();
		TCOD_list_set(intList2,0,(const void *)1);
		TCOD_list_add_all(intList2,intList);
	*/
	void addAll(const TCODList<T> &l2) {
		for (T *t=l2.begin(); t!= l2.end(); t++) {
			push(*t);
		}
	}
开发者ID:AMouri,项目名称:Rouge,代码行数:26,代码来源:list.hpp


注:本文中的TCODList::end方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。