示例#1
0
void Vehicles::update(double dt){


    if (health <= 0){

        isDead = true;

    }

    if (!isDead){

        speedControl(dt);
        newVehicle.pathRoute(dt);
        Pos = newVehicle.getCurrentLocation();

		updateHitbox();

        SetInteraction(AABB(Vector3(Pos.x - InteractionMin.x, Pos.y - InteractionMin.y, Pos.z - InteractionMin.z), Vector3(Pos.x + InteractionMax.x, Pos.y + InteractionMax.y, Pos.z + InteractionMax.z)));
        Yaw = getRotationAngle();

        if (currAttackTarget != nullptr){

            newVehicle.updateWayPoints(currAttackTarget->Pos);

        }


        Pos.y = 0;

    }

    bulletCurrCooldown += dt;


}
示例#2
0
bool Missile::isOutOfFuel() {
    updateHitbox(sin(-utils.getRadian(angle)), cos(-utils.getRadian(angle)), x, z);
    updateLimits();
    if(sqrt(pow((startX - x), 2) + pow((startZ - z), 2) > SHOT_LENGTH)) {
        return true;
    } else {
        move();
        return false;
    }
}
示例#3
0
void updateSprite(struct SPRITE *s)
{

    /* do sprite update, default implementation */
    /* keep sprite from moving when touching walls */
    if (s->solid) {
        if (s->isTouching[LEFT]) {
            --s->isTouching[LEFT];
        }
        if (s->isTouching[RIGHT]) {
            --s->isTouching[RIGHT];
        }
        if (s->isTouching[UP]) {
            --s->isTouching[UP];
        }
        if (s->isTouching[DOWN]) {
            --s->isTouching[DOWN];
        }
    }

    /* move sprite, standard physics */
    s->SetVX(s, calculateVelocity(s->GetVX(s), s->GetAX(s), s->GetDragX(s), s->GetMaxSpeedX(s)));
    s->SetVY(s, calculateVelocity(s->GetVY(s), s->GetAY(s), s->GetDragY(s), s->GetMaxSpeedY(s)));
    s->SetX(s, s->GetX(s) + s->GetVX(s));
    s->SetY(s, s->GetY(s) + s->GetVY(s));
    updateHitbox(&s->box);

    /* sprite timer execution */
    if (s) {
        if (s->timeLeft > 0) {
            --s->timeLeft;
        } else if (s->timeLeft == 0) {
            s->timeLeft = -1;
            if (s->timerFunc)
                s->timerFunc(s);
        }
    }

}
示例#4
0
void MovingObject::updateCoordinates(){
	updateXCoordinate(this->xVelocity);
	updateYCoordinate(this->yVelocity);
	updateHitbox(this->xVelocity, this->yVelocity);
}
示例#5
0
static void SetY(struct SPRITE *s, float val)
{
    s->box.y = val;
    updateHitbox(&s->box);
}