本文整理汇总了C++中Movement类的典型用法代码示例。如果您正苦于以下问题:C++ Movement类的具体用法?C++ Movement怎么用?C++ Movement使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了Movement类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: updateLadder
void JacobsLadder::updateLadder() {
if (isPaused) {
return;
}
if (queue.isEmpty()) {
return;
}
Movement movement = queue.peek();
if (!started) {
if (movement.onStart != NULL) movement.onStart(index);
started = true;
_lastUpdated = millis();
}
//Serial.println(movement.updateDelay);
if (millis() - _lastUpdated < incrementForRatio(movement.ratio) * movement.updateDelay) {
return;
}
_angle = nextAngleToDestination(movement.destinationAngle, incrementForRatio(movement.ratio));
servo.write(_angle);
// Serial.println(_angle);
if (abs(movement.destinationAngle - _angle) <= incrementForRatio(movement.ratio)) {
_angle = movement.destinationAngle;
servo.write(_angle);
if (movement.onEnd != NULL) movement.onEnd(index);
started = false;
queue.pop();
}
_lastUpdated = millis();
}
示例2: update
/**
* @brief This function is called repeatedly by the engine.
*/
void DebugKeys::update() {
#if SOLARUS_DEBUG_LEVEL >= 2
if (InputEvent::is_shift_down()) {
if (game != NULL && game->is_showing_message()) {
game->get_dialog_box().show_all_now();
}
}
// traverse walls when control is pressed
if (game != NULL) {
Movement *movement = game->get_hero().get_movement();
if (movement != NULL) {
if (InputEvent::is_control_down()) {
movement->set_ignore_obstacles(true);
}
else {
movement->restore_default_ignore_obstacles();
}
}
}
#endif
}
示例3: start_movement
/**
* \brief Applies a movement to this object.
*
* Any previous movement is stopped.
*
* \param movement The movement to apply.
*/
void Drawable::start_movement(Movement& movement) {
stop_movement();
this->movement = &movement;
movement.set_drawable(this);
movement.increment_refcount();
}
示例4: computeIncidentEdges
void LocalSearchB::run (UndirectedGraph* G, UndirectedGraph* ktree)
{
_G = G;
_ktree = ktree;
// Adaptive structures (initialization)
computeIncidentEdges();
#ifdef PURGE
cout << endl << endl << "INCIDENTS: ";
for(list<Edge*>::iterator i=_incidents->begin(); i!=_incidents->end(); i++)
{
cout << *(*i);
}
cout << endl;
#endif
computeLeaveEdges();
#ifdef PURGE
cout << endl << "LEAVES: ";
for(list<Edge*>::iterator i=_leaves->begin(); i!=_leaves->end(); i++)
{
cout << *(*i);
}
cout << endl;
#endif
// LS Procedure
Movement* move = new Movement();
int iter=1;
#ifdef PURGE
cout << endl << endl;
cout << "Iteration #" << iter << endl;
cout << "KTREE: " << *_ktree << endl;
#endif
bool toBeContinued = chooseBestNeighbor(move);
while (toBeContinued)
{
#ifdef PURGE
cout << endl << "NEXT MOVE: " << *move << endl;
#endif
move->applyTo(_ktree);
adaptNeighborhood(move);
#ifdef PURGE
cout << endl << endl;
cout << "Iteration #" << ++iter << endl;
cout << "KTREE: " << *_ktree << endl;
#endif
toBeContinued = chooseBestNeighbor(move);
}
}
示例5: TEST
TEST(Movement, onAddEntity) {
Vector2d g = { 0.0, 0.0 };
Entity* e = new Entity();
World w(g);
Moveable m;
Rectangular r(10.0, 20.0);
Shaped s(r);
Universal u(w);
e->addComponent(&m);
e->addComponent(&r);
e->addComponent(&s);
e->addComponent(&u);
Movement sys;
sys.onAddEntity(*e);
auto actualBody = m.getBody();
auto actualFixture = m.getBody();
EXPECT_NE(actualBody, nullptr);
EXPECT_NE(actualFixture, nullptr);
delete e;
}
示例6: global_messageHandler_KickMetal
void global_messageHandler_KickMetal() {
Movement *mov = g_fp->_aniMan->getMovementById(MV_MAN_HMRKICK);
int end = mov->_currMovement ? mov->_currMovement->_dynamicPhases.size() : mov->_dynamicPhases.size();
for (int i = 0; i < end; i++) {
ExCommand *ex = mov->getDynamicPhaseByIndex(i)->_exCommand;
if (ex)
if (ex->_messageKind == 35)
if (ex->_messageNum == SND_CMN_054 || ex->_messageNum == SND_CMN_055)
ex->_messageNum = SND_CMN_015;
}
mov = g_fp->_aniMan->getMovementById(MV_MAN_HMRKICK_COINLESS);
end = mov->_currMovement ? mov->_currMovement->_dynamicPhases.size() : mov->_dynamicPhases.size();
for (int i = 0; i < end; i++) {
ExCommand *ex = mov->getDynamicPhaseByIndex(i)->_exCommand;
if (ex)
if (ex->_messageKind == 35)
if (ex->_messageNum == SND_CMN_054 || ex->_messageNum == SND_CMN_055)
ex->_messageNum = SND_CMN_015;
}
}
示例7: get_frame_delay
/**
* \brief Suspends or resumes the animation.
*
* Nothing is done if the parameter specified does not change.
*
* \param suspended true to suspend the animation, false to resume it
*/
void Sprite::set_suspended(bool suspended) {
if (suspended != this->suspended && !ignore_suspend) {
this->suspended = suspended;
// compte next_frame_date if the animation is being resumed
if (!suspended) {
uint32_t now = System::now();
next_frame_date = now + get_frame_delay();
blink_next_change_date = now;
}
else {
blink_is_sprite_visible = true;
}
// Also suspend or resumed the transition effect and the movement if any.
Transition* transition = get_transition();
if (transition != NULL) {
transition->set_suspended(suspended);
}
Movement* movement = get_movement();
if (movement != NULL) {
movement->set_suspended(suspended);
}
}
}
示例8: Movement
void Explosion::draw()
{
Movement mover = Movement();
for each(shared_ptr<GameObject> part in particles)
{
part->count = life;
glPushMatrix();
if(life > MAX_EXPLOSION_LIFE/4)
{
glEnable (GL_BLEND);
glBlendFunc (GL_SRC_COLOR, GL_ONE_MINUS_SRC_ALPHA);
part->draw();
glDisable(GL_BLEND);
}
else
{
part->draw();
}
glPopMatrix();
//Update the particle.
mover.move(part);
mover.rotate(part);
mover.clip(part);
}
示例9: Activity
DynamicActivity::DynamicActivity(const uint32_t& aid, StaticActivity* fromActivity,
StaticActivity* toActivity, const ProjectParameters& par) : Activity(aid, MOVEMENT) {
vector<pair<uint32_t,uint32_t> > movements;
size_t s1 = fromActivity->locations().size();
size_t s2 = toActivity->locations().size();
for (uint32_t i = 0; i < s1; ++i)
for (uint32_t j = 0; j < s2; ++j)
movements.emplace_back(i,j);
shuffle(movements.begin(), movements.end(), generator);
vector<bool> fromCovered(s1, false), toCovered(s2, false);
for (const auto& c : movements) {
Movement *mv = new Movement(fromActivity->locations()[c.first]->point(), toActivity->locations()[c.second]->point(), par);
mMinAbsDuration = min(mMinAbsDuration, mv->minDuration());
mMaxAbsDuration = max(mMaxAbsDuration, mv->maxDuration());
mMovements.push_back(mv);
fromCovered[c.first] = true;
toCovered[c.second] = true;
if (count(fromCovered.cbegin(), fromCovered.cend(), false) + count(toCovered.cbegin(), toCovered.cend(), false) == 0)
break;
}
fromActivity->addSuccessor(this);
toActivity->addPredecessor(this);
addSuccessor(toActivity);
addPredecessor(fromActivity);
}
示例10: handleMovement
void MainWindow::handleMovement(Movement mvmnt, size_t index)
{
QString text(QString::number(index) + " "
+ QString::number(mvmnt.direction().x) + " "
+ QString::number(mvmnt.direction().y) + " "
+ QString::number(mvmnt.direction().z) + " "
+ mvmnt.size());
ui->movements->setText(text);
}
示例11: confOut
void TrainingsController::store() {
//movements
std::ofstream confOut(rootPath + CONF_FILE);
for (auto it = movements.begin(); it != movements.end(); ++it) {
Movement *mov = it->second;
confOut << mov->getName() << std::endl;
std::ofstream out(rootPath + mov->getName() + ".txt");
out << "name = " << mov->getName() << std::endl;
out << "desc = " << mov->getDescription() << std::endl;
out << "trans_x = " << mov->getTranslationX() << std::endl;
out << "trans_y = " << mov->getTranslationY() << std::endl;
out << "rotation = " << mov->getRotation() << std::endl;
out << "compression = " << mov->getCompression() << std::endl;
out.close();
}
confOut.close();
//trainings
confOut.open(rootPath + TRAININGS_FILE);
for (auto it = trainings.begin(); it != trainings.end(); ++it) {
TrainingsProcedure *train = *it;
confOut << train->getName() << std::endl;
std::ofstream out(rootPath + train->getName() + ".txt");
for (auto it2 = train->getMovements()->begin(); it2 != train->getMovements()->end(); ++it2)
out << (*it2)->getName() << std::endl;
out.close();
}
}
示例12: create_movement_handle
/**
* @brief Makes a movement accessible from the script.
*
* If the movement is already accessible from this script,
* this function returns the already known handle.
*
* @param movement the movement to make accessible
* @return a handle that can be used by scripts to refer to this movement
*/
int Script::create_movement_handle(Movement &movement) {
int handle = movement.get_unique_id();
if (movements.find(handle) == movements.end()) {
movements[handle] = &movement;
unassigned_movements[handle] = &movement;
movement.set_suspended(true); // suspended until it is assigned to an object
}
return handle;
}
示例13:
bool AIBotAction_MOVE::ExecuteAction( void )
{
if( mOwnerBot )
{
Movement* mover = mOwnerBot->Owner()->GetMovement() ;
CPicker* picker = CGraphics::GetSingleton().picker;
if( mover && picker->GetPickedObject() )
{
mover->SetGoalNode((PathingNode*)picker->GetPickedObject());
mover->InitializeAStarState();
//mover->InitializeAStarState();
}
}
return true;
}
示例14: start_movement
/**
* \brief Applies a movement to this object.
*
* Any previous movement is stopped.
*
* \param movement The movement to apply.
*/
void Drawable::start_movement(Movement& movement) {
stop_movement();
this->movement = &movement;
movement.set_drawable(this);
RefCountable::ref(&movement);
}
示例15: calcDuration
int MessageQueue::calcDuration(StaticANIObject *obj) {
int res = 0;
ExCommand *ex;
Movement *mov;
for (uint i = 0; (ex = getExCommandByIndex(i)); i++)
if (ex->_parentId == obj->_id) {
if (ex->_messageKind == 1 || ex->_messageKind == 20) {
if ((mov = obj->getMovementById(ex->_messageNum)) != 0) {
if (ex->_field_14 >= 1)
res += ex->_field_14;
else
res += mov->calcDuration();
}
}
}
return res;
}