Compare commits

...

3 Commits

7 changed files with 40 additions and 178 deletions

View File

@@ -11,7 +11,7 @@ Coffee Crisis Arcade Edition és una versió ampliada i millorada del aclamat Co
Defensa el teu cafè contra les bambolles gegants en aquest trepidant joc d'arcade! 🍵 Defensa el teu cafè contra les bambolles gegants en aquest trepidant joc d'arcade! 🍵
<p align="center"> <p align="center">
<img src="https://php.sustancia.synology.me/images/ccae_title.png" alt="Títol" width="60%" /> <img src="https://php.sustancia.synology.me/images/ccae/ccae_title.png" alt="Títol" width="60%" />
</p> </p>
## Controls ## Controls
@@ -25,8 +25,8 @@ El joc està optimitzat per a ser jugat amb un mando de jocs, encara que un dels
> Nota: El joc suporta nomes un jugador amb teclat. > Nota: El joc suporta nomes un jugador amb teclat.
<p align="center"> <p align="center">
<img src="https://php.sustancia.synology.me/images/ccae1.png" alt="Joc" width="45%" /> <img src="https://php.sustancia.synology.me/images/ccae/ccae1.png" alt="Joc" width="45%" />
<img src="https://php.sustancia.synology.me/images/ccae3.png" alt="Joc" width="45%" /> <img src="https://php.sustancia.synology.me/images/ccae/ccae3.png" alt="Joc" width="45%" />
</p> </p>
## Altres tecles ## Altres tecles
@@ -44,7 +44,7 @@ El joc està optimitzat per a ser jugat amb un mando de jocs, encara que un dels
| **F10** | Reset del joc | | **F10** | Reset del joc |
<p align="center"> <p align="center">
<img src="https://php.sustancia.synology.me/images/ccae2.png" alt="Joc" width="50%" /> <img src="https://php.sustancia.synology.me/images/ccae/ccae2.png" alt="Joc" width="50%" />
</p> </p>
## Com instal·lar i jugar ## Com instal·lar i jugar

View File

@@ -61,7 +61,6 @@ Logo::~Logo()
jail_texture_->setColor(255, 255, 255); jail_texture_->setColor(255, 255, 255);
since_texture_->setColor(255, 255, 255); since_texture_->setColor(255, 255, 255);
JA_StopChannel(-1); JA_StopChannel(-1);
SDL_DestroyTexture(mi_textura);
} }
// Recarga todas las texturas // Recarga todas las texturas

View File

@@ -63,7 +63,6 @@ private:
LogoState state_ = LogoState::JAILGAMES; // El estado indica qué logo se está procesando LogoState state_ = LogoState::JAILGAMES; // El estado indica qué logo se está procesando
Uint32 ticks_start_ = 0; // Almacena el valor actual de los ticks de SDL Uint32 ticks_start_ = 0; // Almacena el valor actual de los ticks de SDL
std::vector<Pixel> pixels_; // Vector con los pixels que forman el logo de "RETROWEEKEND" std::vector<Pixel> pixels_; // Vector con los pixels que forman el logo de "RETROWEEKEND"
SDL_Texture *mi_textura;
// Actualiza las variables // Actualiza las variables
void update(); void update();

View File

@@ -73,46 +73,7 @@ void MovingSprite::update()
} }
// Muestra el sprite por pantalla // Muestra el sprite por pantalla
void MovingSprite::render() void MovingSprite::render() { texture_->render(pos_.x, pos_.y, &sprite_clip_, zoom_w_, zoom_h_, rotate_.angle, rotate_.center, flip_); }
{
texture_->render(pos_.x, pos_.y, &sprite_clip_, zoom_w_, zoom_h_, rotate_.angle, rotate_.center, flip_);
}
// Establece el valor de la variable
void MovingSprite::setZoomW(float value)
{
zoom_w_ = value;
}
// Establece el valor de la variable
void MovingSprite::setZoomH(float value)
{
zoom_h_ = value;
}
// Establece el valor de la variable
void MovingSprite::setAngle(double value)
{
rotate_.angle = value;
}
// Establece el valor de la variable
void MovingSprite::setRotatingCenter(SDL_Point *point)
{
rotate_.center = point;
}
// Incrementa el valor del ángulo
void MovingSprite::updateAngle()
{
rotate_.angle += rotate_.amount;
}
// Obtiene el valor de la variable
bool MovingSprite::isRotating() const
{
return rotate_.enabled;
}
// Establece la rotacion // Establece la rotacion
void MovingSprite::rotate() void MovingSprite::rotate()
@@ -135,43 +96,6 @@ void MovingSprite::setRotate(bool enable)
rotate_.counter = 0; rotate_.counter = 0;
} }
// Establece el valor de la variable
void MovingSprite::setRotateSpeed(int value)
{
rotate_.speed = std::max(1, value);
}
// Establece el valor de la variable
void MovingSprite::setRotateAmount(double value)
{
rotate_.amount = value;
}
// Cambia el sentido de la rotación
void MovingSprite::switchRotate()
{
rotate_.amount *= -1;
}
// Establece el valor de la variable
void MovingSprite::setFlip(SDL_RendererFlip flip)
{
flip_ = flip;
}
// Gira el sprite horizontalmente
void MovingSprite::flip()
{
flip_ = (flip_ == SDL_FLIP_HORIZONTAL) ? SDL_FLIP_NONE : SDL_FLIP_HORIZONTAL;
}
// Obtiene el valor de la variable
SDL_RendererFlip MovingSprite::getFlip()
{
return flip_;
}
// Establece la posición y_ el tamaño del objeto // Establece la posición y_ el tamaño del objeto
void MovingSprite::setPos(SDL_Rect rect) void MovingSprite::setPos(SDL_Rect rect)
{ {
@@ -204,27 +128,3 @@ void MovingSprite::setPosY(float value)
y_ = value; y_ = value;
pos_.y = static_cast<int>(y_); pos_.y = static_cast<int>(y_);
} }
// Establece el valor de la variable
void MovingSprite::setVelX(float value)
{
vx_ = value;
}
// Establece el valor de la variable
void MovingSprite::setVelY(float value)
{
vy_ = value;
}
// Establece el valor de la variable
void MovingSprite::setAccelX(float value)
{
ax_ = value;
}
// Establece el valor de la variable
void MovingSprite::setAccelY(float value)
{
ay_ = value;
}

