示例#1
0
bool RenderTextTrackCue::switchDirection(bool& switched, LayoutUnit& step)
{
    // 15. Switch direction: Move all the boxes in boxes back to their
    // default position as determined in the step above labeled default.
    setX(m_fallbackPosition.x());
    setY(m_fallbackPosition.y());

    // 16. If switched is true, jump to the step labeled done
    // positioning below.
    if (switched)
        return false;

    // 17. Negate step.
    step = -step;

    // 18. Set switched to true.
    switched = true;
    return true;
}
示例#2
0
/*exploser la bombe*/
void Bomb::detonateBomb(std::vector<Engin *> *asteroides){
	float *coords = new float[6];
	coords[0] = -0.8; coords[1] = -0.5; coords[2] = -0.2; coords[3] = 0.1; coords[4] = 0.4; coords[5] = 0.7;
	float rx = coords[(rand() % 6) + 1];
	float ry = coords[(rand() % 6) + 1];
	for (int i = 0; i < 2; i++){
		setX(rx + (((rand() % 3) - 1.0)/10.0));
		setY(ry + (((rand() % 3) - 1.0) / 10.0));
		draw(12, 0.3, true);

		for (int j = 0; j < asteroides->size(); j++)
		{
			if ((abs(abs((*asteroides)[j]->getPosX()) - abs(getX())) <= 0.1)
				&& (abs(abs((*asteroides)[j]->getPosY()) - abs(getY())) <= 0.1)){
				if (asteroides->size()>1){ std::swap((*asteroides)[j], asteroides->back()); asteroides->pop_back(); }
			}
		}
	}
}
示例#3
0
void IconButton::paintEvent(QPaintEvent *e) {
	Painter p(this);

	auto ms = getms();

	paintRipple(p, _st.rippleAreaPosition.x(), _st.rippleAreaPosition.y(), ms, _rippleColorOverride ? &(*_rippleColorOverride)->c : nullptr);

	auto down = isDown();
	auto overIconOpacity = (down || forceRippled()) ? 1. : _a_over.current(getms(), isOver() ? 1. : 0.);
	auto overIcon = [this] {
		if (_iconOverrideOver) {
			return _iconOverrideOver;
		} else if (!_st.iconOver.empty()) {
			return &_st.iconOver;
		} else if (_iconOverride) {
			return _iconOverride;
		}
		return &_st.icon;
	};
	auto justIcon = [this] {
		if (_iconOverride) {
			return _iconOverride;
		}
		return &_st.icon;
	};
	auto icon = (overIconOpacity == 1.) ? overIcon() : justIcon();
	auto position = _st.iconPosition;
	if (position.x() < 0) {
		position.setX((width() - icon->width()) / 2);
	}
	if (position.y() < 0) {
		position.setY((height() - icon->height()) / 2);
	}
	icon->paint(p, position, width());
	if (overIconOpacity > 0. && overIconOpacity < 1.) {
		auto iconOver = overIcon();
		if (iconOver != icon) {
			p.setOpacity(overIconOpacity);
			iconOver->paint(p, position, width());
		}
	}
}
示例#4
0
  void Object::load(xml::Xml &xml)
  {
    clear();

    /* Set attribute defaults */
      xml.setDefaultString("");
      xml.setDefaultInteger(0);
      xml.setDefaultFloat(0);


    /* Attributes ('type' is not forced to be set) */
      if(xml.isInteger("x") && xml.isInteger("y"))
      {
        name = xml.getString("name");
        type = xml.getString("type");
        setX(xml.getInteger("x"));
        setY(xml.getInteger("y"));
        setWidth(xml.getInteger("width"));
        setHeight(xml.getInteger("height"));
      }
      else
      {
        /* Throw */
          throw Exception() << "Missing or wrong typed attribute";
      }

    /* Properties */
      if(xml.toSubBlock("properties"))
      {
        try
        {
          properties.load(xml);
        }
        catch(Exception &exception)
        {
          xml.toBaseBlock();
          throw Exception() << "Error whilst loading properties: " << exception.getDescription();
        }

        xml.toBaseBlock();
      }
  }
