QGraphicsItem * JackTransportClient::createGraphicsItem() { JackTransportGraphicsItem *graphicsItem = new JackTransportGraphicsItem(this); JackTransportThread *thread = (JackTransportThread*)getJackThread(); QObject::connect(thread, SIGNAL(changedPosition(QString)), graphicsItem, SLOT(changePosition(QString))); return graphicsItem; }
StrongEnemy::StrongEnemy(PlayerShip* player, irr::core::vector3df spawnPosition, irr::ITimer* timerReference, irr::scene::ISceneManager* sceneManagerReference) : EnemyShip(player, spawnPosition, 500, timerReference, "Assets/Ships/EnemyShips/StrongShip.obj", "Assets/Ships/EnemyShips/StrongShipTexture.jpg", sceneManagerReference, 2) { //Start the ship at the bottom changePosition(irr::core::vector3df(getPosition().X, -45, getPosition().Z)); currentLoop = 0; currentStage = stageA; timeElapsed = 0; shotsFired = 0; //adjust turn speed turnSpeed /= 3; //Set the cannon positions cannonPositions.push_back(irr::core::vector3df( 1, -1.5f, -1)); cannonPositions.push_back(irr::core::vector3df(-1, -1.5f, -1)); cannonPositions.push_back(irr::core::vector3df( 1, 1.5f, -1)); cannonPositions.push_back(irr::core::vector3df(-1, 1.5f, -1)); //Adjust the particle system's position engineParticleSystem->setPosition(irr::core::vector3df(0, 0.5f, -4)); }
//Optimized to use pointers by Ryan Davis void player::checkMovement(world *map, int x, int y) { unsigned int posOne[2]; unsigned int posTwo[2]; unsigned int posThree[2]; unsigned int posFour[2]; int speed = getSpeed(); x = (x >= 1) ? speed : x; x = (x <= -1) ? -speed : x; y = (y >= 1) ? speed : y; y = (y <= -1) ? -speed : y; speed = map -> getResolution() - speed; //This is a check of the lower bound of movement posOne[0] = (x + position[0] + 16)/map -> getResolution(), posOne[1] = (y + position[1] + 14)/map -> getResolution(); //This is a check of the upper bound of movement posTwo[0] = (x + speed + position[0] - 16)/map -> getResolution(), posTwo[1] = (y + speed + position[1] - 32)/map -> getResolution(); //This is a check of the lower bound of movement posThree[0] = (x + position[0] + 16)/map -> getResolution(), posThree[1] = (y + speed + position[1] - 32)/map -> getResolution(); //This is a check of the upper bound of movement posFour[0] = (x + speed + position[0] - 16)/map -> getResolution(), posFour[1] = (y + position[1] + 14)/map -> getResolution(); if(map -> getTileCollision(map -> checkTileMap(posOne)) && map -> getTileCollision(map -> checkTileMap(posTwo)) && map -> getTileCollision(map -> checkTileMap(posThree)) && map -> getTileCollision(map -> checkTileMap(posFour))) { //position[0] = x + position[0], position[1] = y + position[1]; posOne[0] = x + getPosition()[0], posOne[1] = y + getPosition()[1]; changePosition(posOne); } updatePosition(); }
void repozytorium::dopelnijEnter(int position, int xMax, int ile) { int pom = 1; position++; int odniesienie = position + xMax - ile; while((pom <= xMax) && (position < getDocumentSize()) && (position < odniesienie)) { position++; pom++; } if(position >= getDocumentSize()) return; int i = 0; vector<int>::iterator it = document.begin(); cout<<position<<endl; while( i < position) { it++; i++; } it--; cout<<"zaczynam wstawianie na pozycji "<< position<<endl; while (pom <= xMax) { it = document.insert(it, 10); changePosition(position, 1); position ++; pom++; } cout<<"koncze wstawianie na pozycji "<< position<<endl; }
void keyboard(unsigned char key, int x, int y){ GLfloat distanceToBall = distance(mainCamera.x, 0, mainCamera.z, ball.x, 0, ball.z); if(key == 'r'){ GLfloat _x = random(-7.5, 7.5); GLfloat _z = random(0, 13); changePosition(_x,_z); return; } if(key == 'a' && distanceToBall <= zoneRadius){ GLfloat radianAngle = (PI * 0.8f) / 180.0f; GLfloat deltaX = (ball.x - mainCamera.x); GLfloat deltaZ = (ball.z - mainCamera.z); GLfloat finalX= mainCamera.x + (deltaX * cos(radianAngle) + deltaZ * sin(radianAngle)); GLfloat finalZ = mainCamera.z + (-deltaX * sin(radianAngle) + deltaZ * cos(radianAngle)); ball.move(finalX - ball.x, -0.15, finalZ - ball.z); } else if(key == 'd' && distanceToBall <= zoneRadius){ GLfloat radianAngle = (PI * -0.8f) / 180.0f; GLfloat deltaX = (ball.x - mainCamera.x); GLfloat deltaZ = (ball.z - mainCamera.z); GLfloat finalX= mainCamera.x + (deltaX * cos(radianAngle) + deltaZ * sin(radianAngle)); GLfloat finalZ = mainCamera.z + (-deltaX * sin(radianAngle) + deltaZ * cos(radianAngle)); ball.move(finalX - ball.x, -0.15 , finalZ - ball.z); } else if(key == 's' && distanceToBall <= zoneRadius){ ball.move(0,-0.15,0); } keys[key] = true; }
void update(){ handleKeys(); GLfloat oldX = ball.x; GLfloat oldY = ball.y; GLfloat oldZ = ball.z; if(oldZ + ball.radius >= 15 && !keep){ scored = false; } ball.update(); if(distance(oldX, 0, oldZ, 0, 0, 14.65) < ball.radius + 0.35){ if(oldY > 3.05 && ball.y<= 3.05){ scored = true; } } if(ball.z + ball.radius > 15){ if(ball.y + ball.radius >= 4.4f){ GLfloat _x = random(-7.5, 7.5); GLfloat _z = random(0, 13); ball.move(0,0,0); ball.y = ball.radius; changePosition(_x,_z); } } if(distance(mainCamera.x, 0, mainCamera.z, ball.x, 0, ball.z) < 1.0f && !ball.locked){ mode = TURNING_MODE; } }
void TextObject::move(float x, float y, float sec){ float tx,ty,z,r,s; sprites[0]->getPosition(tx,ty,x,r,s); changePosition(x,y,z,r,s,sec); }
void ViWaveWidgetGroup::updateBindings() { ViWaveWidget *widget; ViWaveWidgetGroup::Action action; foreach(widget, mWidgets) { widget->disconnect(this); foreach(action, mActions) { if(action == ViWaveWidgetGroup::Zoom) { QObject::connect(widget, SIGNAL(zoomChanged(qint16)), this, SLOT(changeZoom(qint16))); } else if(action == ViWaveWidgetGroup::Pointer) { QObject::connect(widget, SIGNAL(pointerChanged(qint32)), this, SLOT(changePointer(qint32))); } else if(action == ViWaveWidgetGroup::Position) { QObject::connect(widget, SIGNAL(positionChanged(ViAudioPosition)), this, SLOT(changePosition(ViAudioPosition))); } else if(action == ViWaveWidgetGroup::Toolbars) { QObject::connect(widget, SIGNAL(toolbarsShown()), this, SLOT(showToolbars())); QObject::connect(widget, SIGNAL(toolbarsHidden()), this, SLOT(hideToolbars())); } } }
void Rope::changeImageByStatus(int _status, Hanger * _hanger) { status = _status; CCTexture2D *pTexture; CCRect rect; // 添加根据状态换图的代码 (注意添加这里width 和 height跟随图片的宽高变换) switch(status) { case ROPE_STATUS_NORMAL: pTexture = CCTextureCache::sharedTextureCache()->addImage("youxi/shenzi.png"); if (pTexture) { rect = CCRectZero; rect.size = pTexture->getContentSize(); setTexture(pTexture); setTextureRect(rect); } lengthOriginal = getContentSize().height * 0.8; break; case ROPE_STATUS_THROW: pTexture = CCTextureCache::sharedTextureCache()->addImage("youxi/shenzi2.png"); if (pTexture) { rect = CCRectZero; rect.size = pTexture->getContentSize(); setTexture(pTexture); setTextureRect(rect); } lengthOriginal = getContentSize().height * 0.8; scaleExchange = ROPE_EXCHANGE_CONTROL_THROW; break; case ROPE_STATUS_INTERSECT: pTexture = CCTextureCache::sharedTextureCache()->addImage("youxi/shenzi3.png"); if (pTexture) { rect = CCRectZero; rect.size = pTexture->getContentSize(); setTexture(pTexture); setTextureRect(rect); } lengthOriginal = getContentSize().height * 0.8; break; case ROPE_STATUS_PULL: pTexture = CCTextureCache::sharedTextureCache()->addImage("youxi/shenzi4.png"); if (pTexture) { rect = CCRectZero; rect.size = pTexture->getContentSize(); setTexture(pTexture); setTextureRect(rect); } lengthOriginal = getContentSize().height * 0.8; break; default: break; } changePosition(_hanger); }
static void changePositionHandler(struct cartJson *cj, struct hash *paramHash) /* Update position in cart, after performing lookup if necessary. * Usually we don't report what we just changed, but since we might modify it, * print out the final value. */ { char *newPosition = cartJsonRequiredParam(paramHash, "newValue", cj->jw, "changePosition"); if (newPosition) changePosition(cj, newPosition); }
void Cube::update(float elapsedTime) { changePosition(-1 * (this->velocity.x * elapsedTime), -1 * (this->velocity.y * elapsedTime), -1 * (this->velocity.z * elapsedTime)); vec3 velocity; velocity = MF.roundf(*getVelocity(), 1); if(velocity.x != 0.0f || velocity.z != 0.0f) this->rotate(velocity, elapsedTime); }
void useItem3(Sugoroku *s, SugorokuStatus *ss, int player_id, int target, Scene *scene) { //全部のプレイヤーの場所をシャッフル int i; int num2; for (i = 0; i < s->player_num; i++) { num2 = rand()%s->player_num; if(!s->player[i].is_goal && !s->player[num2].is_goal) changePosition(s->player, i, num2); } //printw("全員の位置をシャッフルしました.\n"); }
void Rope::doAction(float dt, Hanger * hanger) { switch(hanger->getStatus()) { case HANGER_STATUS_SWAYING: // 需要多转换一下角度 setRotation(angleCenter - hanger->getAngle()); changePosition(hanger); break; case HANGER_STATUS_THROW: case HANGER_STATUS_PULL_HAVING: case HANGER_STATUS_PULL_UNHAVING: // 放缩和重定义位置 changePosition(hanger); break; default: break; } switch(status) { case ROPE_STATUS_NORMAL: break; case ROPE_STATUS_THROW: scaleExchange--; if (scaleExchange == 0) { scaleExchange = ROPE_EXCHANGE_CONTROL_THROW; setScaleX(-getScaleX()); } break; case ROPE_STATUS_INTERSECT: setScaleX(-getScaleX()); break; case ROPE_STATUS_PULL: setScaleX(-getScaleX()); break; default: break; } }
/*! * 设置视屏显示全窗口模式 */ void IBMediaControlC::setFullScreenWindowMode(bool b_fullscren) { if(d->m_fullscreen_window_mode != b_fullscren) { d->m_fullscreen_window_mode =b_fullscren; sendCommand(QString("vo_fullscreen ")+ QString::number(1)); if(d->m_current_play_state == MEDIA_RUNNING_STATE_PAUSE)//处理暂停时全屏切换花屏的问题 { changePosition(d->m_i_current_time); } } }
void WidgetSlider::changedValue(float x, float UNUSED(y)) { float curX, curY, curZ; getPosition(curX, curY, curZ); float pX = CLIP(x - curX, 0.0f, _width) / _width; int state = roundf(pX * _steps); if (state == _state) // No change return; _state = state; if (_steps == 0) { changePosition(0.0); return; } changePosition(((float) _state) / _steps); setActive(true); }
WidgetSlider::WidgetSlider(::Engines::GUI &gui, const Common::UString &tag, const Common::UString &model) : ModelWidget(gui, tag, model), _position(0.0), _steps(0), _state(0) { _model->setClickable(true); _width = getWidth(); _thumb = _model->getNode("thumb"); assert(_thumb); changePosition(0.0); }
Rope::Rope(Hanger * hanger) { CCSprite(); initWithFile("youxi/shenzi.png"); setScale(0.8); lengthOriginal = getContentSize().height * 0.8; setRotation(angleCenter - hanger->getAngle()); changePosition(hanger); autorelease(); }
/*------------------------------------------------------------------------------ | MSStringParserData::changePosition(using signed value) | | | | Sets the current location for parsing to the relative position specified. | | For negative values,do the processing here with underflow checking. For | | positive values,use the unsigned delta_ method. | ------------------------------------------------------------------------------*/ MSStringParserData& MSStringParserData::changePosition(int delta_) { if (delta_<0) { unsigned newPosition; if ((_patternPosition<(-delta_))||(delta_==INT_MIN)) newPosition=0; else newPosition=_patternPosition+delta_; if ((_patternLength>0)&&(_tokenCount>0)) reparseTokens(_patternPosition,_parseText.length()); _patternLength=0; setPosition(newPosition); } else changePosition((unsigned)delta_); return *this; }
void init(void) { glClearColor(1.0,1.0,1.0,1.0); glShadeModel(GL_SMOOTH); render.loadTextures(); ball.loadTexture(); glEnable(GL_TEXTURE_2D); glEnable(GL_COLOR_MATERIAL); glEnable(GL_BLEND); glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); glEnable(GL_DEPTH_TEST); lights(); glEnable(GL_LIGHTING); glEnable(GL_LIGHT0); GLfloat _x = random(-7.5, 7.5); GLfloat _z = random(0, 13); changePosition(_x,_z); }
JackTransportGraphicsItem::JackTransportGraphicsItem(JackTransportClient *client, QGraphicsItem *parent) : QGraphicsRectItem(parent), padding(4) { setPen(QPen(QBrush(Qt::black), 1)); setBrush(Qt::white); labelItem = new GraphicsLabelItem(this); GraphicsContinuousControlItem *beatsPerMinuteControl = new GraphicsContinuousControlItem("Beats per minute", 1, 300, 120, 600, GraphicsContinuousControlItem::HORIZONTAL, 'g', -1, 1, this); GraphicsDiscreteControlItem *beatsPerBarControl = new GraphicsDiscreteControlItem("Beats per bar", 1, 32, 4, 320, GraphicsContinuousControlItem::HORIZONTAL, this); GraphicsDiscreteControlItem *beatTypeControl = new GraphicsDiscreteControlItem("Beat type", 1, 32, 4, 320, GraphicsContinuousControlItem::HORIZONTAL, this); beatsPerMinuteControl->setPos(padding, padding + 0 * (padding + beatsPerMinuteControl->rect().height())); beatsPerBarControl->setPos(padding, padding + 1 * (padding + beatsPerMinuteControl->rect().height())); beatTypeControl->setPos(padding, padding + 2 * (padding + beatsPerMinuteControl->rect().height())); controlsRect = (beatsPerMinuteControl->rect().translated(beatsPerMinuteControl->pos()) | beatsPerBarControl->rect().translated(beatsPerBarControl->pos()) | beatTypeControl->rect().translated(beatTypeControl->pos())); labelItem->setPos(controlsRect.bottomLeft() + QPointF(0, padding)); QObject::connect(beatsPerMinuteControl, SIGNAL(valueChanged(double)), client, SLOT(changeBeatsPerMinute(double))); QObject::connect(beatsPerBarControl, SIGNAL(valueChanged(int)), client, SLOT(changeBeatsPerBar(int))); QObject::connect(beatTypeControl, SIGNAL(valueChanged(int)), client, SLOT(changeBeatType(int))); changePosition(""); }
/** * @brief Constructor for JoystickControl widget. Sets up the image of a joystick */ JoystickControl::JoystickControl(QWidget *parent) : QGraphicsView(parent) { setMinimumSize(64, 64); setSizePolicy(QSizePolicy::MinimumExpanding, QSizePolicy::MinimumExpanding); setScene(new QGraphicsScene(this)); setRenderHints(QPainter::Antialiasing | QPainter::TextAntialiasing); m_renderer = new QSvgRenderer(); bool test = m_renderer->load(QString(":/gcscontrol/images/joystick.svg")); Q_UNUSED(test); Q_ASSERT(test); m_background = new QGraphicsSvgItem(); m_background->setSharedRenderer(m_renderer); m_background->setElementId(QString("background")); m_joystickEnd = new QGraphicsSvgItem(); m_joystickEnd->setSharedRenderer(m_renderer); m_joystickEnd->setElementId(QString("joystickEnd")); m_joystickArea = new QGraphicsSvgItem(); m_joystickArea->setSharedRenderer(m_renderer); m_joystickArea->setElementId(QString("joystickArea")); m_joystickArea->setPos( (m_background->boundingRect().width() - m_joystickArea->boundingRect().width()) * 0.5, (m_background->boundingRect().height() - m_joystickArea->boundingRect().height()) * 0.5 ); m_joystickArea->setVisible(false); QGraphicsScene *l_scene = scene(); l_scene->clear(); // This also deletes all items contained in the scene. l_scene->addItem(m_background); l_scene->addItem(m_joystickArea); l_scene->addItem(m_joystickEnd); l_scene->setSceneRect(m_background->boundingRect()); changePosition(0.0, 0.0); }
void setAction(FightActionEnum newAction) { action = newAction; changePosition(); }
void WidgetSlider::setState(int state) { _state = state; changePosition(CLIP(((float) _state) / _steps, 0.0f, 1.0f)); }
void repozytorium::addLetter(int letter, int tryb, string user, int xMax) { int position = getPosition(user); lastChange.pozycja = position; lastChange.tryb = tryb; lastChange.znak = letter; if(lastChange.znak == 127) { int i = 1; vector<int>::iterator it = document.begin(); while( i < position) { it++; i++; } document.erase(it); changePosition(position, -1); lastChange.rozmiar = getDocumentSize(); sendChangeToAll(user); } else if(lastChange.znak == 10) { int i = 0; vector<int>::iterator it = document.begin(); cout<<position<<endl; while( i < position) { it++; i++; } int ile = i = (position % xMax); for(; i < xMax; i++) { cout<<i<<endl; if(position < getDocumentSize()) { it = document.insert(it, 10); } else document.push_back(10); changePosition(position, 1); position ++; } cout<<position<<endl; dopelnijEnter(position, xMax, ile); lastChange.rozmiar = getDocumentSize(); cout<<"wyslany rozmiar "<< lastChange.rozmiar<<endl; sendChangeToAll(user); } else if(tryb == CHANGE) { if(position < getDocumentSize()) { document.at(position) = letter; changeCursorPosition(user, 1); } else { document.push_back(letter); changePosition(position, 1); } lastChange.rozmiar = getDocumentSize(); sendChangeToAll(user); } else if(tryb == INSERT) { int i = 0; vector<int>::iterator it = document.begin(); while( i < position) { it++; i++; } if(position < getDocumentSize()) { document.insert(it, letter); changePosition(position, 1); } else { document.push_back(letter); changePosition(position, 1); } lastChange.rozmiar = getDocumentSize(); sendChangeToAll(user); } }
itkDataTensorImageVtkViewInteractor::itkDataTensorImageVtkViewInteractor(medAbstractView *parent): medAbstractImageViewInteractor(parent), d(new itkDataTensorImageVtkViewInteractorPrivate) { d->view = dynamic_cast<medAbstractImageView*>(parent); medVtkViewBackend* backend = static_cast<medVtkViewBackend*>(parent->backend()); d->view2d = backend->view2D; d->view3d = backend->view3D; d->render = backend->renWin; d->manager = vtkTensorManager::New(); d->datasetFloat = NULL; d->filterFloat = NULL; d->datasetDouble = NULL; d->filterDouble = NULL; d->minorScaling = 1; d->majorScalingExponent = 0; // set default properties d->manager->SetGlyphShapeToLine(); for (int i=0; i<6; i++) d->imageBounds[i] = 0; // be careful not to forget setting the same renderer for the interactor and the view // otherwise a new renderer is created d->manager->SetRenderWindowInteractor(d->render->GetInteractor(), d->view3d->GetRenderer()); connect(d->view->positionBeingViewedParameter(), SIGNAL(valueChanged(QVector3D)), this, SLOT(changePosition(QVector3D))); d->slicingParameter = new medIntParameter("Slicing", this); }
void useItem2(Sugoroku *s, SugorokuStatus *ss, int player_id, int target, Scene *scene) { //選択したプレイヤーと場所を交換する changePosition(s->player, player_id, target); //printw("%sさんと%sさんの位置を交換しました.\n", p[player_num].name, p[change_player].name); }
Cube::Cube(float posX, float posY, float posZ, float size):GameObject(size, true) { size /= 2; this->quadPosition.push_back(vec3(-size + 0.0f, -size + 0.0f, size + 0.0f)); this->quadPosition.push_back(vec3( size + 0.0f, -size + 0.0f, size + 0.0f)); this->quadPosition.push_back(vec3( size + 0.0f, size + 0.0f, size + 0.0f)); this->quadPosition.push_back(vec3(-size + 0.0f, size + 0.0f, size + 0.0f)); this->quadPosition.push_back(vec3(-size + 0.0f, -size + 0.0f, -size + 0.0f)); this->quadPosition.push_back(vec3( size + 0.0f, -size + 0.0f, -size + 0.0f)); this->quadPosition.push_back(vec3( size + 0.0f, size + 0.0f, -size + 0.0f)); this->quadPosition.push_back(vec3(-size + 0.0f, size + 0.0f, -size + 0.0f)); this->wireframeMode = false; this->indexes.push_back(3); this->indexes.push_back(0); this->indexes.push_back(1); this->indexes.push_back(1); this->indexes.push_back(3); this->indexes.push_back(2); this->indexes.push_back(2); this->indexes.push_back(1); this->indexes.push_back(5); this->indexes.push_back(5); this->indexes.push_back(2); this->indexes.push_back(6); this->indexes.push_back(6); this->indexes.push_back(5); this->indexes.push_back(4); this->indexes.push_back(4); this->indexes.push_back(6); this->indexes.push_back(7); this->indexes.push_back(7); this->indexes.push_back(4); this->indexes.push_back(0); this->indexes.push_back(0); this->indexes.push_back(7); this->indexes.push_back(3); this->indexes.push_back(3); this->indexes.push_back(2); this->indexes.push_back(6); this->indexes.push_back(6); this->indexes.push_back(3); this->indexes.push_back(7); this->indexes.push_back(7); this->indexes.push_back(7); this->indexes.push_back(4); this->indexes.push_back(4); this->indexes.push_back(0); this->indexes.push_back(1); this->indexes.push_back(1); this->indexes.push_back(4); this->indexes.push_back(5); this->color = vec4(0.5f, 0.5f, 0.5f, 1.0f); this->size = size; changePosition(posX, posY, posZ); this->mass = MF.getVolumeOfACube(size); }