本文整理汇总了C++中BoxCollider::hitLeft方法的典型用法代码示例。如果您正苦于以下问题:C++ BoxCollider::hitLeft方法的具体用法?C++ BoxCollider::hitLeft怎么用?C++ BoxCollider::hitLeft使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类BoxCollider
的用法示例。
在下文中一共展示了BoxCollider::hitLeft方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: update
void GameScreen::update(float mouseX, float mouseY){
updateMouse(mouseX, mouseY);
for (int i = 0; i < NBR_TEAMS; i++){
m_teams[i]->update();
}
//Causes an explosion at where the curShor hits
if (m_curUnit->getWeapon()->getCurShot()){
if (m_quadTree->processCollisions(m_curUnit->getWeapon()->getCurShot()->getModel())){
if (m_explo){
float exploForce = 0.0f;
exploForce = m_curUnit->getWeapon()->getPower() * 0.5f;
if (exploForce < 0.2f){
exploForce = 0.2f;
}
m_explo->circularExplosion(Vector(m_curUnit->getWeapon()->getCurShot()->getModel()->getPos().x, m_curUnit->getWeapon()->getCurShot()->getModel()->getPos().y, 1), exploForce, m_curUnit->getWeapon()->getDamage() * m_curUnit->getWeapon()->getPower(), *m_quadTree);
m_curUnit->getWeapon()->hitObject(NULL, 0, 0);
m_hitTerrain = true;
m_endTurnTimer->resetTimer();
}
}
}
for (int i = 0; i < NBR_TEAMS; i++){
for (int j = 0; j < NBR_UNITS; j++){
Unit* tempUnit = m_teams[i]->getUnit(j);
//Smooths out physics
tempUnit->getModel()->setPos(tempUnit->getPhysics()->nextPos());
//Checks to see if collision occurs between current position and next
BoxCollider* tempCol = (BoxCollider*)m_quadTree->processCollisions(tempUnit->getModel(), tempUnit->getPhysics()->nextPos());
if (tempCol){
//When going left, collide with right of terrain
if (tempUnit->getPhysics()->getVelX() < 0){
if (tempCol->hitright(&tempUnit->getModel()->getCollider())){
tempUnit->getPhysics()->setAccelX(0.0f);
tempUnit->getPhysics()->setVelocityX(0.0f);
}
}
//When going right collide with left of terrain
if (tempUnit->getPhysics()->getVelX() > 0){
if (tempCol->hitLeft(&tempUnit->getModel()->getCollider())){
tempUnit->getPhysics()->setAccelX(0.0f);
tempUnit->getPhysics()->setVelocityX(0.0f);
}
}
//When falling collide with top of terrain
if (tempUnit->getPhysics()->getVelY() < 0){
if (tempCol->hitTop(&tempUnit->getModel()->getCollider())){
tempUnit->getPhysics()->setAccelY(0.0f);
tempUnit->getPhysics()->setVelocityY(0.0f);
tempUnit->getPhysics()->isGrounded(true);
}
}
//When jumping collide with bottom of terrain
if (tempUnit->getPhysics()->getVelY() > 0){
if (tempCol->hitBottom(&tempUnit->getModel()->getCollider())){
tempUnit->getPhysics()->setAccelY(0.0f);
tempUnit->getPhysics()->setVelocityY(0.0f);
}
}
}
else{
//If not colliding the unit is falling
tempUnit->getPhysics()->isGrounded(false);
}
//If the unit goes below the water level they die
if (tempUnit->getPosition().y < WATER_LEVEL && !tempUnit->isDead()){
tempUnit->setCurHealth(0);
if (m_curUnit == tempUnit){
changeUnit();
}
}
//When a unit is below 0 health set them to dead and change unit
if (!tempUnit->isDead() && tempUnit->getCurHealth() <= 0){
tempUnit->setCurHealth(0);
if (m_curUnit == tempUnit){
changeUnit();
}
}
//If the unit is alive, run its update
if (!tempUnit->isDead()){
if (m_delayTest){
tempUnit->update(m_mousePos);
//.........这里部分代码省略.........