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


C++ Inventory::get方法代码示例

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


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

示例1: draw_player_inventory

static void draw_player_inventory(GameState* gs, Inventory& inv,
		const BBox& bbox, int min_slot, int max_slot, int slot_selected = -1) {
	int mx = gs->mouse_x(), my = gs->mouse_y();
	int slot = min_slot;
	for (int y = bbox.y1; y < bbox.y2; y += TILE_SIZE) {
		for (int x = bbox.x1; x < bbox.x2; x += TILE_SIZE) {
			if (slot >= max_slot)
				break;

			ItemSlot& itemslot = inv.get(slot);

			BBox slotbox(x, y, x + TILE_SIZE, y + TILE_SIZE);
			Colour outline(COL_UNFILLED_OUTLINE);
			if (itemslot.amount > 0 && slot != slot_selected) {
				outline = COL_FILLED_OUTLINE;
				if (slotbox.contains(mx, my)) {
					outline = COL_PALE_YELLOW;
					draw_console_item_description(gs, itemslot.item);
				}
			}

			if (slot != slot_selected)
				draw_player_inventory_slot(gs, itemslot, x, y);
			//draw rectangle over item edges
			gl_draw_rectangle_outline(slotbox, outline);

			slot++;
		}
	}

	if (slot_selected != -1) {
		draw_player_inventory_slot(gs, inv.get(slot_selected),
				gs->mouse_x() - TILE_SIZE / 2, gs->mouse_y() - TILE_SIZE / 2);
	}
}
开发者ID:gigimoi,项目名称:lanarts,代码行数:35,代码来源:InventoryContent.cpp

示例2: setItem

//----------------------------------------- setItem()
void Borrow::setItem(istream& in, Inventory& inv, MovieFactory& mf) {
	// assume that items can only be movies
	string mediaCode = "Z"; string movieCode = "Z";
	in >> mediaCode >> movieCode;
	Item* target = mf.createItem(movieCode);
	item = NULL;
	
	if(target != NULL && mediaCode.c_str()[0] == 'D') {
		target->parseTransactionData(in);
		Item* movieInStore = NULL;
		movieInStore = inv.get(target);		// modify movieInStore

		if(movieInStore != NULL) {
			item = movieInStore;
		} else {item = NULL;}
		delete target;
	} else {
		in.ignore(256, '\n');		// consume the rest of the bad data
	}
}
开发者ID:jamesus95,项目名称:Cpp,代码行数:21,代码来源:borrow.cpp


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