本文整理汇总了C++中setY函数的典型用法代码示例。如果您正苦于以下问题:C++ setY函数的具体用法?C++ setY怎么用?C++ setY使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了setY函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: setX
/*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(); }
}
}
}
}
示例2: p
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());
}
}
}
示例3: clear
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();
}
}
示例4: setX
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_);
}
示例5: setX
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);
}
示例6: resetParticle
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);
}
示例7: setLeftTopX
/**
* 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);
}
示例8: QGraphicsItem
/**
* @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);
}
示例9: setX
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();
}
}
示例10: switch
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);
}
示例11: rect
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();
}
示例12: setLeftTopX
/**
* 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);
}
示例13: QQmlComponent
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;
}
示例14: UMLWidget
/**
* 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();
}
示例15: setX
//=============================================================================
// 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);
}