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


C++ Food类代码示例

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


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

示例1: update

		void update(void){
			f.update();
			razer_convert_keycode_to_pos(keys_history[0],&pos);
			if (last_pos.x!=pos.x || last_pos.y!=pos.y){
				last_pos.x=pos.x; last_pos.y=pos.y;
				//cout <<"key pos = "<<(pos).x<<","<<(pos).y<<endl;
			}
			direction_t d=LEFT;
			if(pos.x == 16 && pos.y == 4)
				d=UP;
			else if(pos.x == 16 && pos.y == 5)
				d=DOWN;
			else if(pos.x == 15 && pos.y == 5)
				d=LEFT;
			else if(pos.x == 17 && pos.y == 5)
				d=RIGHT;
			s.move(d);
			g.update();
			s.update();
			razer_update_keys(chroma,chroma->keys);
			usleep(400000);
			Cord sc = s.getFront();
			Cord fc = g.getPosition();
			if(sc.x==fc.x && sc.y==fc.y){
				Food tmp = Food();
				s.grow();
				s.grow();
				g = tmp;
			}
			razer_update(chroma);
			razer_frame_limiter(chroma,13);
		}
开发者ID:jamesshawver1,项目名称:razer_blackwidow_chroma_driver,代码行数:32,代码来源:snake.cpp

示例2: main

int main() {
    Food apple;
    Food pie;

    pie.beCooked(true);

    Food sugar = apple + pie;

    operator<<(cout, apple);
    cout << apple;

    cout << "-------\n";

    Food carrots = pie;
    carrots = pie;

    cout << carrots;

    cout << "-------\n";

    Car mustang;
    Food celery = mustang;

    cout << Food(mustang);
    cout << (Food)mustang;
    cout << static_cast<Food>(mustang);

    return 0;
}
开发者ID:2016-spring-csuf-benblazak-cpsc-121,项目名称:course-materials,代码行数:29,代码来源:01,03.cpp

示例3: PRINT_DEBUG

Dish* Ingridients::readDish(const QJsonObject& json) {
    PRINT_DEBUG("Reading new dish");

    QJsonArray itemsList = json["items"].toArray();
    Food* newFood = readFood(itemsList[0].toObject()["food"].toObject());
    Dish* newDish = new Dish(json["name"].toString().toStdString(), newFood,
                             itemsList[0].toObject()["amount"].toInt());

    avaliableItems.push_back(newFood);
    newFood->addItemList(&avaliableItems);

    for ( int index = 1; index < itemsList.size(); index++ ) {
        newFood = readFood(itemsList[index].toObject()["food"].toObject());
        newDish->addFood(newFood, itemsList[index].toObject()["amount"].toInt());
        std::list<Item*>::iterator it;

        for ( it = avaliableItems.begin(); ; it++ ) {
            if ( !(*it)->getName().compare(newFood->getName()) ) {
                delete newFood;

                break;
            } else if ( it == avaliableItems.end() ) {
                avaliableItems.push_back(newFood);
                newFood->addItemList(&avaliableItems);
            }
        }
    }

    return newDish;
}
开发者ID:ivanbilych,项目名称:jougen,代码行数:30,代码来源:ingridients.cpp

示例4: qCritical

Food Food::parseElement( const QDomElement &element, bool *ok )
{
  if ( element.tagName() != "food" ) {
    qCritical() << "Expected 'food', got '" <<element.tagName() << "'.";
    if ( ok ) *ok = false;
    return Food();
  }

  Food result = Food();

  QDomNode n;
  for( n = element.firstChild(); !n.isNull(); n = n.nextSibling() ) {
    QDomElement e = n.toElement();
    if ( e.tagName() == "name" ) {
      result.setName( e.text() );
    }
    else if ( e.tagName() == "taste" ) {
      result.setTaste( e.text() );
    }
  }


  if ( ok ) *ok = true;
  return result;
}
开发者ID:cornelius,项目名称:kode,代码行数:25,代码来源:simple.cpp

示例5: setFood

bool		Core::posFood(const Food &food)
{
  if ((food.getPosX() == _pos[0].getPosX()) && (food.getPosY() == _pos[0].getPosY()))
    setFood(true);
  else
    setFood(false);
  return (true);
}
开发者ID:VictorCholet,项目名称:cpp_nibbler,代码行数:8,代码来源:Core.cpp

