Esempio n. 1
0
void ItemContainer::changeBackground(QPixmap &newPict)
{
    picture = newPict;
    trimPicture();
    createPieces();
    update();
}
Esempio n. 2
0
void Renderer::createTumbler(const Maze& maze,
                             std::vector<SpritePiece>* pieces) {
  mTargetSize = maze.getSize() * CELL_SIZE;
  initTargets();

  auto cols = maze.getSize().x;
  auto rows = maze.getSize().y;
  sf::Sprite sprite;
  sprite.setTextureRect(sf::IntRect(0, 0, CELL_SIZE, CELL_SIZE));
  for (auto& target : mTargets) {
    auto view = target->getView();
    auto center = view.getCenter();
    auto pieceW = view.getSize().x;
    auto pieceH = view.getSize().y;
    auto x = center.x - pieceW / 2.0f;
    auto y = center.y - pieceH / 2.0f;
    auto vRect = sf::FloatRect(x, y, pieceW * 1.0f, pieceH * 1.0f);
    for (auto r = 0u; r < rows; ++r) {
      for (auto c = 0u; c < cols; ++c) {
        const auto& data = maze.getChipData(r, c);
        const auto& p = data.pos;
        const auto& chip = mMapchips.at(p[1]).at(p[0]);
        sprite.setTexture(chip);
        sprite.setPosition(c * CELL_SIZE * 1.0f, r * CELL_SIZE * 1.0f);
        if (vRect.intersects(sprite.getGlobalBounds())) {
          target->draw(sprite);
        }
      }
    }
  }

  createPieces(pieces);
}
Esempio n. 3
0
void ItemContainer::resizeEvent(QResizeEvent *event)
{
    width = event->size().width();
    height = event->size().height();
    pieceWidth = width/level;
    pieceHeight = height/level;
    trimPicture();
    createPieces();
    paintoption = paintAll;
}
Esempio n. 4
0
void Renderer::createScreenshot(const sf::Vector2u& targetSize,
                                std::vector<SpritePiece>* pieces,
                                std::function<void(sf::RenderTarget*)> drawTo) {
  mTargetSize = targetSize;
  initTargets();
  for (auto& target : mTargets) {
    drawTo(target.get());
  }
  createPieces(pieces);
}
Esempio n. 5
0
ItemContainer::ItemContainer(QPixmap &graph,State s,QWidget *parent)
    :width(300),height(300),state(s),level(state.N),
    pieceWidth(width/level),pieceHeight(height/level),
    picture(graph),paintoption(paintAll),QWidget(parent)
{
    resize(width,height);
    trimPicture();//trim the picture and save it to myPicture
    createPieces();//setup pieces
    timer = new QTimer(this);
    connect(timer,SIGNAL(timeout()),this,SLOT(updateArea()));
    connect(this,SIGNAL(moveDone()),this,SLOT(processNextMove()));//actually It could be done with invoking.
    setFocusPolicy(Qt::StrongFocus);
}
Esempio n. 6
0
Model::Player::Player
(
	std::string const & inName,
	Color::Color inColor,
	std::set< Utils::Expansion::Type > const & inExpansions
)
:
	mName( inName ),
	mColor( inColor ),
	mScore( 0 ),
	mPieces( createPieces( inExpansions ) ),
	mInfoChanged( new boost::signals2::signal< void () >() )
{
}
Esempio n. 7
0
void Renderer::createDebugTumbler(cpBody* body, const sf::Vector2u& tumblerSize,
                                  std::vector<SpritePiece>* pieces) {
  mTargetSize = tumblerSize;
  initTargets();

  cpBodyEachShape(body, [](cpBody* body, cpShape* shape, void* data) {
    auto type = reinterpret_cast<ShapeType*>(cpShapeGetUserData(shape));
    if (*type != ShapeType::Segment) return;

    reinterpret_cast<Renderer*>(data)->drawBar(shape);
  }, this);

  createPieces(pieces);
}