示例#5
0
Label::Label(string lText, int x_, int y_, int width_, int height_, const Font *font_, bool animation_, float animationSpeed_, int indent_, bool align_)
{
    // Coords
    setX(x_);
    setY(y_);

    // Width / Height
    setWidth(width_);
    setHeight(height_);

    // Texts
    setText(lText);

    // Indent
    setIndent(indent_);

    // Animation
    setAnimation(animation_);

    // Invisible
    setAnimatonValue(0.0f);

    if(animation_)
    {
        // Speed
        setAnimationSpeed(animationSpeed_);
    }
    else
    {
        // Speed
        setAnimationSpeed(0.0f);
    }

    // Align
    setAlign(align_);

    // Font Id
    font = (Font*)font_;

    // Timer
    animationTimer = new Timer(animationSpeed_);
}
示例#6
0
PainterBezier::PainterBezier(QQuickItem  *parent)
:QQuickPaintedItem (parent)
,m_p1(QPointF(0.f,0.f))
,m_p2(QPointF(0.f,0.f))
,m_p3(QPointF(0.f,0.f))
,m_p4(QPointF(0.f,0.f))
,m_OutlineColor(Qt::black)
,m_FillColor(QColor(177,189,180))
,m_OutlineWidth(1.f)
,m_FillWidth(3.f)
{
    setX(0);
    setY(0);
    setWidth(1);
    setHeight(1);
    setFlag(ItemHasContents, true);
    //setAntialiasing(true);
    setRenderTarget(QQuickPaintedItem::FramebufferObject);
    setSmooth(true);
}
示例#7
0
void Particle::update(float frametime)
{
	if (!active)
		return;
	timeAlive += frametime;
	if (timeAlive >= maxTimeAlive)
	{
		resetParticle();
		return;
	}
	// update physics and drawing stuff

	setX(getX() + velocity.x * frametime);
	setY(getY() + velocity.y * frametime);
	rotationValue += frametime;
	if (rotationValue> 2*2.14159) //prevent overrotation
		rotationValue = 0;
	setRadians(rotationValue);

}
示例#8
0
/**
 * Update the robot values from the blob
 *
 * @param b The blob to update our object from.
 */
void VisualRobot::updateRobot(Blob b)
{
    setLeftTopX(b.getLeftTopX());
    setLeftTopY(b.getLeftTopY());
    setLeftBottomX(b.getLeftBottomX());
    setLeftBottomY(b.getLeftBottomY());
    setRightTopX(b.getRightTopX());
    setRightTopY(b.getRightTopY());
    setRightBottomX(b.getRightBottomX());
    setRightBottomY(b.getRightBottomY());
    setX(b.getLeftTopX());
    setY(b.getLeftTopY());
    setWidth(dist(b.getRightTopX(), b.getRightTopY(), b.getLeftTopX(),
                       b.getLeftTopY()));
    setHeight(dist(b.getLeftTopX(), b.getLeftTopY(), b.getLeftBottomX(),
                        b.getLeftBottomY()));
    setCenterX(getLeftTopX() + ROUND2(getWidth() / 2));
    setCenterY(getRightTopY() + ROUND2(getHeight() / 2));
    setDistance(1);
}
示例#9
0
/**
 * @brief Connexion::Connexion Création d'une nouvelle connexion
 * @param n1 Noeud d'ancrage de la connexion
 * @param n2 Noeud d'ancrage de la connexion
 *
 * Les connexions sont à double sens et des ressources
 * peuvent transiter du noeud 1 au noeud 2 et inversement.
 *
 * A la création un identifiant unique est défini.
 */
