afegit friendly fire
This commit is contained in:
@@ -19,6 +19,7 @@ Bala::Bala(SDL_Renderer* renderer)
|
||||
angle_(0.0f),
|
||||
velocitat_(0.0f),
|
||||
esta_(false),
|
||||
grace_timer_(0.0f),
|
||||
brightness_(Defaults::Brightness::BALA) {
|
||||
// [NUEVO] Carregar forma compartida des de fitxer
|
||||
forma_ = Graphics::ShapeLoader::load("bullet.shp");
|
||||
@@ -34,6 +35,7 @@ void Bala::inicialitzar() {
|
||||
centre_ = {0.0f, 0.0f};
|
||||
angle_ = 0.0f;
|
||||
velocitat_ = 0.0f;
|
||||
grace_timer_ = 0.0f;
|
||||
}
|
||||
|
||||
void Bala::disparar(const Punt& posicio, float angle, uint8_t owner_id) {
|
||||
@@ -57,12 +59,23 @@ void Bala::disparar(const Punt& posicio, float angle, uint8_t owner_id) {
|
||||
// 7 px/frame × 20 FPS = 140 px/s
|
||||
velocitat_ = 140.0f;
|
||||
|
||||
// Activar grace period (prevents instant self-collision)
|
||||
grace_timer_ = Defaults::Game::BULLET_GRACE_PERIOD;
|
||||
|
||||
// Reproducir sonido de disparo láser
|
||||
Audio::get()->playSound(Defaults::Sound::LASER, Audio::Group::GAME);
|
||||
}
|
||||
|
||||
void Bala::actualitzar(float delta_time) {
|
||||
if (esta_) {
|
||||
// Decrementar grace timer
|
||||
if (grace_timer_ > 0.0f) {
|
||||
grace_timer_ -= delta_time;
|
||||
if (grace_timer_ < 0.0f) {
|
||||
grace_timer_ = 0.0f;
|
||||
}
|
||||
}
|
||||
|
||||
mou(delta_time);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user