void Decoration::setEndPosition(const VC3 &position) { this->endPosition.x = position.x; this->endPosition.z = position.z; // height ignored updateVisual(); }
void Visual3DText::init() { VisualModel::init(); reinit(); updateVisual(); }
//------------------------------------------------------------------- void Vob::setShowVisual(bool _showVisual) { if(!mShowVisualFrozen) { mShowVisual = _showVisual; updateVisual(); } }
void Enemy::update(float dt, const Physics &phys) { vel += phys.gravity * dt; if (facingLeft) vel.setX(-speed, phys.gravAngle%180); else vel.setX( speed, phys.gravAngle%180); hitWall = false; if (phys.gravAngle%180 == 0) canGoX(dt, phys); canGoY(dt, phys); if (phys.gravAngle%180 != 0) canGoX(dt, phys); if (hitWall) { vel.setX(-1*vel.getX(phys.gravAngle), phys.gravAngle); facingLeft = !facingLeft; } visual.FlipX(facingLeft ^ (phys.gravAngle>=180)); rotate(phys.gravAngle); updateVisual(); }
void Player::update(float dt, const Physics &phys) { if (!freeFly) { inAir = true; vel += phys.gravity * dt; vel.setX(0, phys.gravAngle); vel.add((playerControl*dt).x, (playerControl).y, phys.gravAngle); if (inAir && vel.getY(phys.gravAngle)<0 && cancleJump) vel.setY(0, phys.gravAngle); // cancle the jump if possible cancleJump = true; } // calculate position canGoX(dt, phys); canGoY(dt, phys); visual.FlipX(facingLeft); updateVisual(); }
void Decoration::loadModel(const char *filename) { if (visualObject != NULL) { delete visualObject; visualObject = NULL; } if (visualObjectModel != NULL) { delete visualObjectModel; visualObjectModel = NULL; } visualObjectModel = new VisualObjectModel(filename); visualObject = visualObjectModel->getNewObjectInstance(); visualObject->setCollidable(false); visualObject->setInScene(true); visualObject->setVisible(true); //visualObject->setEffect(VISUALOBJECTMODEL_EFFECT_ADDITIVE); //visualObject->setEffect(VISUALOBJECTMODEL_EFFECT_MULTIPLY); updateVisual(); // parse water boundaries: parseBoundingQuadSize(filename); }
ReturnFlag NFishSwarm::evolve(){ ReturnFlag rf=Return_Normal; //new prey behavior for(auto &fish:m_pop){ for(int i=0;i<m_tryNumber;++i){ rf=fish->prey(m_visual); if(rf!=Return_Normal) return rf; updateBestArchive(fish->self()); } } //new follow behavior for(auto &fish:m_pop){ rf=fish->follow(*m_best[0],m_visual); if(rf!=Return_Normal) return rf; updateBestArchive(fish->self()); } //new swarm behevior computeCenter(); findBest(); for(auto &fish:m_pop){ if(m_center>fish->self()){ if(fish->m_index!=m_bestIdx[0]){ rf=fish->swarm(m_center,m_visual); if(rf!=Return_Normal) return rf; }else{ fish->self()=m_center; } updateBestArchive(fish->self()); } } updateVisual(); updateCurRadius(); m_iter++; return rf; }
//------------------------------------------------------------------- void Vob::setVisual(const String& _visual) { mVisual = _visual; updateVisual(); }
void Decoration::setEndHeight(float height) { this->endPosition.y = height; updateVisual(); }
void Decoration::setSpeed(float speed) { this->animationSpeed = speed; updateVisual(); // Is this necessary? }
void Decoration::setHeight(float height) { this->position.y = height; updateVisual(); }
void Decoration::setStartRotation(const VC3 &rotation) { this->startRotation = rotation; this->rotation = rotation; updateVisual(); }
// Modifications by Ilkka: All increments are multiplied by animationSpeed to allow speed adjustment void Decoration::run() { tickCount++; bool needUpdate = false; for (int i = 0; i < DECORATION_MAX_EFFECTS; i++) { if (effectOn[i]) { switch(i) { case Decoration::DECORATION_EFFECT_WAVE_X: // NOTICE: inaccuracy grows by time!!! position.x += (float)sinf(effectValue[i]) / GAME_TICKS_PER_SECOND * 0.5f; effectValue[i] += animationSpeed*0.001f; if (effectValue[i] >= 2*3.1415927f) effectValue[i] -= 2*3.1415927f; break; case Decoration::DECORATION_EFFECT_WAVE_Y: // NOTICE: inaccuracy grows by time!!! position.y += (float)sinf(effectValue[i]) / GAME_TICKS_PER_SECOND * 0.5f; effectValue[i] += animationSpeed*0.0012f; if (effectValue[i] >= 2*3.1415927f) effectValue[i] -= 2*3.1415927f; break; case Decoration::DECORATION_EFFECT_WAVE_Z: // NOTICE: inaccuracy grows by time!!! position.z += (float)sinf(effectValue[i]) / GAME_TICKS_PER_SECOND * 0.5f; effectValue[i] += animationSpeed*0.0013f; if (effectValue[i] >= 2*3.1415927f) effectValue[i] -= 2*3.1415927f; break; case Decoration::DECORATION_EFFECT_ROTATE_X: // NOTICE: inaccuracy grows by time!!! rotation.x += animationSpeed*360.0f / GAME_TICKS_PER_SECOND; if (rotation.x >= 360) rotation.x -= 360; break; case Decoration::DECORATION_EFFECT_ROTATE_Y: // NOTICE: inaccuracy grows by time!!! rotation.y += animationSpeed*360.0f / GAME_TICKS_PER_SECOND; if (rotation.y >= 360) rotation.y -= 360; break; case Decoration::DECORATION_EFFECT_ROTATE_Z: // NOTICE: inaccuracy grows by time!!! rotation.z += animationSpeed*360.0f / GAME_TICKS_PER_SECOND; if (rotation.z >= 360) rotation.z -= 360; break; case Decoration::DECORATION_EFFECT_GEAR1_Y: // NOTICE: inaccuracy grows by time!!! if ((tickCount % 500) < 100) { rotation.y += animationSpeed*36.0f / GAME_TICKS_PER_SECOND; if (rotation.y >= 360) rotation.y -= 360; } break; case Decoration::DECORATION_EFFECT_GEAR2_Y: // NOTICE: inaccuracy grows by time!!! if ((tickCount % 500) > 100 && (tickCount % 500) < 300) { rotation.y -= animationSpeed*36.0f / GAME_TICKS_PER_SECOND; if (rotation.y < 0) rotation.y += 360; } break; case Decoration::DECORATION_EFFECT_GEAR3_Y: // NOTICE: inaccuracy grows by time!!! if ((tickCount % 500) > 250) { rotation.y += animationSpeed*16.0f / GAME_TICKS_PER_SECOND; if (rotation.y >= 360) rotation.y -= 360; } break; default: break; // TODO... (nop ?) } needUpdate = true; } } if (needUpdate) updateVisual(); }