View File

@@ -38,7 +38,7 @@ protected:
SDL_RendererFlip flip_; // Indica como se voltea el sprite SDL_RendererFlip flip_; // Indica como se voltea el sprite
// Incrementa el valor del ángulo // Incrementa el valor del ángulo
void updateAngle(); void updateAngle() { rotate_.angle += rotate_.amount; }
// Mueve el sprite // Mueve el sprite
void move(); void move();
@@ -73,40 +73,40 @@ public:
float getAccelY() const { return ay_; } float getAccelY() const { return ay_; }
// Establece la variable // Establece la variable
void setVelX(float value); void setVelX(float value) { vx_ = value; }
void setVelY(float value); void setVelY(float value) { vy_ = value; }
void setAccelX(float value); void setAccelX(float value) { ax_ = value; }
void setAccelY(float value); void setAccelY(float value) { ay_ = value; }
// Obten el valor de la variable // Obten el valor de la variable
bool isRotating() const; bool isRotating() const { return rotate_.enabled; }
// Establece el valor de la variable // Establece el valor de la variable
void setZoomW(float value); void setZoomW(float value) { zoom_w_ = value; }
void setZoomH(float value); void setZoomH(float value) { zoom_h_ = value; }
// Establece el valor de la variable // Establece el valor de la variable
void setAngle(double vaue); void setAngle(double value) { rotate_.angle = value; }
void setRotatingCenter(SDL_Point *point); void setRotatingCenter(SDL_Point *point) { rotate_.center = point; }
// Activa o desactiva el efecto de rotación // Activa o desactiva el efecto de rotación
void setRotate(bool enable); void setRotate(bool enable);
// Establece el valor de la variable // Establece el valor de la variable
void setRotateSpeed(int value); void setRotateSpeed(int value) { rotate_.speed = std::max(1, value); }
void setRotateAmount(double value); void setRotateAmount(double value) { rotate_.amount = value; }
// Cambia el sentido de la rotación // Cambia el sentido de la rotación
void switchRotate(); void switchRotate() { rotate_.amount *= -1; }
// Establece el valor de la variable // Establece el valor de la variable
void setFlip(SDL_RendererFlip flip); void setFlip(SDL_RendererFlip flip) { flip_ = flip; }
// Gira el sprite horizontalmente // Gira el sprite horizontalmente
void flip(); void flip() { flip_ = (flip_ == SDL_FLIP_HORIZONTAL) ? SDL_FLIP_NONE : SDL_FLIP_HORIZONTAL; }
// Obtiene el valor de la variable // Obtiene el valor de la variable
SDL_RendererFlip getFlip(); SDL_RendererFlip getFlip() { return flip_; }
// Establece la posición y_ el tamaño del objeto // Establece la posición y_ el tamaño del objeto
void setPos(SDL_Rect rect); void setPos(SDL_Rect rect);

View File

@@ -17,22 +17,13 @@ void SmartSprite::update()
} }
} }
// Establece el valor de la variable // Dibuja el sprite
void SmartSprite::setFinishedCounter(int value) void SmartSprite::render()
{ {
finished_counter_ = value; if (enabled_)
} {
MovingSprite::render();
// Establece el valor de la variable }
void SmartSprite::setDestX(int x)
{
dest_x_ = x;
}
// Establece el valor de la variable
void SmartSprite::setDestY(int y)
{
dest_y_ = y;
} }
// Comprueba el movimiento // Comprueba el movimiento
@@ -115,21 +106,3 @@ void SmartSprite::checkFinished()
} }
} }
} }
// Obtiene el valor de la variable
bool SmartSprite::isOnDestination() const
{
return on_destination_;
}
// Obtiene el valor de la variable
bool SmartSprite::hasFinished() const
{
return finished_;
}
// Habilita el objeto
void SmartSprite::setEnabled(bool value)
{
enabled_ = value;
}

View File

@@ -32,27 +32,18 @@ public:
// Actualiza la posición y comprueba si ha llegado a su destino // Actualiza la posición y comprueba si ha llegado a su destino
void update() override; void update() override;
// Establece el valor de la variable // Dibuja el sprite
void setFinishedCounter(int value); void render();
// Establece el valor de la variable // Getters
void setDestX(int x); int getDestX() const { return dest_x_; }
int getDestY() const { return dest_y_; }
bool isOnDestination() const { return on_destination_; }
bool hasFinished() const { return finished_; }
// Establece el valor de la variable // Setters
void setDestY(int y); void setFinishedCounter(int value) { finished_counter_ = value; }
void setDestX(int x) { dest_x_ = x; }
// Obtiene el valor de la variable void setDestY(int y) { dest_y_ = y; }
int getDestX() const; void setEnabled(bool value) { enabled_ = value; }
// Obtiene el valor de la variable
int getDestY() const;
// Obtiene el valor de la variable
bool isOnDestination() const;
// Obtiene el valor de la variable
bool hasFinished() const;
// Habilita el objeto
void setEnabled(bool value);
}; };