int getBestHeight (const int preferredHeight) { const int extra = getOutlineThickness() * 2; return jmax (getRowHeight() * 2 + extra, jmin (getRowHeight() * getNumRows() + extra, preferredHeight)); }
void DisplayGrid::draw(sf::RenderTarget &target, sf::RenderStates states) const { int amtX = obsMap->getWidth(); int amtY = obsMap->getHeight(); int sizeX = getSize().x; int sizeY = getSize().y; int tileX, tileY; sf::Vector2f tileSize(sizeX / amtX, sizeY / amtY); sf::RectangleShape tile(tileSize); sf::Vector2f pos = getPosition(); for (int x = 0; x < amtX; x++) { for (int y = 0; y < amtY; y++) { tileX = pos.x + tileSize.x * x; tileY = pos.y + tileSize.y * y; tile.setPosition(tileX, tileY); tile.setFillColor(getTileColor(obsMap->at(x, y))); tile.setOutlineColor(getOutlineColor()); tile.setOutlineThickness(getOutlineThickness()); target.draw(tile); } } }
float sfShape_getOutlineThickness(const sfShape* shape) { CSFML_CALL_RETURN(shape, getOutlineThickness(), 0.f); }
void radarStateClass::update(sf::RenderWindow& window) { sf::Event event; while(window.pollEvent(event)) { if(event.type == sf::Event::Closed) { window.close(); return; } else if(event.type == sf::Event::KeyPressed) { if(event.key.code == sf::Keyboard::Tab) { stopScan(); global::activeGameStateStack->pop(); return; } } } ++currentFrame; if(currentFrame > numberOfWaitFrame) { currentFrame = 0; } if(currentFrame == 0) { for(auto circleIte = listOfCircle.begin(); circleIte != listOfCircle.end(); ) { if(circleIte->getOutlineThickness() < maxThickness) { circleIte->setOutlineThickness(circleIte->getOutlineThickness() + 1); if(circleIte->getOutlineThickness() >= maxThickness) { circleIte->setFillColor(sf::Color::Transparent); } } else { circleIte->setRadius(circleIte->getRadius() + 0.1); } if(circleIte->getRadius() > maxRadius) { listOfCircle.erase(circleIte++); continue; } circleIte->setOrigin(circleIte->getRadius(), circleIte->getRadius()); ++circleIte; } } if(scannerTimer.getElapsedTime().asSeconds() > timeBetweenScan && inScan == false) { startScan(); } if(inScan == true) { moveScannerAndScan(); } global::activeGameStateStack->oldUpdate(window); }