float TileData::eatTile(float amountWanted) { if(getFoodValue() < amountWanted) { amountWanted = getFoodValue(); } changeFoodValue(-amountWanted); return amountWanted; }
void TileData::saveToFile(FormattedFile &file) { if (mTile == NULL || getFoodValue() != mTile->getFoodValue()) { file << TileDataPropertyNames[FOOD_VALUE] << ' ' << getFoodValue() << ' '; } if (mTile == NULL || getRegrowthRate() != mTile->getRegrowthRate()) { file << TileDataPropertyNames[REGROWTH_VALUE] << ' ' << getRegrowthRate() << ' '; } if (mTile == NULL || getMaxFoodValue() != mTile->getMaxFoodValue()) { file << TileDataPropertyNames[MAX_FOOD_VALUE] << ' ' << getMaxFoodValue() << ' '; } file << "| "; }
void TileData::displayData(UIText &text) { format fmt("<12>%.1f</>/<12>%.1f</>\n"); fmt % getFoodValue() % getMaxFoodValue(); text << "<15>Food</>:\t\t" << fmt.str(); text << "<15>Regrowth</>:\t" << getRegrowthRate() << '\n'; }
void Mouth::draw(RenderContext const& ctx) { if (committed_) { // nothing to draw, physics will draw for us #ifdef DEBUG_DRAW_MOUTH float ratio = sqrt((getFoodValue() / density_) / size_); float widthLeft = width_ * ratio; float lengthLeft = length_ * ratio; glm::vec3 worldTransform = getWorldTransformation(); Shape3D::get()->drawRectangleXOYCentered(glm::vec3(vec3xy(worldTransform), 0), glm::vec2(lengthLeft, widthLeft), worldTransform.z, glm::vec3(0.5f,0,1)); #endif } else { glm::vec3 worldTransform = getWorldTransformation(); Shape3D::get()->drawRectangleXOYCentered(glm::vec3(vec3xy(worldTransform), 0), glm::vec2(length_, width_), worldTransform.z, debug_color); Shape3D::get()->drawLine(glm::vec3(vec3xy(worldTransform), 0), glm::vec3(vec3xy(worldTransform), 0) + glm::vec3(glm::rotate(getChildAttachmentPoint(0), worldTransform.z), 0), debug_color); } }