fix: tidy scenes (slides/secreta enums UPPER_CASE) i mapa membres _
This commit is contained in:
+69
-69
@@ -7,102 +7,102 @@
|
||||
#include "core/jail/jinput.hpp"
|
||||
|
||||
Mapa::Mapa(Jd8::Surface gfx, Prota* sam) {
|
||||
this->gfx = gfx;
|
||||
this->sam = sam;
|
||||
this->gfx_ = gfx;
|
||||
this->sam_ = sam;
|
||||
|
||||
this->preparaFondoEstatic();
|
||||
this->preparaTombes();
|
||||
|
||||
this->ultim_vertex.columna = 255;
|
||||
this->frame_torxes = 0;
|
||||
this->ultim_vertex_.columna = 255;
|
||||
this->frame_torxes_ = 0;
|
||||
|
||||
this->farao = false;
|
||||
this->clau = false;
|
||||
this->porta_oberta = false;
|
||||
this->nova_momia = false;
|
||||
this->farao_ = false;
|
||||
this->clau_ = false;
|
||||
this->porta_oberta_ = false;
|
||||
this->nova_momia_ = false;
|
||||
}
|
||||
|
||||
Mapa::~Mapa() {
|
||||
Jd8::freeSurface(this->fondo);
|
||||
Jd8::freeSurface(this->fondo_);
|
||||
}
|
||||
|
||||
void Mapa::draw() {
|
||||
if (info::ctx.num_piramide != 4) {
|
||||
switch (sam->o) {
|
||||
switch (sam_->o) {
|
||||
case 0: // Down
|
||||
Jd8::blitCKToSurface(sam->x, sam->y, this->gfx, 15, 125 + sam->frame_pejades, 15, 1, this->fondo, 255);
|
||||
Jd8::blitCKToSurface(sam_->x, sam_->y, this->gfx_, 15, 125 + sam_->frame_pejades, 15, 1, this->fondo_, 255);
|
||||
break;
|
||||
case 1: // Up
|
||||
Jd8::blitCKToSurface(sam->x, sam->y + 15, this->gfx, 0, 125 + (14 - sam->frame_pejades), 15, 1, this->fondo, 255);
|
||||
Jd8::blitCKToSurface(sam_->x, sam_->y + 15, this->gfx_, 0, 125 + (14 - sam_->frame_pejades), 15, 1, this->fondo_, 255);
|
||||
break;
|
||||
case 2: // Right
|
||||
Jd8::blitCKToSurface(sam->x + 7, sam->y, this->gfx, 30 + sam->frame_pejades, 125, 1, 15, this->fondo, 255);
|
||||
Jd8::blitCKToSurface(sam_->x + 7, sam_->y, this->gfx_, 30 + sam_->frame_pejades, 125, 1, 15, this->fondo_, 255);
|
||||
break;
|
||||
case 3: // Left
|
||||
Jd8::blitCKToSurface(sam->x + 8, sam->y, this->gfx, 45 + (14 - sam->frame_pejades), 125, 1, 15, this->fondo, 255);
|
||||
Jd8::blitCKToSurface(sam_->x + 8, sam_->y, this->gfx_, 45 + (14 - sam_->frame_pejades), 125, 1, 15, this->fondo_, 255);
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
Jd8::blit(this->fondo);
|
||||
Jd8::blit(this->fondo_);
|
||||
|
||||
// Pinta tombes
|
||||
for (int y = 0; y < 4; y++) {
|
||||
for (int x = 0; x < 4; x++) {
|
||||
Jd8::blitCK(35 + (x * 65), 45 + (y * 35), this->gfx, this->tombes[x + (y * 4)].x, this->tombes[x + (y * 4)].y, 50, 20, 255);
|
||||
Jd8::blitCK(35 + (x * 65), 45 + (y * 35), this->gfx_, this->tombes[x + (y * 4)].x, this->tombes[x + (y * 4)].y, 50, 20, 255);
|
||||
}
|
||||
}
|
||||
|
||||
Jd8::blitCK(45, 15, this->gfx, 30 + (this->frame_torxes * 25), 80, 25, 15, 255);
|
||||
Jd8::blitCK(95, 15, this->gfx, 30 + (this->frame_torxes * 25), 80, 25, 15, 255);
|
||||
Jd8::blitCK(195, 15, this->gfx, 30 + (this->frame_torxes * 25), 80, 25, 15, 255);
|
||||
Jd8::blitCK(245, 15, this->gfx, 30 + (this->frame_torxes * 25), 80, 25, 15, 255);
|
||||
Jd8::blitCK(45, 15, this->gfx_, 30 + (this->frame_torxes_ * 25), 80, 25, 15, 255);
|
||||
Jd8::blitCK(95, 15, this->gfx_, 30 + (this->frame_torxes_ * 25), 80, 25, 15, 255);
|
||||
Jd8::blitCK(195, 15, this->gfx_, 30 + (this->frame_torxes_ * 25), 80, 25, 15, 255);
|
||||
Jd8::blitCK(245, 15, this->gfx_, 30 + (this->frame_torxes_ * 25), 80, 25, 15, 255);
|
||||
};
|
||||
|
||||
void Mapa::update() {
|
||||
if (((sam->x - 20) % 65 == 0) && ((sam->y - 30) % 35 == 0) && ((this->ultim_vertex.columna != (sam->x - 20) / 65) || (this->ultim_vertex.fila != (sam->y - 30) / 35))) {
|
||||
this->vertex.columna = (sam->x - 20) / 65;
|
||||
this->vertex.fila = (sam->y - 30) / 35;
|
||||
if (this->ultim_vertex.columna != 255) {
|
||||
if (((sam_->x - 20) % 65 == 0) && ((sam_->y - 30) % 35 == 0) && ((this->ultim_vertex_.columna != (sam_->x - 20) / 65) || (this->ultim_vertex_.fila != (sam_->y - 30) / 35))) {
|
||||
this->vertex_.columna = (sam_->x - 20) / 65;
|
||||
this->vertex_.fila = (sam_->y - 30) / 35;
|
||||
if (this->ultim_vertex_.columna != 255) {
|
||||
this->comprovaUltimCami();
|
||||
}
|
||||
this->ultim_vertex = this->vertex;
|
||||
this->ultim_vertex_ = this->vertex_;
|
||||
}
|
||||
|
||||
if (this->porta_oberta && sam->x == 150 && sam->y == 30) {
|
||||
if (this->porta_oberta_ && sam_->x == 150 && sam_->y == 30) {
|
||||
if (Ji::keyPressed(SDL_SCANCODE_UP)) {
|
||||
this->sam->o = 4;
|
||||
this->sam->y -= 15;
|
||||
this->sam_->o = 4;
|
||||
this->sam_->y -= 15;
|
||||
}
|
||||
}
|
||||
|
||||
if (Jg::getCycleCounter() % 8 == 0) {
|
||||
this->frame_torxes++;
|
||||
this->frame_torxes = this->frame_torxes % 4;
|
||||
this->frame_torxes_++;
|
||||
this->frame_torxes_ = this->frame_torxes_ % 4;
|
||||
}
|
||||
}
|
||||
|
||||
auto Mapa::novaMomia() -> bool {
|
||||
bool resultat = nova_momia;
|
||||
nova_momia = false;
|
||||
bool resultat = nova_momia_;
|
||||
nova_momia_ = false;
|
||||
return resultat;
|
||||
}
|
||||
|
||||
void Mapa::preparaFondoEstatic() {
|
||||
// Prepara el fondo est�tic de l'habitaci�
|
||||
this->fondo = Jd8::newSurface();
|
||||
this->fondo_ = Jd8::newSurface();
|
||||
if (info::ctx.num_piramide == 6) {
|
||||
Jd8::blitToSurface(9, 2, this->gfx, 227, 185, 92, 7, this->fondo); // Text "SECRETA"
|
||||
Jd8::blitToSurface(9, 2, this->gfx_, 227, 185, 92, 7, this->fondo_); // Text "SECRETA"
|
||||
} else {
|
||||
Jd8::blitToSurface(9, 2, this->gfx, 60, 185, 39, 7, this->fondo); // Text "NIVELL"
|
||||
Jd8::blitToSurface(72, 6, this->gfx, 153, 189, 3, 1, this->fondo); // Ralleta entre num piramide i num habitacio
|
||||
Jd8::blitToSurface(9, 2, this->gfx_, 60, 185, 39, 7, this->fondo_); // Text "NIVELL"
|
||||
Jd8::blitToSurface(72, 6, this->gfx_, 153, 189, 3, 1, this->fondo_); // Ralleta entre num piramide i num habitacio
|
||||
}
|
||||
Jd8::blitToSurface(130, 2, this->gfx, 225, 192, 19, 8, this->fondo); // Montonet de monedes + signe '='
|
||||
Jd8::blitToSurface(220, 2, this->gfx, 160, 185, 48, 7, this->fondo); // Text "ENERGIA"
|
||||
Jd8::blitToSurface(130, 2, this->gfx_, 225, 192, 19, 8, this->fondo_); // Montonet de monedes + signe '='
|
||||
Jd8::blitToSurface(220, 2, this->gfx_, 160, 185, 48, 7, this->fondo_); // Text "ENERGIA"
|
||||
if (info::ctx.diners >= 200) {
|
||||
Jd8::blitToSurface(175, 3, this->gfx, 60, 193, 7, 6, this->fondo);
|
||||
Jd8::blitToSurface(175, 3, this->gfx_, 60, 193, 7, 6, this->fondo_);
|
||||
}
|
||||
|
||||
// Pinta taulells
|
||||
@@ -110,22 +110,22 @@ void Mapa::preparaFondoEstatic() {
|
||||
for (int x = 0; x < 19; x++) {
|
||||
switch (info::ctx.num_piramide) {
|
||||
case 1:
|
||||
Jd8::blitToSurface(20 + (x * 15), 30 + (y * 15), this->gfx, 0, 80, 15, 15, this->fondo);
|
||||
Jd8::blitToSurface(20 + (x * 15), 30 + (y * 15), this->gfx_, 0, 80, 15, 15, this->fondo_);
|
||||
break;
|
||||
case 2:
|
||||
Jd8::blitToSurface(20 + (x * 15), 30 + (y * 15), this->gfx, 25, 95, 15, 15, this->fondo);
|
||||
Jd8::blitToSurface(20 + (x * 15), 30 + (y * 15), this->gfx_, 25, 95, 15, 15, this->fondo_);
|
||||
break;
|
||||
case 3:
|
||||
Jd8::blitToSurface(20 + (x * 15), 30 + (y * 15), this->gfx, 40, 95, 15, 15, this->fondo);
|
||||
Jd8::blitToSurface(20 + (x * 15), 30 + (y * 15), this->gfx_, 40, 95, 15, 15, this->fondo_);
|
||||
break;
|
||||
case 4:
|
||||
Jd8::blitToSurface(20 + (x * 15), 30 + (y * 15), this->gfx, 175 + ((rand() % 3) * 15), 80, 15, 15, this->fondo);
|
||||
Jd8::blitToSurface(20 + (x * 15), 30 + (y * 15), this->gfx_, 175 + ((rand() % 3) * 15), 80, 15, 15, this->fondo_);
|
||||
break;
|
||||
case 5:
|
||||
Jd8::blitToSurface(20 + (x * 15), 30 + (y * 15), this->gfx, 130, 80, 15, 15, this->fondo);
|
||||
Jd8::blitToSurface(20 + (x * 15), 30 + (y * 15), this->gfx_, 130, 80, 15, 15, this->fondo_);
|
||||
break;
|
||||
case 6:
|
||||
Jd8::blitToSurface(20 + (x * 15), 30 + (y * 15), this->gfx, 145, 80, 15, 15, this->fondo);
|
||||
Jd8::blitToSurface(20 + (x * 15), 30 + (y * 15), this->gfx_, 145, 80, 15, 15, this->fondo_);
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
@@ -134,28 +134,28 @@ void Mapa::preparaFondoEstatic() {
|
||||
}
|
||||
|
||||
// Pinta vores de les parets
|
||||
Jd8::blitCKToSurface(5, 15, this->gfx, 30, 110, 15, 15, this->fondo, 255);
|
||||
Jd8::blitCKToSurface(295, 15, this->gfx, 45, 110, 15, 15, this->fondo, 255);
|
||||
Jd8::blitCKToSurface(5, 180, this->gfx, 0, 155, 15, 20, this->fondo, 255);
|
||||
Jd8::blitCKToSurface(295, 180, this->gfx, 15, 155, 15, 20, this->fondo, 255);
|
||||
Jd8::blitCKToSurface(5, 15, this->gfx_, 30, 110, 15, 15, this->fondo_, 255);
|
||||
Jd8::blitCKToSurface(295, 15, this->gfx_, 45, 110, 15, 15, this->fondo_, 255);
|
||||
Jd8::blitCKToSurface(5, 180, this->gfx_, 0, 155, 15, 20, this->fondo_, 255);
|
||||
Jd8::blitCKToSurface(295, 180, this->gfx_, 15, 155, 15, 20, this->fondo_, 255);
|
||||
|
||||
// Pinta parets verticals
|
||||
for (int i = 0; i < 10; i++) {
|
||||
Jd8::blitToSurface(5, 30 + (i * 15), this->gfx, 0, 110, 15, 15, this->fondo);
|
||||
Jd8::blitToSurface(295, 30 + (i * 15), this->gfx, 15, 110, 15, 15, this->fondo);
|
||||
Jd8::blitToSurface(5, 30 + (i * 15), this->gfx_, 0, 110, 15, 15, this->fondo_);
|
||||
Jd8::blitToSurface(295, 30 + (i * 15), this->gfx_, 15, 110, 15, 15, this->fondo_);
|
||||
}
|
||||
|
||||
// Pinta parets hortzintals
|
||||
for (int i = 0; i < 11; i++) {
|
||||
Jd8::blitToSurface(20 + (i * 25), 185, this->gfx, 0, 95, 25, 15, this->fondo);
|
||||
Jd8::blitToSurface(20 + (i * 25), 15, this->gfx, 0, 95, 25, 15, this->fondo);
|
||||
Jd8::blitToSurface(20 + (i * 25), 185, this->gfx_, 0, 95, 25, 15, this->fondo_);
|
||||
Jd8::blitToSurface(20 + (i * 25), 15, this->gfx_, 0, 95, 25, 15, this->fondo_);
|
||||
}
|
||||
|
||||
// Pinta la porta
|
||||
Jd8::blitCKToSurface(150, 18, this->gfx, 0, 143, 15, 12, this->fondo, 255);
|
||||
Jd8::blitCKToSurface(150, 18, this->gfx_, 0, 143, 15, 12, this->fondo_, 255);
|
||||
|
||||
if (info::ctx.num_piramide == 2) {
|
||||
Jd8::blitToSurface(5, 100, this->gfx, 30, 140, 15, 15, this->fondo);
|
||||
Jd8::blitToSurface(5, 100, this->gfx_, 30, 140, 15, 15, this->fondo_);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -204,12 +204,12 @@ auto minim(Uint8 a, Uint8 b) -> Uint8 {
|
||||
}
|
||||
|
||||
void Mapa::comprovaUltimCami() {
|
||||
Uint8 col_aux = abs(this->vertex.columna - this->ultim_vertex.columna);
|
||||
Uint8 fil_aux = abs(this->vertex.fila - this->ultim_vertex.fila);
|
||||
Uint8 col_aux = abs(this->vertex_.columna - this->ultim_vertex_.columna);
|
||||
Uint8 fil_aux = abs(this->vertex_.fila - this->ultim_vertex_.fila);
|
||||
|
||||
if (col_aux > fil_aux) { // Cam� horitzontal
|
||||
Uint8 cami_fila = this->vertex.fila;
|
||||
Uint8 cami_columna = minim(this->vertex.columna, this->ultim_vertex.columna);
|
||||
Uint8 cami_fila = this->vertex_.fila;
|
||||
Uint8 cami_columna = minim(this->vertex_.columna, this->ultim_vertex_.columna);
|
||||
|
||||
Sint8 caixa_avall = (cami_fila << 2) + cami_columna;
|
||||
Sint8 caixa_amunt = caixa_avall - 4;
|
||||
@@ -223,8 +223,8 @@ void Mapa::comprovaUltimCami() {
|
||||
this->comprovaCaixa(caixa_amunt);
|
||||
}
|
||||
} else { // Cam� vertical
|
||||
Uint8 cami_columna = this->vertex.columna;
|
||||
Uint8 cami_fila = minim(this->vertex.fila, this->ultim_vertex.fila);
|
||||
Uint8 cami_columna = this->vertex_.columna;
|
||||
Uint8 cami_fila = minim(this->vertex_.fila, this->ultim_vertex_.fila);
|
||||
|
||||
Sint8 caixa_dreta = (cami_fila << 2) + cami_columna;
|
||||
Sint8 caixa_esquerra = caixa_dreta - 1;
|
||||
@@ -265,26 +265,26 @@ void Mapa::comprovaCaixa(Uint8 num) {
|
||||
break;
|
||||
case CONTE_FARAO:
|
||||
this->tombes[num].x = 150;
|
||||
this->farao = true;
|
||||
this->farao_ = true;
|
||||
break;
|
||||
case CONTE_CLAU:
|
||||
this->tombes[num].x = 200;
|
||||
this->clau = true;
|
||||
this->clau_ = true;
|
||||
break;
|
||||
case CONTE_MOMIA:
|
||||
this->tombes[num].y = 175;
|
||||
this->nova_momia = true;
|
||||
this->nova_momia_ = true;
|
||||
break;
|
||||
case CONTE_PERGAMI:
|
||||
this->tombes[num].x = 250;
|
||||
this->sam->pergami = true;
|
||||
this->sam_->pergami = true;
|
||||
break;
|
||||
case CONTE_DIAMANT:
|
||||
this->tombes[num].y = 70;
|
||||
info::ctx.diamants++;
|
||||
info::ctx.diners += VALOR_DIAMANT;
|
||||
if (info::ctx.diamants == 16) {
|
||||
this->farao = this->clau = true;
|
||||
this->farao_ = this->clau_ = true;
|
||||
}
|
||||
break;
|
||||
default:
|
||||
@@ -295,8 +295,8 @@ void Mapa::comprovaCaixa(Uint8 num) {
|
||||
}
|
||||
|
||||
void Mapa::comprovaPorta() {
|
||||
if (this->clau && this->farao) {
|
||||
Jd8::blitCKToSurface(150, 18, this->gfx, 15, 143, 15, 12, this->fondo, 255);
|
||||
porta_oberta = true;
|
||||
if (this->clau_ && this->farao_) {
|
||||
Jd8::blitCKToSurface(150, 18, this->gfx_, 15, 143, 15, 12, this->fondo_, 255);
|
||||
porta_oberta_ = true;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user