Afegits roidets de colisió per als globos per a certs moments
This commit is contained in:
@@ -5,6 +5,8 @@
|
||||
#include "param.h" // Para Param, param, ParamBalloon, ParamGame
|
||||
#include "sprite.h" // Para Sprite
|
||||
#include "texture.h" // Para Texture
|
||||
#include "resource.h"
|
||||
#include "jail_audio.h"
|
||||
|
||||
// Constructor
|
||||
Balloon::Balloon(float x, float y, BalloonType type, BalloonSize size, float vel_x, float speed, Uint16 creation_timer, SDL_Rect play_area, std::shared_ptr<Texture> texture, const std::vector<std::string> &animation)
|
||||
@@ -36,6 +38,7 @@ Balloon::Balloon(float x, float y, BalloonType type, BalloonSize size, float vel
|
||||
power_ = BALLOON_POWER[index];
|
||||
menace_ = BALLOON_MENACE[index];
|
||||
score_ = BALLOON_SCORE[index];
|
||||
sound_ = BALLOON_SOUND[index];
|
||||
|
||||
break;
|
||||
}
|
||||
@@ -50,14 +53,16 @@ Balloon::Balloon(float x, float y, BalloonType type, BalloonSize size, float vel
|
||||
power_ = BALLOON_POWER[index];
|
||||
menace_ = BALLOON_MENACE[index];
|
||||
score_ = BALLOON_SCORE[index];
|
||||
sound_ = BALLOON_SOUND[index];
|
||||
|
||||
break;
|
||||
}
|
||||
|
||||
case BalloonType::POWERBALL:
|
||||
{
|
||||
const int index = 3;
|
||||
constexpr int index = 3;
|
||||
h_ = w_ = BALLOON_SIZE[4];
|
||||
sound_ = BALLOON_SOUND[3];
|
||||
power_ = score_ = menace_ = 0;
|
||||
|
||||
vy_ = 0;
|
||||
@@ -145,6 +150,7 @@ void Balloon::move()
|
||||
const float max_x = play_area_.x + play_area_.w - w_ + clip;
|
||||
if (x_ < min_x || x_ > max_x)
|
||||
{
|
||||
playSound();
|
||||
x_ = std::clamp(x_, min_x, max_x);
|
||||
vx_ = -vx_;
|
||||
// Activa el efecto de rebote o invierte la rotación
|
||||
@@ -179,6 +185,7 @@ void Balloon::move()
|
||||
const int min_y = play_area_.y;
|
||||
if (y_ < min_y)
|
||||
{
|
||||
playSound();
|
||||
y_ = min_y;
|
||||
vy_ = -vy_;
|
||||
enableBounce();
|
||||
@@ -189,6 +196,7 @@ void Balloon::move()
|
||||
const int max_y = play_area_.y + play_area_.h - h_;
|
||||
if (y_ > max_y)
|
||||
{
|
||||
playSound();
|
||||
y_ = max_y;
|
||||
vy_ = -default_vy_;
|
||||
if (type_ != BalloonType::POWERBALL)
|
||||
@@ -401,4 +409,13 @@ void Balloon::useNormalColor()
|
||||
{
|
||||
use_reversed_colors_ = false;
|
||||
setAnimation();
|
||||
}
|
||||
|
||||
// Reproduce el sonido al rebotar
|
||||
void Balloon::playSound()
|
||||
{
|
||||
if (sound_enabled_)
|
||||
{
|
||||
JA_PlaySound(Resource::get()->getSound(sound_));
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user