Connexion::Connexion(NodeConnectable &n1, NodeConnectable &n2, const GamerList &gl)
    : QGraphicsItem(0), n1(n1), n2(n2), lstGamer(gl), counterAdvance(0),
      stepMultiplier(1.5)
{
    setNextId();
    setX(n1.x());
    setY(n1.y());
    setZValue(1);

    //Calcule de la distance de la connexion
    distance = (int)sqrt(pow(n1.x()-n2.x(),2)+
                      pow(n1.y()-n2.y(),2));
    distance -= n2.getRadius();
    distance -= n1.getRadius();
    pathLegth = (int)(distance/stepMultiplier);

    //Connexion des noeud
    n1.connect(n2.getId(), this);
    n2.connect(n1.getId(), this);
}
void ffmpegWidget::mouseMoveEvent (QMouseEvent* event) {
	// drag the screen around so the pixel "grabbed" stays under the cursor
	if (event->buttons() & Qt::LeftButton) {
        // disable automatic updates
        disableUpdates = true;
        setX(oldx + (int)((clickx - event->x())/this->sfx));
        disableUpdates = false;        
        setY(oldy + (int)((clicky - event->y())/this->sfy));
        event->accept();
    }
	// drag the grid around so the pixel "grabbed" stays under the cursor
    else if (event->buttons() & Qt::RightButton) {
        // disable automatic updates
        disableUpdates = true;
        setGx(oldgx - (int)((clickx - event->x())/this->sfx));
        disableUpdates = false;
        setGy(oldgy - (int)((clicky - event->y())/this->sfy));
        event->accept();
    }
}
示例#11
0
文件: client.cpp 项目: edmondas/ncwm
void Client::gravitate(bool invert) {

    int dx = 0;
    int dy = 0;
    int gravity = NorthWestGravity;
    XSizeHints sizeHints;

    XCORE->sizeHints(clientWindow_, &sizeHints);

    if (sizeHints.flags & PWinGravity) {
        gravity = sizeHints.win_gravity;
    }

    switch (gravity) {
    case NorthEastGravity:
    case EastGravity:
    case SouthEastGravity:
        dx = -borderWidth_;
        break;
    default:
        break;
    }

    switch (gravity) {
    case SouthWestGravity:
    case SouthGravity:
    case SouthEastGravity:
        dy = -titleBarHeight_ - borderWidth_;
        break;
    default:
        break;
    }

    if (invert) {
        dx = -dx;
        dy = -dy;
    }

    setX(x() + dx);
    setY(y() + dy);
}
示例#12
0
void TankGameWidget::PaintText(const ScreenText& txt, QPainter& painter)
{
    if (txt.Finished())
    {
        return; //shall not be rendered now
    }

    painter.save();
    painter.setPen(txt.Pen());
    QFont font=painter.font();
    font.setPixelSize(txt.FontSize());
    font.setBold(true);
    painter.setFont(font);

    int rowStep=3*txt.FontSize();

    if (txt.Position().x()<0 || txt.Position().y()<0)
    {
        int xPos=txt.Position().x();
        int yPos=txt.Position().y();
        if (xPos<0) xPos=0;
        if (yPos<0) yPos=0;
        QRect rect(xPos, yPos, m_const.boardPixelSizeFloat.x(), txt.FontSize());
        for (const QString& s : txt.Text())
        {
            painter.drawText(rect, Qt::AlignCenter, s);
            rect.setY(rect.y()+rowStep);
        }
    }
    else
    {
        auto pos=ToScreen(txt.Position(), 0, 0);
        for (const QString& s : txt.Text())
        {
            painter.drawText(pos, s);
            pos.setY(pos.y()+rowStep);
        }
    }

    painter.restore();
}
示例#13
0
/**
 * Update the robot values from the blob
 *
 * @param b The blob to update our object from.
 */
void VisualCross::updateCross(Blob *b)
{
    setLeftTopX(b->getLeftTopX());
    setLeftTopY(b->getLeftTopY());
    setLeftBottomX(b->getLeftBottomX());
    setLeftBottomY(b->getLeftBottomY());
    setRightTopX(b->getRightTopX());
    setRightTopY(b->getRightTopY());
    setRightBottomX(b->getRightBottomX());
    setRightBottomY(b->getRightBottomY());
    setX(b->getLeftTopX());
    setY(b->getLeftTopY());
    setWidth(dist(b->getRightTopX(), b->getRightTopY(), b->getLeftTopX(),
                       b->getLeftTopY()));
    setHeight(dist(b->getLeftTopX(), b->getLeftTopY(), b->getLeftBottomX(),
                        b->getLeftBottomY()));
    setCenterX(getLeftTopX() + ROUND2(getWidth() / 2));
    setCenterY(getRightTopY() + ROUND2(getHeight() / 2));
    setDistance(1);
    setPossibleCrosses(&ConcreteCross::abstractCrossList);
}
示例#14
0
Predator::Predator() {
    component = new QQmlComponent(getEngine(), QUrl(QStringLiteral("qrc:/Predator.qml")));
    if(component->status() == component->Ready) {
        object = component->create(getEngine()->rootContext());
        object->setProperty("parent", QVariant::fromValue(getCanvas()));
        QQmlEngine::setObjectOwnership(object, QQmlEngine::CppOwnership);
    }
    else
        qDebug() << component->errorString();

    setY(50 + ((double)rand()/(double)(RAND_MAX)) * (getCanvasHeight() - 100));
    setX(50 + ((double)rand()/(double)(RAND_MAX)) * (getCanvasWidth() - 100));

    isPredator = true;

    // Randomize staring velocity to sweep
    velocity.setX(2.0 + ((double)rand()/(double)(RAND_MAX)) * -4.0);
    velocity.setY(2.0 + ((double)rand()/(double)(RAND_MAX)) * -4.0);

    lastVel = velocity;
}
示例#15
0
/**
 * Constructs a MessageWidget.
 *
 * This method is used for creation, synchronous and synchronous message types.
 *
 * @param scene   The parent to this class.
 * @param a       The role A widget for this message.
 * @param b       The role B widget for this message.
 * @param y       The vertical position to display this message.
 * @param sequenceMessageType Whether synchronous or asynchronous
 * @param id      A unique id used for deleting this object cleanly.
 *                The default (-1) will prompt generation of a new ID.
 */
