本文整理汇总了C++中Physics::moveobject方法的典型用法代码示例。如果您正苦于以下问题:C++ Physics::moveobject方法的具体用法?C++ Physics::moveobject怎么用?C++ Physics::moveobject使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Physics
的用法示例。
在下文中一共展示了Physics::moveobject方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: update
int8_t Player::update(const Physics& physics, uint16_t dpf)
{
const PlayerState* pst = plstates.get(stance);
if (pst)
{
pst->update(*this);
physics.moveobject(phobj, dpf);
pst->nextstate(*this);
}
uint16_t lookdpf = dpf;
switch (stance)
{
case PST_WALK:
lookdpf = static_cast<short>(dpf * (1.0f + abs(phobj.hspeed) / 25));
break;
}
look.update(lookdpf);
return phobj.fhlayer;
}
示例2: update
int8_t Drop::update(const Physics& physics)
{
physics.moveobject(phobj);
if (state == DROPPED && phobj.onground)
{
phobj.hspeed = 0.0;
phobj.setflag(PhysicsObject::NOGRAVITY);
setposition(dest.x(), dest.y() - 4);
state = FLOATING;
}
if (state == FLOATING)
{
phobj.y = basey + 5.0f + (cos(moved) - 1.0f) * 2.5f;
moved = (moved < 360.0f) ? moved + 0.025f : 0.0f;
}
if (state == PICKEDUP)
{
static const uint16_t PICKUPTIME = 48;
if (looter)
{
double hdelta = looter->x - phobj.x;
phobj.hspeed = looter->hspeed / 2.0 + (hdelta - 16.0) / PICKUPTIME;
}
opacity -= 1.0f / PICKUPTIME;
if (opacity <= 1.0f / PICKUPTIME)
{
opacity = 0.0f;
MapObject::deactivate();
return -1;
}
}
return phobj.fhlayer;
}
示例3: update
int8_t MapObject::update(const Physics& physics)
{
physics.moveobject(phobj);
return phobj.fhlayer;
}
示例4: update
int8_t Mob::update(const Physics& physics)
{
if (!active)
return phobj.fhlayer;
bool aniend = animations.at(stance).update();
if (aniend && stance == DIE)
{
dead = true;
}
if (fading)
{
opacity -= 0.025f;
if (opacity.last() < 0.025f)
{
opacity.set(0.0f);
fading = false;
dead = true;
}
}
else if (fadein)
{
opacity += 0.025f;
if (opacity.last() > 0.975f)
{
opacity.set(1.0f);
fadein = false;
}
}
if (dead)
{
active = false;
return -1;
}
effects.update();
showhp.update();
if (!dying)
{
if (!canfly)
{
if (phobj.flagnotset(PhysicsObject::TURNATEDGES))
{
flip = !flip;
phobj.setflag(PhysicsObject::TURNATEDGES);
if (stance == HIT)
setstance(STAND);
}
}
switch (stance)
{
case MOVE:
if (canfly)
{
phobj.hforce = flip ? flyspeed : -flyspeed;
switch (flydirection)
{
case UPWARDS:
phobj.vforce = -flyspeed;
break;
case DOWNWARDS:
phobj.vforce = flyspeed;
break;
}
}
else
{
phobj.hforce = flip ? speed : -speed;
}
break;
case HIT:
if (canmove)
{
double KBFORCE = phobj.onground ? 0.2 : 0.1;
phobj.hforce = flip ? -KBFORCE : KBFORCE;
}
break;
case JUMP:
phobj.vforce = -5.0;
break;
}
physics.moveobject(phobj);
if (control)
{
counter++;
bool next;
switch (stance)
{
case HIT:
next = counter > 200;
break;
case JUMP:
//.........这里部分代码省略.........
示例5: update
//.........这里部分代码省略.........
if (single.delay <= Constants::TIMESTEP)
{
applysingle(single);
return true;
}
else
{
single.delay -= Constants::TIMESTEP;
return false;
}
});
bool nosingle = singlelist.size() == 0;
size_t remove = 0;
for (auto& dmg : damagenumbers)
{
if (dmg.update())
remove++;
}
for (size_t i = remove; i--;)
{
damagenumbers.erase(damagenumbers.begin());
}
bool nonumbers = damagenumbers.size() == 0;
if (dead && nobullets && nosingle && nonumbers)
{
active = false;
return -1;
}
effects.update();
showhp.update();
if (control && !dying)
{
if (!canfly)
{
if (phobj.flagnotset(PhysicsObject::TURNATEDGES))
{
flip = !flip;
phobj.setflag(PhysicsObject::TURNATEDGES);
if (stance == HIT)
setstance(STAND);
}
}
switch (stance)
{
case MOVE:
if (canfly)
{
phobj.hforce = flip ? flyspeed : -flyspeed;
switch (flydirection)
{
case UPWARDS:
phobj.vforce = -flyspeed;
break;
case DOWNWARDS:
phobj.vforce = flyspeed;
break;
}
}
else
{
phobj.hforce = flip ? speed : -speed;
if (canjump && phobj.onground && counter > 50 && counter < 150 && randomizer.below(0.005f))
{
phobj.vforce = -5.0f;
}
}
break;
case HIT:
if (canmove)
{
double KBFORCE = phobj.onground ? 0.2 : 0.1;
phobj.hforce = flip ? -KBFORCE : KBFORCE;
}
break;
}
counter++;
if (aniend && counter > 200)
{
nextmove();
sendmovement();
counter = 0;
}
physics.moveobject(phobj);
}
else
{
phobj.normalize();
physics.getfht().updatefh(phobj);
}
return phobj.fhlayer;
}