Ejemplo n.º 1
0
BombExplosionItem::BombExplosionItem(Bomb* p_model, Granatier::Direction::Type direction, int bombPower, KGameRenderer* renderer, qreal svgScaleFactor) : KGameRenderedItem(renderer, QStringLiteral(""))
{
    m_direction = direction;
    m_explosionID = p_model->explosionID();

    m_svgScaleFactor = svgScaleFactor;

    QString strElemetId;
    int width = 1;
    int height = 1;
    switch(m_direction)
    {
        case Granatier::Direction::NORTH:
            setSpriteKey(QStringLiteral("bomb_blast_north_0"));
            width = Granatier::CellSize * 0.5;
            height = Granatier::CellSize * 1.5;
            break;
        case Granatier::Direction::EAST:
            setSpriteKey(QStringLiteral("bomb_blast_east_0"));
            width = Granatier::CellSize * 1.5;
            height = Granatier::CellSize * 0.5;
            break;
        case Granatier::Direction::SOUTH:
            setSpriteKey(QStringLiteral("bomb_blast_south_0"));
            width = Granatier::CellSize * 0.5;
            height = Granatier::CellSize * 1.5;
            break;
        case Granatier::Direction::WEST:
            setSpriteKey(QStringLiteral("bomb_blast_west_0"));
            width = Granatier::CellSize * 1.5;
            height = Granatier::CellSize * 0.5;
            break;
    }

    if((static_cast<int>(Granatier::CellSize) - width) % 2 != 0)
    {
        width--;
    }
    if((static_cast<int>(Granatier::CellSize) - height) % 2 != 0)
    {
        height--;
    }
    m_itemSizeSet = QSize(width, height);

    QSize svgSize = m_itemSizeSet / m_svgScaleFactor;
    setRenderSize(svgSize);
    setScale(m_svgScaleFactor);

    setZValue(303 + bombPower);
}
Ejemplo n.º 2
0
BonusItem::BonusItem(Bonus* p_model, KGameRenderer* renderer) : ElementItem (p_model, renderer)
{
    setSpriteKey(p_model->getImageId());
    m_undestroyableExplosionID = 0;
    m_destructionTimer = NULL;
    m_destructionCounter = 0;
}
Ejemplo n.º 3
0
void Explodable::setState(Explodable::State state)
{
	m_state = state;
	setRandomFrame();
	if (m_state == Moving)
	{
		m_nextBoundingRect.setSize(QSizeF(m_relativeWidth, m_relativeHeight));
		setSpriteKey(m_mainSvg);
	}
	else
	{
		m_nextBoundingRect.setSize(QSizeF(EXPLOSION_RELATIVE_SIZE_W, EXPLOSION_RELATIVE_SIZE_H));
		setSpriteKey(m_explosionSvg);
	}
	resize(m_lastSize);
}
Ejemplo n.º 4
0
KBounceBall::KBounceBall( KBounceRenderer* renderer, KBounceBoard* board )
: KGameRenderedItem(renderer,"", board ), m_renderer( renderer ), m_board( board ),
    m_soundDelay( 0 ), m_size( QSize( 16, 16 ) ), m_framesNum( 0 ), m_xPos( 0 ), m_yPos( 0 ) 
{
	setSpriteKey("ball");
	resetPixmaps();
	m_nextBoundingRect.setSize( QSizeF( BALL_RELATIVE_SIZE, BALL_RELATIVE_SIZE ) );
}
Ejemplo n.º 5
0
void BlockItem::startDestructionAnimation()
{
    m_destructionCounter = 0;
    m_destructionTimer = new QTimer(this);
    m_destructionTimer->setInterval(300);
    m_destructionTimer->start();
    connect(m_destructionTimer, &QTimer::timeout, this, &BlockItem::destructionAnimation);

    setSpriteKey(QStringLiteral("arena_block_highlight"));
}
Ejemplo n.º 6
0
void BombExplosionItem::updateAnimationn(int nFrame)
{
    QString strElemetId;
    switch(m_direction)
    {
        case Granatier::Direction::NORTH:
            setSpriteKey(QStringLiteral("bomb_blast_north_%1").arg(nFrame));
            break;
        case Granatier::Direction::EAST:
            setSpriteKey(QStringLiteral("bomb_blast_east_%1").arg(nFrame));
            break;
        case Granatier::Direction::SOUTH:
            setSpriteKey(QStringLiteral("bomb_blast_south_%1").arg(nFrame));
            break;
        case Granatier::Direction::WEST:
            setSpriteKey(QStringLiteral("bomb_blast_west_%1").arg(nFrame));
            break;
    }
}
Ejemplo n.º 7
0
void CellItem::updatePixmap()
{
    QList<QGraphicsItem*> children = childItems();
    qDeleteAll(children);

    QList<QString> spriteKeys = s_stateNames[m_state];
    setSpriteKey(spriteKeys[0]);
    for(int i=1; i<spriteKeys.count(); i++)
        addOverlay(spriteKeys[i]);
    if(m_state == KMinesState::Revealed)
    {
        if(m_digit != 0)
            addOverlay(s_digitNames[m_digit]);
        else if(m_hasMine)
        {
            if(m_exploded)
                addOverlay(QStringLiteral( "explosion" ));
            addOverlay(QStringLiteral( "mine" ));
        }
    }
}
Ejemplo n.º 8
0
BlockItem::BlockItem(Block* p_model, KGameRenderer* renderer) : ElementItem (p_model, renderer)
{
    setSpriteKey(p_model->getImageId());
    m_destructionTimer = nullptr;
    connect(p_model, SIGNAL(startDestructionAnimation()), this, SLOT(startDestructionAnimation()));
}
Ejemplo n.º 9
0
 void Piece::updateSpriteKey()
 {
     setSpriteKey ( spriteKey ( m_type, m_color ) );
     update();
 }