void Game::interfejs(float hp, float bullets, Text &h, Text &b, Vector2f poz, float magazynek, int runda, Text &round, int ile_zombii, Text &licznik_zombie, Text &gun_name, string gun, RectangleShape &sprint, bool isSprint, Time czas) { h.setString("hp: "+to_string((int)hp)); b.setString("bullets: "+to_string((int)magazynek)+" / " +to_string((int)bullets)); h.setPosition(poz.x + 1280 / 2-80, poz.y - 360+20); b.setPosition(poz.x + 1280 / 2 - 265, poz.y + 360 - 40); gun_name.setString(gun); gun_name.setPosition(poz.x + 1280 / 2 - 265, poz.y + 360 - 80); round.setString("round: " + to_string(runda)); round.setPosition(poz.x - 1280 / 2 + 10, poz.y + 360 - 40); licznik_zombie.setString("zombies left to kill: " + to_string(ile_zombii)); licznik_zombie.setPosition(poz.x - 1280 / 2 +10 , poz.y - 360 + 20); sprint.setPosition(poz.x + 1280 / 2 - 90, poz.y - 360 + 70); if(isSprint && sprint.getSize().x >0) sprint.setSize(Vector2f(sprint.getGlobalBounds().width -(15.0f*czas.asSeconds()), sprint.getGlobalBounds().height )); else { if(sprint.getSize().x <= 15*5)sprint.setSize(Vector2f(sprint.getGlobalBounds().width + (7.5f*0.5f*czas.asSeconds()), sprint.getGlobalBounds().height)); } }
//Точка входит в квадрат? bool Check(RectangleShape rect, CircleShape shape){ Vector2f coordrect = rect.getPosition(); Vector2f coordshape = shape.getPosition(); if (coordrect.x <= coordshape.x && coordrect.y <= coordshape.y && coordrect.x + rect.getSize().x >= coordshape.x && coordrect.y + rect.getSize().y >= coordshape.y) { return true; } else { return false; } }
Player(int player, float x, float y){ // == Создание игрока == rectangle.setPosition(Vector2f(x, y)); //Позиция игрока this->player = player; //ID игрока rectangle.setSize(Vector2f(20, 20)); //Размер rectangle.setFillColor(Color::Green); //Цвет // == Создание пушки == Vector2f centerTank = { 0, 0 }; centerTank.x = rectangle.getPosition().x + (rectangle.getSize().x / 2); //Центр танка по x centerTank.y = rectangle.getPosition().y + (rectangle.getSize().y / 2); //Центр танка по y turret.setPrimitiveType(LinesStrip); turret.append(centerTank); //Начало пушки из танка centerTank.y -= 25; turret.append(centerTank); //Смещение по y на 10 };
void UIComponentTreeViewItem::onRender(Renderer* renderer, UIView* view) { // Render this item full size /*RectangleShape back; back.setRect(view->getBounds()); back.setColor(Color::Red); renderer->draw(back);*/ // Render a little expandable flag if it applies if(mParent->getChildCount() > 0) { RectangleShape back; back.setRect(mParent->getChild(0)->getBounds()); back.setSize(5.f, back.getSize().y); back.setColor(Color::Red); renderer->draw(back); } }
void RenderSystem::update(float dt, std::vector<GameObject*>* objects) { for (Ite i = objects->begin(); i != objects->end(); i++) { RenderComponent* render = (*i)->getComponent<RenderComponent>(); if (render != nullptr) { RectangleShape shape = *render->getDrawable(); PhysicsComponent* physics = (*i)->getComponent<PhysicsComponent>(); if (physics != nullptr) { Vector2f position = mScale * flipY(physics->getBody()->GetPosition()); shape.setPosition(position); shape.setSize(1.02f * mScale * physics->getSize()); shape.setOrigin(shape.getSize() * 0.5f); // positive direction is opposite in Box2D shape.setRotation(-1.0f * physics->getBody()->GetAngle() * 180 / b2_pi); } mWindow->draw(shape); } } }
float bottom() const noexcept { return y() + shape.getSize().y / 2.f; }
float top() const noexcept { return y() - shape.getSize().y / 2.f; }
float right() const noexcept { return x() + shape.getSize().x / 2.f; }
float left() const noexcept { return x() - shape.getSize().x / 2.f; }
float bottom() { return y() + shape.getSize().y / 2.f; }
float top() { return y() - shape.getSize().y / 2.f; }
float right() { return x() + shape.getSize().x / 2.f; }
float left() { return x() - shape.getSize().x / 2.f; }
// function for initialize a shapes void initShape(RectangleShape& shape, Vector2f const& pos, Color const& color ) { shape.setFillColor(color); shape.setPosition(pos); shape.setOrigin(shape.getSize() * 0.5f); // the center of rectangle }