示例6: insFood

void SamsMode::insFood(int nr)
{
	Food *f = new Food;
	f->energyLevel = *food_maxenergy;
//	f->resize();
	f->createBody( m_dynamicsWorld, btVector3( (critterspacing/2)+(critterspacing*nr), 3.0f, 8.0f ) );
	food_units.push_back( f );
}
开发者ID:ethicalfive,项目名称:critterthing,代码行数:8,代码来源:sams_mode.cpp

示例7: while

void Animal::updateStomachContents() {
    std::vector<Food *>::iterator it = stomach.begin();
    while (it != stomach.end()) {
        Food *food = (*it);
        if (food->getAmount() <= 0.0) {
            it = stomach.erase(it);
        } else {
            it++;
        }
    }
}
开发者ID:jefrsilva,项目名称:LD24Awareness,代码行数:11,代码来源:Animal.cpp

示例8: addFood

bool Store::addFood(Food food) {
  if (food.getId() != getNextId()) {
    throw "Food has invalid id #";
    return false;
  }
  bst->insert(food);
  hashBrownTable.insertItem(food.getId(), bst->get(food));
  numFoods++;
  maxId++;
  return true;
}
开发者ID:gratimax,项目名称:22c-project,代码行数:11,代码来源:Store.cpp

示例9: QListWidget

void AdminWindow::populateFoodList()
{
    listFood = new QListWidget();


    QWidget *widget = new QWidget();
    QVBoxLayout *layout = new QVBoxLayout();

    QSqlQuery query;
    query.prepare("SELECT * FROM Foods");
    bool r = query.exec();
    if(r == true)
    {
        while(query.next())
        {
          //  qDebug()<<"Food Selected: "<<query.record().value("name").toString();
            //======================
            QListWidgetItem* item = new QListWidgetItem();
            item->setSizeHint(QSize(0,60));



            FoodRow *catagory = new FoodRow();
            Food *food = new Food();
            food->setName(query.record().value("Name").toString());
            food->setCatagroy(query.record().value("Catagory").toString());
            food->setPrice(query.record().value("Price").toFloat());



            catagory->SetFood(food);
            layout->addWidget(catagory);


            connect(catagory, SIGNAL(signal_foodRemoved(QString)), this, SLOT(onFoodRemoved(QString)));
            connect(catagory, SIGNAL(signal_foodEdited(Food*)), this, SLOT(onFoodEdited(Food*)));


        }



        widget->setLayout(layout);
        ui->scrollArea_FoodAdd->setWidget(widget);



    }
}
开发者ID:nazib07,项目名称:RestaurantManagement,代码行数:49,代码来源:adminwindow.cpp

示例10: while

void		Core::displayBegin(const IGui *gui, const Food &food) const
{
  int		i;

  i = 0;
  if (gui)
    {
      while (i <= SIZE_SNAKE)
	{
	  gui->displayBody(_pos[i].getPosX(), _pos[i].getPosY());
	  i++;
	}
      gui->displayFood(food.getPosX(), food.getPosY());
    }
}
开发者ID:VictorCholet,项目名称:cpp_nibbler,代码行数:15,代码来源:Core.cpp

示例11: writeFood

void Ingridients::writeFood(QJsonObject& json, Food& food) const {
    PRINT_DEBUG("Writing food" << food.getName());

    json["name"] = QString::fromStdString(food.getName());
    json["mass"] = static_cast<qint64>(food.getMass());
    json["price"] = static_cast<qint64>(food.getPrice());
    json["measureType"] = static_cast<int>(food.getUnitType());
    json["fats"] = static_cast<qint64>(food.getFats());
    json["proteins"] = static_cast<qint64>(food.getProteins());
    json["carbohydrates"] = static_cast<qint64>(food.getCarbohydrates());
    json["calories"] = static_cast<qint64>(food.getCalories());
}
开发者ID:ivanbilych,项目名称:jougen,代码行数:12,代码来源:ingridients.cpp

示例12: moveAllFood