MessageWidget::MessageWidget(UMLScene * scene, ObjectWidget* a, ObjectWidget* b,
                             int y, Uml::SequenceMessage::Enum sequenceMessageType,
                             Uml::ID::Type id /* = Uml::id_None */)
  : UMLWidget(scene, WidgetBase::wt_Message, id)
{
    init();
    m_pOw[Uml::RoleType::A] = a;
    m_pOw[Uml::RoleType::B] = b;
    m_sequenceMessageType = sequenceMessageType;
    if (m_sequenceMessageType == Uml::SequenceMessage::Creation) {
        y -= m_pOw[Uml::RoleType::B]->height() / 2;
        m_pOw[Uml::RoleType::B]->setY(y);
    }
    updateResizability();
    calculateWidget();
    y = y < getMinY() ? getMinY() : y;
    y = y > getMaxY() ? getMaxY() : y;
    setY(y);

    this->activate();
}
示例#16
0
//=============================================================================
// Entity bounces after collision with another entity
//=============================================================================
void Entity::bounce(VECTOR2 &collisionVector, Entity &ent)
{
    VECTOR2 Vdiff = ent.getVelocity() - velocity;
    VECTOR2 cUV = collisionVector;              // collision unit vector
    Graphics::Vector2Normalize(&cUV);
    float cUVdotVdiff = Graphics::Vector2Dot(&cUV, &Vdiff);
    float massRatio = 2.0f;
    if (getMass() != 0)
        massRatio *= (ent.getMass() / (getMass() + ent.getMass()));

    // If entities are already moving apart then bounce must
    // have been previously called and they are still colliding.
    // Move entities apart along collisionVector
    if(cUVdotVdiff > 0)
    {
        setX(getX() - cUV.x * massRatio);
        setY(getY() - cUV.y * massRatio);
    }
    else 
        deltaV += ((massRatio * cUVdotVdiff) * cUV);
}
示例#17
0
文件: matrix.c 项目: BigEd/wp34s
decNumber *matrix_getrc(decNumber *res, const decNumber *m) {
    decNumber ydn;
    int rows, cols, c, r, pos;
    int n = matrix_decompose(m, &rows, &cols, NULL);

    if (n < 0)
        return NULL;
    getY(&ydn);
    pos = dn_to_int(&ydn);
    pos -= n;
    if (pos < 0 || pos >= rows*cols) {
        err(ERR_RANGE);
        return NULL;
    }
    c = pos % cols + 1;
    r = pos / cols + 1;
    int_to_dn(res, r);
    int_to_dn(&ydn, c);
    setY(&ydn);
    return res;
}
示例#18
0
  void Vector::reset(double n1, double n2, Mode form) {
    mode = form;
    if (form == RECT) {
      x = n1;
      y = n2;
      setMag();
      setAngle();
    }
    else if (form == POL) {
      mag = n1;
      angle = n2 / Rad_to_deg;
      setX();
      setY();
    }
    else {
      cerr << "Incorrect 3rd argument to Vector -- "
	   << "vector set to 0\n";
      x = y = mag = angle = 0.0;
      mode = RECT;
    }
  }
示例#19
0
/**
 * Overrides the standard paint event.
 */
