void Character::tick(GameEngine* ge){ //Unlike the standard Sprite, character animations tend to switch only when they are actually moving. bool haveMoved = false; if(getMovementX() != 0){ Rectangle rect; rect.setXY(getPositionX() + getMovementX(), getPositionY()); rect.setWidthHeight(getWidth(), getHeight()); if(!willBeOutOfWorldX(ge->getActiveWorld()) && ge->getActiveWorld()->isPositionWalkable(rect) ){ setPositions( getPositionX() + getMovementX(), getPositionY()); haveMoved = true; } setMovementX(0); } if(getMovementY() != 0 ){ Rectangle rect2; rect2.setXY(getPositionX(), getPositionY()+getMovementY()); rect2.setWidthHeight(getWidth(), getHeight()); if(!willBeOutOfWorldY(ge->getActiveWorld()) && ge->getActiveWorld()->isPositionWalkable(rect2 )){ setPositions(getPositionX(), getPositionY() + getMovementY()); haveMoved = true; } setMovementY(0); } if(haveMoved) incrementAnimationSwitchCounter(1); draw(); }
void Button::render(bool resetPos) { //std::cout << "INFO: Button::render: Rendering the Button" << std::endl; float posx = getPosX(); float posy = getPosY(); float height = getHeight(); float width = getWidth(); if ( resetPos ) setPositions(); posx = getPosX(); posy = getPosY(); height = getHeight(); width = getWidth(); renderTexture( mTexture, mRenderer, posx, posy, width, height ); //render the title message if (mTitle != nullptr) { float title_scale = 0.7; mTitle->setActive(true); mTitle->setHeight(height * title_scale); mTitle->setWidth(width * title_scale); float tborder = (1.-0.8)/2.; mTitle->setPosX( posx + tborder * width); mTitle->setPosY( posy + tborder * height); mTitle->render(); } }
void WDisplay::setup(QDomNode node, const SkinContext& context) { // Set background pixmap if available if (context.hasNode(node, "BackPath")) { setPixmapBackground(context.getSkinPath( context.selectString(node, "BackPath"))); } // Number of states setPositions(context.selectInt(node, "NumberStates")); // Load knob pixmaps QString path = context.selectString(node, "Path"); for (int i = 0; i < m_pixmaps.size(); ++i) { setPixmap(&m_pixmaps, i, context.getSkinPath(path.arg(i))); } // See if disabled images is defined, and load them... if (context.hasNode(node, "DisabledPath")) { QString disabledPath = context.selectString(node, "DisabledPath"); for (int i = 0; i < m_disabledPixmaps.size(); ++i) { setPixmap(&m_disabledPixmaps, i, context.getSkinPath(disabledPath.arg(i))); } m_bDisabledLoaded = true; } }
void freeKick5::execute() { QList<int> activeAgents=wm->kn->ActiveAgents(); // if(!rolesIsInit) initRole(); for(int i=0;i<activeAgents.size();i++) setTactics(activeAgents.at(i)); setPositions(); int recieverID = tDefenderLeft->getID(); target = Vector2D(wm->ball.pos.loc.x-2000,-wm->ball.pos.loc.y); tAttackerMid->isKicker(target); tAttackerMid->setFreeKickType(kickType::FreeKick5); if(state > 1) { activeAgents.removeOne(tAttackerMid->getID()); if(wm->cmgs.ourIndirectKick()) { wm->ourRobot[recieverID].Status = AgentStatus::RecievingPass; activeAgents.removeOne(recieverID); } tAttackerMid->youHavePermissionForKick(-1); } while(activeAgents.size() > 0) { wm->ourRobot[activeAgents.takeFirst()].Status = AgentStatus::Idle; } }
void freeKick47::execute() { QList<int> activeAgents=wm->kn->ActiveAgents(); // if(!rolesIsInit) initRole(); if( state > 3) initRolesB(AttackerRight,DefenderLeft); for(int i=0;i<activeAgents.size();i++) setTactics(activeAgents.at(i)); tAttackerMid->isKicker(Vector2D(0.3*Field::MaxX, -sign(wm->ball.pos.loc.y)*(0.6)*Field::MaxY)); tAttackerMid->setFreeKickType(kickType::FreeKick47); setPositions(activeAgents); if(state > 3) activeAgents.removeOne(tAttackerMid->getID()); while(activeAgents.size() > 0) { wm->ourRobot[activeAgents.takeFirst()].Status = AgentStatus::Idle; } }
WDisplay::WDisplay(QWidget * parent) : WWidget(parent), m_iCurrentPixmap(0), m_pPixmapBack(nullptr), m_bDisabledLoaded(false) { setPositions(0); }
void freeKick10::execute() { QList<int> activeAgents=wm->kn->ActiveAgents(); // if(!rolesIsInit) initRole(); for(int i=0;i<activeAgents.size();i++) setTactics(activeAgents.at(i)); tAttackerMid->isKicker(Vector2D(Field::MaxX*0.7,-sign(wm->ball.pos.loc.y)*0.7*Field::MaxY)); tAttackerMid->setFreeKickType(kickType::FreeKick10); setPositions(activeAgents); if(state > 3) activeAgents.removeOne(tAttackerMid->getID()); if( state == 2) counter++; // wm->ourRobot[tAttackerLeft->getID()].Status = AgentStatus::RecievingPass; // activeAgents.removeOne(tAttackerLeft->getID()); // wm->ourRobot[tAttackerRight->getID()].Status = AgentStatus::RecievingPass; // activeAgents.removeOne(tAttackerRight->getID()); while(activeAgents.size() > 0) { wm->ourRobot[activeAgents.takeFirst()].Status = AgentStatus::Idle; } }
bool Button::collide(float x_screen, float y_screen) { //need to figure out the screen pos of the button corner and its width and heigh in pixels /* float posx = parent->getPosX(); float posy = parent->getPosY(); float width = parent->getWidth() * this->getRelWidth(); float height = parent->getHeight() * this->getRelHeight(); float rposx = posx + getRelX(); float rposy = posy + getRelY();*/ setPositions(); float rposx = getPosX(); float rposy = getPosY(); float width = getWidth(); float height = getHeight(); if ( (x_screen < rposx + width) && (rposx <= x_screen ) && (y_screen < rposy + height) && (rposy <= y_screen ) ) { setPressed(true); return true; } else { setPressed(false); return false; } }
Skin::Skin (const QString &url) { setSizes (); setPositions (); m_valid = setSkin (url); }
void EmoAttractor::changeWorld( ci::Vec3f _wCenter, float _wRadius ) { mWorldCenter = _wCenter; mWorldRadius = _wRadius; calcStartPositions(); movePositions(); setPositions(); }
void EmoAttractor::update( float _level, float _min, float _max ) { if(!mExists) return; mLevel = niko::mapping( _level, _min, _max, 0.0f, PI*0.5f); movePositions(); setPositions(); }
/*! Clears all data in the QGlyphRun object. */ void QGlyphRun::clear() { detach(); d->rawFont = QRawFont(); d->flags = 0; setPositions(QVector<QPointF>()); setGlyphIndexes(QVector<quint32>()); }
void TickerTape::startAction(int ndx) { m_actions.push_back(TextAction(m_transitionInterval, m_actionCounter++, this, ndx)); TextAction &action = m_actions.back(); action.m_transFuncPos = m_transFunc; action.m_transFuncAlpha = m_transFunc; action.m_phaseNumber = 0; setPositions(action); action.m_startAlpha = 0.f; action.m_destAlpha = 1.f; setTextFade(0.f, ndx); }
/*! Clears all data in the QGlyphRun object. */ void QGlyphRun::clear() { detach(); d->rawFont = QRawFont(); d->strikeOut = false; d->overline = false; d->underline = false; setPositions(QVector<QPointF>()); setGlyphIndexes(QVector<quint32>()); }
void menuManager::loadContent(std::string menuID) { close = newGame = credits = false; null.loadFromFile("Sprites/null.png"); itemNumber = 0; file.loadContent("Load/menus.txt", attributes, contents, menuID); for(int i = 0; i < attributes.size(); i++) { for(int j = 0; j < attributes[i].size(); j++) { std::string att = attributes[i][j]; std::string con = contents[i][j]; if(att == "Item") menuItems.push_back(con); else if (att == "Image") { image.loadFromFile(con); menuImages.push_back(image); } else if(att == "Position") { std::string pos[2]; pos[0] = con.substr(0, con.find(',')); pos[1] = con.substr(con.find(',') + 1); position.x = atof(pos[0].c_str()); position.y = atof(pos[1].c_str()); } else if(att == "Align") align = con; else if(att == "Axis") axis = atoi(con.c_str()); else if (att == "Animation") animationTypes.push_back(con); else if (att == "Font") font = con; } } equaliseMenuItems(); setAnimations(); setPositions(); }
// set video range void VideoFFmpeg::setRange (double start, double stop) { try { // set range if (m_isFile) { VideoBase::setRange(start, stop); // set range for video setPositions(); } } CATCH_EXCP; }
void PlayKickoffOur::execute() { QList<int> activeAgents=wm->kn->ActiveAgents(); initRole(); for(int i=0;i<activeAgents.size();i++) setTactics(activeAgents.at(i)); setPositions(); if( wm->cmgs.canKickBall() ) wm->ourRobot[tAttackerMid->getID()].Status = AgentStatus::Kicking; }
// play video bool VideoFFmpeg::play (void) { try { // if object is able to play if (VideoBase::play()) { // set video position setPositions(); // return success return true; } } CATCH_EXCP; return false; }
void freeKick7::execute() { QList<int> activeAgents=wm->kn->ActiveAgents(); // if(!rolesIsInit) initRole(); if( state == 2) initRolesB(AttackerLeft,DefenderLeft); for(int i=0;i<activeAgents.size();i++) setTactics(activeAgents.at(i)); setPositions(activeAgents); int recieverID; tAttackerMid->isKicker(Vector2D(0.3*Field::MaxX, -sign(wm->ball.pos.loc.y)*(0.6)*Field::MaxY)); tAttackerMid->setFreeKickType(kickType::FreeKick7); if(state > 1) { recieverID = tAttackerLeft->getID(); activeAgents.removeOne(tAttackerMid->getID()); if(wm->cmgs.ourIndirectKick()) { wm->ourRobot[recieverID].Status = AgentStatus::RecievingPass; activeAgents.removeOne(recieverID); } } else { if( state == 1) activeAgents.removeOne(tAttackerMid->getID()); recieverID = tDefenderLeft->getID(); wm->ourRobot[recieverID].Status = AgentStatus::RecievingPass; activeAgents.removeOne(recieverID); } while(activeAgents.size() > 0) { wm->ourRobot[activeAgents.takeFirst()].Status = AgentStatus::Idle; } }
void Pager::reload(){ items.clear(); lister.allowExt("xml"); lister.listDir(dir); string folder = dir + "/"; int counterStart; if(lister.size() > 15){ counterStart = lister.size() - 15; } else { counterStart = 0; } for(int i = counterStart; i < lister.size(); i++){ items[i] = new PagerItem(lister.getPath(i)); items[i]->setReloader(); } setPositions(); }
void PlayPenaltyOpp::execute() { QList<int> activeAgents=wm->kn->ActiveAgents(); initRole(); for(int i=0;i<activeAgents.size();i++) { wm->ourRobot[activeAgents.at(i)].Status = AgentStatus::Idle; } while( !activeAgents.isEmpty() ) { int index = activeAgents.takeFirst(); setTactics(index); } setPositions(); }
void PlayStop::execute() { wm->passPoints.clear(); wm->debug_pos.clear(); QList<int> activeAgents=wm->kn->ActiveAgents(); for(int i=0;i<activeAgents.size();i++) { wm->ourRobot[activeAgents.at(i)].Status = AgentStatus::Idle; } initRole(); while (activeAgents.size() >0) { setTactics(activeAgents.takeFirst()); } setPositions(); }
// play video bool VideoFFmpeg::play (void) { try { // if object is able to play if (VideoBase::play()) { // set video position setPositions(); if (m_isStreaming) { av_read_play(m_formatCtx); } // return success return true; } } CATCH_EXCP; return false; }
void WDisplay::setup(const QDomNode& node, const SkinContext& context) { // Set background pixmap if available QDomElement backPathNode = context.selectElement(node, "BackPath"); if (!backPathNode.isNull()) { setPixmapBackground(context.getPixmapSource(backPathNode), context.selectScaleMode(backPathNode, Paintable::TILE)); } // Number of states setPositions(context.selectInt(node, "NumberStates")); // Load knob pixmaps QDomElement pathNode = context.selectElement(node, "Path"); QString path = context.nodeToString(pathNode); // The implicit default in <1.12.0 was FIXED so we keep it for // backwards compatibility. Paintable::DrawMode pathMode = context.selectScaleMode(pathNode, Paintable::FIXED); for (int i = 0; i < m_pixmaps.size(); ++i) { setPixmap(&m_pixmaps, i, context.getSkinPath(path.arg(i)), pathMode); } // See if disabled images is defined, and load them... QDomElement disabledNode = context.selectElement(node, "DisabledPath"); if (!disabledNode.isNull()) { QString disabledPath = context.nodeToString(disabledNode); // The implicit default in <1.12.0 was FIXED so we keep it for // backwards compatibility. Paintable::DrawMode disabledMode = context.selectScaleMode(disabledNode, Paintable::FIXED); for (int i = 0; i < m_disabledPixmaps.size(); ++i) { setPixmap(&m_disabledPixmaps, i, context.getSkinPath(disabledPath.arg(i)), disabledMode); } m_bDisabledLoaded = true; } }
void freeKickDirect::execute() { QList<int> activeAgents=wm->kn->ActiveAgents(); // if(!rolesIsInit) initRole(); for(int i=0; i<activeAgents.size(); i++) setTactics(activeAgents.at(i)); setPositions(); target = Field::oppGoalCenter; tAttackerMid->isKicker(target); tAttackerMid->setFreeKickType(kickType::Shoot); tAttackerMid->youHavePermissionForKick(-1); activeAgents.removeOne(tAttackerMid->getID()); while(activeAgents.size() > 0) { wm->ourRobot[activeAgents.takeFirst()].Status = AgentStatus::Idle; } }
Pager::Pager(map<string, string> &_attrs) : GuiNode(){ attrs = _attrs; pageDims.x = ofToInt(attrs["columns"]); pageDims.y = ofToInt(attrs["rows"]); numItemsPerPage = pageDims.x * pageDims.y; itemDims.x = 245; itemDims.y = 138; currentPage = 0; initialize(); exit = new GuiButton("cuts/exit_big.png"); exit->setPosition(ofVec2f(pos.x + 1320,pos.y - 200)); exit->setAttr("action", "close"); exit->setAttr("sfx","button11"); dir = _attrs["directory"]; if(dir == "audio/user"){ bReloader = true; } else { bReloader = false; } populate(dir); setPositions(); SubObMediator::Instance()->addObserver("audio-recording-complete", this); SubObMediator::Instance()->addObserver("button", this); }
void BadAgent::getReadyToFight(int type, int dif, int speed){ switch (type) { case BA_TYPE_BACTERIA: img = IMG_BACTERIA; hitPoints = 100 + 50 * dif; setDefs(50, 10); setSizes(25, 25, 1); dmgToDo = 2 + 1 * dif; dnaToGive = 25 + 5 * dif; pointsToGice = 50; break; case BA_TYPE_VIRUS: img = IMG_VIRUS; hitPoints = 75 + 30 * dif; setDefs(10, 70); setSizes(25, 25, 1); dmgToDo = 1 + 2 * dif; dnaToGive = 15 + 10 * dif; pointsToGice = 60; break; case BA_TYPE_BOSS_BACTERIA: img = IMG_BACTERIA; hitPoints = 1000 + 200 * dif; setDefs(90, 25); setSizes(50, 50, 1); dmgToDo = 20 + 5 * dif; dnaToGive = 400 + 20 * dif; pointsToGice = 150; break; case BA_TYPE_BOSS_VIRUS: img = IMG_VIRUS; hitPoints = 1000 + 100 * dif; setDefs(10, 100); setSizes(50, 50, 1); dmgToDo = 20 + 3 *dif; dnaToGive = 300 + 25 * dif; pointsToGice = 180; break; default: std::cout << "Error not valid type: " << type << " deleting...\n"; destroying = true; readyToDestroy = true; break; } switch (speed) { case BA_MOV_SLOW: setMaxSpeed(80 + 10 * dif); break; case BA_MOV_NORMAL: setMaxSpeed(120 + 15 * dif); break; case BA_MOV_FAST: setMaxSpeed(160 + 20 * dif); break; default: setMaxSpeed(800); std::cout << "ERROR" << std::endl; break; } maxHitPoints = hitPoints; setPositions(-2000, -2000, 1); }
void SkeletonBlendedGeometry::changed(ConstFieldMaskArg whichField, UInt32 origin, BitVector details) { Inherited::changed(whichField, origin, details); if((whichField & BaseGeometryFieldMask) && getBaseGeometry() != NULL) { if(getBaseGeometry()->getTypes() != NULL) { setTypes(getBaseGeometry()->getTypes()); } if(getBaseGeometry()->getLengths() != NULL) { setLengths(getBaseGeometry()->getLengths()); } if(getBaseGeometry()->getPositions() != NULL) { GeoPropertyUnrecPtr Pos(getBaseGeometry()->getPositions()->clone()); setPositions(dynamic_pointer_cast<GeoVectorProperty>(Pos)); } if(getBaseGeometry()->getNormals() != NULL) { GeoPropertyUnrecPtr Norm(getBaseGeometry()->getNormals()->clone()); setNormals(dynamic_pointer_cast<GeoVectorProperty>(Norm)); } if(getBaseGeometry()->getColors() != NULL) { setColors(getBaseGeometry()->getColors()); } if(getBaseGeometry()->getSecondaryColors() != NULL) { setSecondaryColors(getBaseGeometry()->getSecondaryColors()); } if(getBaseGeometry()->getTexCoords() != NULL) { setTexCoords(getBaseGeometry()->getTexCoords()); } if(getBaseGeometry()->getTexCoords1() != NULL) { setTexCoords1(getBaseGeometry()->getTexCoords1()); } if(getBaseGeometry()->getTexCoords2() != NULL) { setTexCoords2(getBaseGeometry()->getTexCoords2()); } if(getBaseGeometry()->getTexCoords3() != NULL) { setTexCoords3(getBaseGeometry()->getTexCoords3()); } if(getBaseGeometry()->getTexCoords4() != NULL) { setTexCoords4(getBaseGeometry()->getTexCoords4()); } if(getBaseGeometry()->getTexCoords5() != NULL) { setTexCoords5(getBaseGeometry()->getTexCoords5()); } if(getBaseGeometry()->getTexCoords6() != NULL) { setTexCoords6(getBaseGeometry()->getTexCoords6()); } if(getBaseGeometry()->getTexCoords7() != NULL) { setTexCoords7(getBaseGeometry()->getTexCoords7()); } if(getBaseGeometry()->getIndices() != NULL) { setIndices(getBaseGeometry()->getIndices()); } setMaterial(getBaseGeometry()->getMaterial()); } if( (whichField & InternalJointsFieldMask) || (whichField & InternalWeightIndexesFieldMask) || (whichField & InternalWeightsFieldMask)) { calculatePositions(); } }
void SkeletonBlendedGeometry::calculatePositions(void) { if(getBaseGeometry() == NULL) { //Error SWARNING << "SkeletonBlendedGeometry::calculatePositions(): Base Geometry is NULL." << std::endl; return; } if(getPositions() == NULL) { //Error SWARNING << "SkeletonBlendedGeometry::calculatePositions(): Positions is NULL." << std::endl; return; } if(getBaseGeometry()->getPositions() == NULL) { //Error SWARNING << "SkeletonBlendedGeometry::calculatePositions(): Base Geometry Postions is NULL." << std::endl; return; } Pnt3f CalculatedPoint; Pnt3f BasePointInfluenced; Pnt3f BasePoint; Vec3f CalculatedNormal; //Reset all points GeoVectorPropertyUnrecPtr ResetPositions(dynamic_pointer_cast<GeoVectorProperty>(getBaseGeometry()->getPositions()->clone())); setPositions(ResetPositions); UInt32 WeightIndex, JointIndex, VertexIndex; //Update the Positions and Normals for(UInt32 i(0) ; i < getWeights()->size() ; ++i) { VertexIndex = getWeightIndexes()->getValue<UInt32>( 3 * i ); JointIndex = getWeightIndexes()->getValue<UInt32>((3 * i) + 1); WeightIndex = getWeightIndexes()->getValue<UInt32>((3 * i) + 2); //Get the position of this index from the base geometry getBaseGeometry()->getPositions()->getValue<Pnt3f>(BasePoint, VertexIndex); //Get the Influence matrix of this joint //Apply the influence of this joint to the position getBindTransformationDiff(JointIndex).mult(BasePoint, BasePointInfluenced); //Add the displacement to the value at this position getPositions()->getValue<Pnt3f>(CalculatedPoint, VertexIndex); //Scale the influence by the blend amount CalculatedPoint += getWeights()->getValue<Pnt1f>(WeightIndex)[0] * (BasePointInfluenced - BasePoint); getPositions()->setValue<Pnt3f>(CalculatedPoint, VertexIndex); } for(UInt32 i = 0; i < _mfParents.size(); i++) { _mfParents[i]->invalidateVolume(); } _volumeCache.setValid(); _volumeCache.setEmpty(); }
void TickerTape::setSize(const Vec2i &sz) { StaticText::setSize(sz); foreach (Actions, a, m_actions) { setPositions(*a); }