void InGameLayer::moveAllFood()
{
	Food* getFood = nullptr;
	float vx = mPanda->getVx();
	for (int i = foodList.size() - 1; i >= 0 ; i--)
	{
		getFood = foodList.at(i);
		getFood->move(vx);
		if (getFood->getPositionX() <= -getFood->getContentSize().width)
		{
			mFoodPool.takeIn(getFood);
			elementLayer->removeChild(getFood);
			foodList.eraseObject(getFood);
		}
	}
}
开发者ID:picassoporker,项目名称:runnning-panda,代码行数:16,代码来源:InGameLayer.cpp

示例13: TestBorderCollision

void Snake::Move(Food& food, int dif)
{
	TestBorderCollision();
	if (gameover)
	{
		return;
	}

	for (int i = 0; i < s_parts.size(); i++)
	{
		standard_field.EraseAtMap(s_parts[i].GetX(), s_parts[i].GetY());
		switch (s_parts[i].GetDirection())
		{
		case UP:
			s_parts[i].SetY(s_parts[i].GetY() - 1);
			break;
		case RIGHT:
			s_parts[i].SetX(s_parts[i].GetX() + 1);
			break;
		case DOWN:
			s_parts[i].SetY(s_parts[i].GetY() + 1);
			break;
		case LEFT:
			s_parts[i].SetX(s_parts[i].GetX() - 1);
			break;
		}

		standard_field.AddToMap(s_parts[i].GetX(), s_parts[i].GetY(), SNAKE_PART);
	}

	if (s_parts[0].GetX() == food.GetX() && s_parts[0].GetY() == food.GetY())
	{
		EatFood(food, dif);
		food.Generate();										    
	}

	for (int i = s_parts.size() - 1; i > 0; i--)
	{
		if (s_parts[i].GetDirection() != s_parts[i - 1].GetDirection())
		{
			s_parts[i].SetDirection(s_parts[i - 1].GetDirection());
		}
	}

	TestSelfCollision();
}
开发者ID:Redneloss,项目名称:ConsoleSnake,代码行数:46,代码来源:Snake.cpp

示例14: getInSortedOrder

bool Store::anyRecipeReferences(int id) {
  vector<Food> *v = getInSortedOrder();
  for (int i = 0; i < v->size(); i++) {
    Food food = v->operator[](i);
    if (food.isRecipe()) {
      vector<int> ingredients = food.getIngredients();
      for (int j = 0; j < ingredients.size(); j++) {
        if (ingredients[j] == id) {
          delete v;
          return true;
        }
      }
    }
  }
  delete v;
  return false;
}
开发者ID:gratimax,项目名称:22c-project,代码行数:17,代码来源:Store.cpp

示例15: GetRandPos

void Evolution::init()
{
    mFoodAmount = 500;
    mMaxBio = 520;
    mFoodSpawnTime = 0.0f;
    mFoodSpawnCycleLength = 0.0f;

    //int j = 0;
    for (int i=0; i<mMaxBio-mFoodAmount; ++i)
    {
        Stat stat;
        stat.pos = GetRandPos();
        //stat.canSee = false;
        //stat.eggEater = false;
        stat.carnivore = false;
        stat.lifeTimeLength = 180.0f;
        stat.eggTimeLength = 60.0f;
        stat.eggCycleLength = 30.0f;//30.0f
        stat.foodCycleLength = 45.0f;
        stat.speed = 20.0f;//20.0f
        stat.sightDistance = 0.0f;//0.0f
        //stat.species = j;
        stat.fearDistance = 17.0f;//17.0f
        stat.pursuitLength = 5.0f;
        //stat.foodBeforeEgg = 2;
        //stat.eyeParts = 0;
        //stat.eggEatParts = 0;
        //stat.carnivore = true;
        stat.carnivoreParts = 0;//0.0f
        //stat.family.pParent = NULL;
        stat.nameber = GetRandFloat()*1000.0f;

        Lifeform lifeform;
        lifeform.spawn(stat);
        lifeformList.push_back(lifeform);
        //++j;
        //if (j > 4) j = 0;
    }

    for (int i=0; i<mFoodAmount; ++i)
    {
        Food food;
        food.spawn(GetRandPos());
        foodList.push_back(food);
    }
}
开发者ID:DKennedyNS,项目名称:Evolution_Sim,代码行数:46,代码来源:Evolution.cpp


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