void PreconditionWidget::paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget)
{
    Q_UNUSED(option);
    Q_UNUSED(widget);

    int w = width();
    int h = height();

    int x = m_objectWidget->x() + m_objectWidget->width() / 2;
    x -= w/2;
    setX(x);
    int y = this->y();

    //test if y isn't above the object
    if (y <= m_objectWidget->y() + m_objectWidget->height()) {
        y = m_objectWidget->y() + m_objectWidget->height() + 15;
    }
    if (y + h >= m_objectWidget->getEndLineY()) {
        y = m_objectWidget->getEndLineY() - h;
    }
    setY(y);
    setPenFromSettings(painter);
    if (UMLWidget::useFillColor()) {
        painter->setBrush(UMLWidget::fillColor());
    }
    {
        const QFontMetrics &fm = getFontMetrics(FT_NORMAL);
        const int fontHeight  = fm.lineSpacing();
        const QString precondition_value = QLatin1String("{ ") + name() + QLatin1String(" }");
        //int middleX = w / 2;
        int textStartY = (h / 2) - (fontHeight / 2);
        painter->drawRoundRect(0, 0, w, h, (h * 60) / w, 60);
        painter->setPen(textColor());
        painter->setFont(UMLWidget::font());
        painter->drawText(PRECONDITION_MARGIN, textStartY,
                       w - PRECONDITION_MARGIN * 2, fontHeight, Qt::AlignCenter, precondition_value);
    }

    UMLWidget::paint(painter, option, widget);
}
示例#20
0
HandleItem::HandleItem( QRect rect, QGraphicsScene *scene, const QColor color) : QGraphicsItem( 0, scene ),
                        m_role(HandleItem::CenterHandle),
                        m_color(color), m_item(new QGraphicsRectItem( rect, 0, scene ))
{
    // This constructor sets up the center handle, as well as creates the other handles and links everything together.
    // The center handle must know about all of the other handles so it can translate them with the object

    HandleItem *topHandle = new HandleItem( m_item, color, HandleItem::TopHandle, scene );
    topHandle->SetRectItem(m_item);
    
    HandleItem *rightHandle = new HandleItem(m_item, color, HandleItem::RightHandle, scene );
    rightHandle->SetRectItem(m_item);
    
    HandleItem *leftHandle = new HandleItem( m_item, color, HandleItem::LeftHandle, scene );
    leftHandle->SetRectItem(m_item);
    
    HandleItem *bottomHandle = new HandleItem(m_item, color, HandleItem::BottomHandle, scene );
    bottomHandle->SetRectItem(m_item);

    m_handles.push_back(topHandle);
    m_handles.push_back(rightHandle);
    m_handles.push_back(leftHandle);
    m_handles.push_back(bottomHandle);

    topHandle->SetDependentHandles(QList<HandleItem*>() << rightHandle << leftHandle << this);

    rightHandle->SetDependentHandles(QList<HandleItem*>() << topHandle << bottomHandle << this);

    leftHandle->SetDependentHandles(QList<HandleItem*>() << topHandle << bottomHandle << this);

    bottomHandle->SetDependentHandles(QList<HandleItem*>() << rightHandle << leftHandle << this);

    this->SetDependentHandles(QList<HandleItem*>() << rightHandle << leftHandle << topHandle << bottomHandle);

    SetDefaults();
    
    setX(m_item->rect().left() + m_item->rect().width() / 2 - HandleRadius);
    setY(m_item->rect().y() + m_item->rect().height() / 2 - HandleRadius);
    
}
示例#21
0
 void Player::collidePlatform(GameObject& p)
 {
    // "Latch" onto a platform if we land onto it  
    if(y() + m_anims.currentAnim().frame().h - p.y() <= 4 && m_jumpState != Jumping)
    {
       setY(p.y() - height());
       if(m_jumpState == Falling)
       {
          m_anims.setCurrentAnim(m_direction == 1 ? "land_right" : "land_left");
          m_jumpState = Landing;
          m_landSound.play();
       }
       else if(m_jumpState == Landing && m_anims.currentAnim().currentFrameNumber() == m_anims.currentAnim().frameCount() - 1)
       {
          m_anims.setCurrentAnim(m_direction == 1 ? (m_moveForward ? "run_right" : "wait_right") : (m_moveForward ? "run_left" : "wait_left"));
          m_jumpState = Standing;
       }
       m_fallSpeed = 0;
       m_currentPlatformStart = p.x();
       m_currentPlatformEnd = p.x() + p.width();
    }
 }
