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; }
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; } }
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); } } }
void MovingObject::updateCoordinates(){ updateXCoordinate(this->xVelocity); updateYCoordinate(this->yVelocity); updateHitbox(this->xVelocity, this->yVelocity); }
static void SetY(struct SPRITE *s, float val) { s->box.y = val; updateHitbox(&s->box); }