本文整理汇总了C++中Platform::getType方法的典型用法代码示例。如果您正苦于以下问题:C++ Platform::getType方法的具体用法?C++ Platform::getType怎么用?C++ Platform::getType使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Platform
的用法示例。
在下文中一共展示了Platform::getType方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: move
void Player::move(const std::vector<Solid*>& solids)
{
gapToReference = coord.x - (REF_X*800 + (scene->getCam().x-400));
float rad = motion_angle*PI_ENGINE/180;
float dx = 0;
float dy = 0;
// déplacement normal
if(motion_angle >= -MAX_MOVE_ANGLE)
{
if(motion_angle <= MAX_MOVE_ANGLE)
{
dx = SPEED * (1-sin(rad)*std::abs(sin(rad))) * (1-tanh(gapToReference/50)/1.5);
dy = GRAVITY * timer - 20;
}
if(motion_angle <= 90)
{
if(!jumping && jumpCommand)
{
if(timer > 20)
double_jumping = true;
jumping = true;
timer = 1;
}
}
}
// chute libre
else if(motion_angle < MAX_MOVE_ANGLE && motion_angle >= MAX_MOVE_ANGLE-180)
{
dx = SPEED * cos(rad);
dy = GRAVITY * timer;
}
// mode saut
if(jumping)
{
dx = SPEED * (1-sin(rad)*std::abs(sin(rad))) * (1-tanh(gapToReference/50)/5);
dy = GRAVITY * timer - 26;
if(dy >= -DBLE_JUMP_SENSIBILITY && dy <= DBLE_JUMP_SENSIBILITY && !double_jumping && timer >= 1.20)
{
if(jumpCommand)
{
double_jumping = true;
timer = 1;
}
}
if(motion_angle == 90 && double_jumping) dx = SPEED;
}
float x1 = coord.x;
float y1 = coord.y;
float x2 = x1 + dx;
float y2 = y1 + dy;
float d = sqrt((x2-x1)*(x2-x1) + (y2-y1)*(y2-y1));
int sub_pts = (int)round(d) - 1;
std::vector<sf::Vector2f> sub_positions;
sub_positions.push_back(sf::Vector2f(0, 0));
for(int p = 1; p <= sub_pts; p++)
sub_positions.push_back(sf::Vector2f(p*(x2-x1)/(sub_pts+1), p*(y2-y1)/(sub_pts+1)));
sub_positions.push_back(sf::Vector2f(x2-x1, y2-y1));
bool collisionDetected = false;
for(int cur_pos = 1; cur_pos < sub_positions.size() && !collisionDetected; cur_pos++)
{
for(int i = 0; i < solids.size() && !collisionDetected; i++)
{
for(int j = 0; j < hitBox.getSegments().size() && !collisionDetected; j++)
{
Segment new_segm(
hitBox.getSegments()[j].getP1() + sub_positions[cur_pos],
hitBox.getSegments()[j].getP2() + sub_positions[cur_pos]
);
if((solids[i]->getHitBox()).intersectsWith(new_segm))
{
if(solids[i]->getEType() == Entity::PLATFORM){
Platform* plat = (Platform*)(solids[i]);
if(plat->getType()==Platform::DEADLY)
dead=true;
}
collisionDetected = true;
jumping = false;
double_jumping = false;
timer = 1;
move(sub_positions[cur_pos-1]);
int angle = -90;
float angle_rad;
int pas = 1;
bool possible = false;
sf::Vector2f vect;
//.........这里部分代码省略.........