void SceneGraphDeviceContext::DrawMusicText(const std::wstring &text, int x, int y, bool)
{
    Q_ASSERT(m_fontStack.top());

    QFont font(QString::fromStdString(m_fontStack.top()->GetFaceName()));

    // Note: Verovio calls it point size but it is actually pixel size. Qt can only handle pixel size in int, thus it
    // would be better to use point size.
    int pixelSize = static_cast<int>(translate(m_fontStack.top()->GetPointSize()));
    font.setPixelSize(pixelSize);

    // Memory management is handled by m_quickItem (set in AddQuickItem)
    auto musicTextQuickItem = new TextQuickItem();

    musicTextQuickItem->appendText(QString::fromStdWString(text), font);

    musicTextQuickItem->setX(static_cast<double>(translateX(x)));
    musicTextQuickItem->setY(static_cast<double>(translateY(y)));
    musicTextQuickItem->calcPos();

    AddQuickItem(musicTextQuickItem);
}
示例#23
0
文件: qmloutput.cpp 项目: KDE/kscreen
void QMLOutput::currentModeIdChanged()
{
    if (!m_output) {
        return;
    }

    if (m_rightDock) {
        QMLOutput *rightDock = m_rightDock;
        float newWidth = currentOutputWidth() * m_screen->outputScale();
        setX(rightDock->x() - newWidth);
        setRightDockedTo(rightDock);
    }

    if (m_bottomDock) {
        QMLOutput *bottomDock = m_bottomDock;
        float newHeight = currentOutputHeight() * m_screen->outputScale();
        setY(bottomDock->y() - newHeight);
        setBottomDockedTo(bottomDock);
    }

    Q_EMIT currentOutputSizeChanged();
}
示例#24
0
/**
 * Synchronizes the state of this body with the internal Box2D state.
 */
