tidy-fix automàtic (sense naming)
This commit is contained in:
+44
-25
@@ -1,6 +1,6 @@
|
||||
#include "game/mapa.hpp"
|
||||
|
||||
#include <stdlib.h>
|
||||
#include <cstdlib>
|
||||
|
||||
#include "core/jail/jgame.hpp"
|
||||
#include "core/jail/jinput.hpp"
|
||||
@@ -21,7 +21,7 @@ Mapa::Mapa(JD8_Surface gfx, Prota* sam) {
|
||||
this->nova_momia = false;
|
||||
}
|
||||
|
||||
Mapa::~Mapa(void) {
|
||||
Mapa::~Mapa() {
|
||||
JD8_FreeSurface(this->fondo);
|
||||
}
|
||||
|
||||
@@ -48,7 +48,7 @@ void Mapa::draw() {
|
||||
// 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);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -62,7 +62,9 @@ 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) this->comprovaUltimCami();
|
||||
if (this->ultim_vertex.columna != 255) {
|
||||
this->comprovaUltimCami();
|
||||
}
|
||||
this->ultim_vertex = this->vertex;
|
||||
}
|
||||
|
||||
@@ -79,7 +81,7 @@ void Mapa::update() {
|
||||
}
|
||||
}
|
||||
|
||||
bool Mapa::novaMomia() {
|
||||
auto Mapa::novaMomia() -> bool {
|
||||
bool resultat = nova_momia;
|
||||
nova_momia = false;
|
||||
return resultat;
|
||||
@@ -96,7 +98,9 @@ void Mapa::preparaFondoEstatic() {
|
||||
}
|
||||
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);
|
||||
if (info::ctx.diners >= 200) {
|
||||
JD8_BlitToSurface(175, 3, this->gfx, 60, 193, 7, 6, this->fondo);
|
||||
}
|
||||
|
||||
// Pinta taulells
|
||||
for (int y = 0; y < 11; y++) {
|
||||
@@ -150,7 +154,7 @@ void Mapa::preparaFondoEstatic() {
|
||||
}
|
||||
}
|
||||
|
||||
void swap(Uint8& a, Uint8& b) {
|
||||
void swap(Uint8& a, Uint8& b) noexcept {
|
||||
Uint8 temp = a;
|
||||
a = b;
|
||||
b = temp;
|
||||
@@ -161,28 +165,36 @@ void Mapa::preparaTombes() {
|
||||
int cx = info::ctx.num_piramide == 6 ? 270 : 0;
|
||||
int cy = info::ctx.num_piramide == 6 ? 50 : 0;
|
||||
|
||||
for (int i = 0; i < 16; i++) {
|
||||
this->tombes[i].contingut = contingut;
|
||||
this->tombes[i].oberta = false;
|
||||
this->tombes[i].costat[0] = false;
|
||||
this->tombes[i].costat[1] = false;
|
||||
this->tombes[i].costat[2] = false;
|
||||
this->tombes[i].costat[3] = false;
|
||||
this->tombes[i].x = cx;
|
||||
this->tombes[i].y = cy;
|
||||
for (auto& tombe : this->tombes) {
|
||||
tombe.contingut = contingut;
|
||||
tombe.oberta = false;
|
||||
tombe.costat[0] = false;
|
||||
tombe.costat[1] = false;
|
||||
tombe.costat[2] = false;
|
||||
tombe.costat[3] = false;
|
||||
tombe.x = cx;
|
||||
tombe.y = cy;
|
||||
}
|
||||
if (info::ctx.num_piramide == 6) {
|
||||
return;
|
||||
}
|
||||
if (info::ctx.num_piramide == 6) return;
|
||||
this->tombes[0].contingut = CONTE_FARAO;
|
||||
this->tombes[1].contingut = CONTE_CLAU;
|
||||
this->tombes[2].contingut = CONTE_PERGAMI;
|
||||
this->tombes[3].contingut = CONTE_MOMIA;
|
||||
for (int i = 4; i < 8; i++) this->tombes[i].contingut = CONTE_RES;
|
||||
for (int i = 8; i < 16; i++) this->tombes[i].contingut = CONTE_TRESOR;
|
||||
for (int i = 4; i < 8; i++) {
|
||||
this->tombes[i].contingut = CONTE_RES;
|
||||
}
|
||||
for (int i = 8; i < 16; i++) {
|
||||
this->tombes[i].contingut = CONTE_TRESOR;
|
||||
}
|
||||
|
||||
for (int i = 0; i < 50; i++) swap(this->tombes[rand() % 16].contingut, this->tombes[rand() % 16].contingut);
|
||||
for (int i = 0; i < 50; i++) {
|
||||
swap(this->tombes[rand() % 16].contingut, this->tombes[rand() % 16].contingut);
|
||||
}
|
||||
}
|
||||
|
||||
Uint8 minim(Uint8 a, Uint8 b) {
|
||||
auto minim(Uint8 a, Uint8 b) -> Uint8 {
|
||||
return (a < b) ? a : b;
|
||||
}
|
||||
|
||||
@@ -225,11 +237,16 @@ void Mapa::comprovaUltimCami() {
|
||||
|
||||
void Mapa::comprovaCaixa(Uint8 num) {
|
||||
// Si la tomba ja està oberta, no hi ha res que mirar
|
||||
if (this->tombes[num].oberta) return;
|
||||
if (this->tombes[num].oberta) {
|
||||
return;
|
||||
}
|
||||
|
||||
// Si algun costat encara no està passat, no hi ha res que fer
|
||||
for (int i = 0; i < 4; i++)
|
||||
if (!this->tombes[num].costat[i]) return;
|
||||
for (bool i : this->tombes[num].costat) {
|
||||
if (!i) {
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
// Sinó, pos la acabem d'obrir
|
||||
this->tombes[num].oberta = true;
|
||||
@@ -263,7 +280,9 @@ void Mapa::comprovaCaixa(Uint8 num) {
|
||||
this->tombes[num].y = 70;
|
||||
info::ctx.diamants++;
|
||||
info::ctx.diners += VALOR_DIAMANT;
|
||||
if (info::ctx.diamants == 16) this->farao = this->clau = true;
|
||||
if (info::ctx.diamants == 16) {
|
||||
this->farao = this->clau = true;
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user