本文整理汇总了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);
}
示例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;
}
示例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;
}
示例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;
}
示例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);
}
示例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 );
}
示例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++;
}
}
}
示例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;
}
示例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);
}
}
示例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());
}
}
示例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());
}
示例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);
}
}
}
示例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();
}
示例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;
}
示例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);
}
}