void Box2DBody::synchronize()
{
    Q_ASSERT(mBody);
    mSynchronizing = true;

    const b2Vec2 position = mBody->GetPosition();
    const float32 angle = mBody->GetAngle();

    const qreal newX = position.x * scaleRatio;
    const qreal newY = -position.y * scaleRatio;
    const qreal newRotation = -(angle * 180.0) / b2_pi;

    if (!qFuzzyCompare(x(), newX))
        setX(newX);
    if (!qFuzzyCompare(y(), newY))
        setY(newY);

    if (!qFuzzyCompare(rotation(), newRotation))
        setRotation(newRotation);

    mSynchronizing = false;
}
示例#25
0
bool TiledObject::setCollisionIndex(int index)
{
    if(m_collisionIndex == index)
        return false;
    if(index < -1 || index > m_collisionItems.count())
    {
        qWarning() << "TiledObject: Collision index out of range.";
        return false;
    }
    if(index == -1 || index == m_collisionItems.count())
    {
        m_collisionIndex = index;
        emit collisionIndexChanged();
        return false;
    }

    if(index >= 0 && index < m_collisionItems.count())
    {
        CollisionItem *item = m_collisionItems[index];
        if(!item)
            return false;

        setProperties(item->properties());
        setX(item->x());
        setY(item->y());
        setWidth(item->width());
        setHeight(item->height());
        setRotation(item->rotation());

        setVisible(item->isVisible());
        setId(item->id());
        setBody(item->body());
    }

    m_collisionIndex = index;
    emit collisionIndexChanged();

    return true;
}
示例#26
0
void Container::init()
{
    if (_initialized) return;

    setModal(true);
    setFullscreen(false);

    auto game = Game::getInstance();

    setX((game->renderer()->width()  - 537)/2);
    setY((game->renderer()->height() - 376)/2);

    addUI("background", new Image("art/intrface/loot.frm"));

    addUI("button_done", new ImageButton(ImageButton::TYPE_SMALL_RED_CIRCLE, 478, 331));
    getActiveUI("button_done")->addEventHandler("mouseleftclick", [this](Event* event){ this->onDoneButtonClick(dynamic_cast<MouseEvent*>(event)); });


    // TAKEALL
    // invmadn
    // invmaup

    // invupds
    // invupin
    // invupout


    auto dudeList = new ItemsList(170, 35);
    dudeList->setItems(Game::getInstance()->player()->inventory());
    addUI(dudeList);

    auto containerList = new ItemsList(292, 35);
    containerList->setItems(object()->inventory());
    addUI(containerList);

    dudeList->addEventHandler("itemdragstop", [containerList](Event* event){ containerList->onItemDragStop(dynamic_cast<MouseEvent*>(event)); });
    containerList->addEventHandler("itemdragstop", [dudeList](Event* event){ dudeList->onItemDragStop(dynamic_cast<MouseEvent*>(event)); });

}
示例#27
0
void SVGRootInlineBox::layoutRootBox()
{
    RenderBlock* parentBlock = block();
    ASSERT(parentBlock);

    IntRect childRect;
    for (InlineBox* child = firstChild(); child; child = child->nextOnLine()) {
        // Skip generated content.
        if (!child->renderer()->node())
            continue;
        childRect.unite(child->calculateBoundaries());
    }

    int xBlock = childRect.x();
    int yBlock = childRect.y();
    int widthBlock = childRect.width();
    int heightBlock = childRect.height();

    // Finally, assign the root block position, now that all content is laid out.
    parentBlock->setLocation(xBlock, yBlock);
    parentBlock->setWidth(widthBlock);
    parentBlock->setHeight(heightBlock);

    // Position all children relative to the parent block.
    for (InlineBox* child = firstChild(); child; child = child->nextOnLine()) {
        // Skip generated content.
        if (!child->renderer()->node())
            continue;
        child->adjustPosition(-xBlock, -yBlock);
    }

    // Position ourselves.
    setX(0);
    setY(0);
    setLogicalWidth(widthBlock);
    setLogicalHeight(heightBlock);
    setBlockLogicalHeight(heightBlock);
    setLineTopBottomPositions(0, heightBlock);
}
void twistedpair::initDC (void) {
  nr_double_t d   = getPropertyDouble ("d");
  nr_double_t rho = getPropertyDouble ("rho");
  calcLength ();

  if (d != 0.0 && rho != 0.0 && len != 0.0) {
    // tiny resistances
    nr_double_t g1 = M_PI * sqr (d / 2) / rho / len;
    nr_double_t g2 = g1;
    setVoltageSources (0);
    allocMatrixMNA ();
    setY (NODE_1, NODE_1, +g1); setY (NODE_2, NODE_2, +g1);
    setY (NODE_1, NODE_2, -g1); setY (NODE_2, NODE_1, -g1);
    setY (NODE_3, NODE_3, +g2); setY (NODE_4, NODE_4, +g2);
    setY (NODE_3, NODE_4, -g2); setY (NODE_4, NODE_3, -g2);
  }
  else {
    // DC shorts
    setVoltageSources (2);
    allocMatrixMNA ();
    voltageSource (VSRC_1, NODE_1, NODE_2);
    voltageSource (VSRC_2, NODE_3, NODE_4);
  }
}
示例#29
0
Joueur::Joueur(int id, int x , int y){
    setX(x);
    setY(y);
    this->id = id;
    xSprite = 11;
    ySprite = 505;
    lSprite = 22;
    hSprite = 36;
    hauteur = 35;
    largeur = 19;
    maxHigh = 50;
    currentHigh = 0;
    step = 0;
    pauseSprite = 15;
    state = STANDING;
    orientG = false;
    nbMaxBombes = 1;
    nbBombes = 0;
    hp = 1;
    bombes.resize(0);
    immortality = false;
    immortalityCD = 1500;
    bonusPower = 1;
    bonusJump = 0;
    bonusTrigger = false;
    tired = 1;
    nbKills = 0;
    killBy = -1;

    if(id <4) // 1 : le nombre de couleurs différentes existantes
      sprite = QPixmap(QString("../Game1/ressource/sprites_bomberman_p%1.png").arg(id));
    else
        sprite = QPixmap("../Game1/ressource/sprites_bomberman.png");

    currentImage = sprite.copy(xSprite,ySprite,lSprite,hSprite);
    picture = new QGraphicsPixmapItem(currentImage);
    picture->setPos(x,y);
}
示例#30
0
void Boom::update(float frameTime)
{
	Entity::update(frameTime);

	if(active) {
		timeOnScreen += frameTime;
	}

 	if (timeOnScreen > BOOM_TIME){
		setActive(false);
		setVisible(false);
		setX(-2*GAME_WIDTH);
		setY(-2*GAME_HEIGHT);

		timeOnScreen = 0;
	}

	edge.bottom = spriteData.y + (spriteData.height * BOOM_IMAGE_SCALE) - BOOM_RADIUS_OFFSET;
	edge.top = spriteData.y + BOOM_RADIUS_OFFSET;
	edge.right = spriteData.x + (spriteData.width * BOOM_IMAGE_SCALE) - BOOM_RADIUS_OFFSET;
	edge.left = spriteData.x + BOOM_RADIUS_OFFSET;

}