cppcheck
This commit is contained in:
@@ -9,28 +9,21 @@ ModuleGame::ModuleGame() {
|
||||
this->gfx = JD8_LoadSurface(info::ctx.pepe_activat ? "gfx/frames2.gif" : "gfx/frames.gif");
|
||||
JG_SetUpdateTicks(10);
|
||||
|
||||
this->sam = new Prota(this->gfx);
|
||||
this->mapa = new Mapa(this->gfx, this->sam);
|
||||
this->marcador = new Marcador(this->gfx, this->sam);
|
||||
this->sam = std::make_unique<Prota>(this->gfx);
|
||||
this->mapa = std::make_unique<Mapa>(this->gfx, this->sam.get());
|
||||
this->marcador = std::make_unique<Marcador>(this->gfx, this->sam.get());
|
||||
if (info::ctx.num_piramide == 2) {
|
||||
this->bola = new Bola(this->gfx, this->sam);
|
||||
} else {
|
||||
this->bola = nullptr;
|
||||
this->bola = std::make_unique<Bola>(this->gfx, this->sam.get());
|
||||
}
|
||||
this->momies = nullptr;
|
||||
|
||||
this->iniciarMomies();
|
||||
}
|
||||
|
||||
ModuleGame::~ModuleGame() {
|
||||
if (this->bola != nullptr) delete this->bola;
|
||||
if (this->momies != nullptr) {
|
||||
this->momies->clear();
|
||||
delete this->momies;
|
||||
}
|
||||
delete this->marcador;
|
||||
delete this->mapa;
|
||||
delete this->sam;
|
||||
|
||||
JD8_FreeSurface(this->gfx);
|
||||
}
|
||||
@@ -123,7 +116,7 @@ void ModuleGame::Draw() {
|
||||
this->marcador->draw();
|
||||
this->sam->draw();
|
||||
if (this->momies != nullptr) this->momies->draw();
|
||||
if (this->bola != nullptr) this->bola->draw();
|
||||
if (this->bola) this->bola->draw();
|
||||
}
|
||||
|
||||
void ModuleGame::Update() {
|
||||
@@ -137,14 +130,14 @@ void ModuleGame::Update() {
|
||||
this->momies = seguent;
|
||||
info::ctx.momies--;
|
||||
}
|
||||
if (this->bola != nullptr) this->bola->update();
|
||||
if (this->bola) this->bola->update();
|
||||
this->mapa->update();
|
||||
if (this->mapa->novaMomia()) {
|
||||
if (this->momies != nullptr) {
|
||||
this->momies->insertar(new Momia(this->gfx, true, 0, 0, this->sam));
|
||||
this->momies->insertar(new Momia(this->gfx, true, 0, 0, this->sam.get()));
|
||||
info::ctx.momies++;
|
||||
} else {
|
||||
this->momies = new Momia(this->gfx, true, 0, 0, this->sam);
|
||||
this->momies = new Momia(this->gfx, true, 0, 0, this->sam.get());
|
||||
info::ctx.momies++;
|
||||
}
|
||||
}
|
||||
@@ -187,9 +180,9 @@ void ModuleGame::iniciarMomies() {
|
||||
bool dimonis = info::ctx.num_piramide == 6;
|
||||
for (int i = 0; i < info::ctx.momies; i++) {
|
||||
if (this->momies == nullptr) {
|
||||
this->momies = new Momia(this->gfx, dimonis, x, y, this->sam);
|
||||
this->momies = new Momia(this->gfx, dimonis, x, y, this->sam.get());
|
||||
} else {
|
||||
this->momies->insertar(new Momia(this->gfx, dimonis, x, y, this->sam));
|
||||
this->momies->insertar(new Momia(this->gfx, dimonis, x, y, this->sam.get()));
|
||||
}
|
||||
x += 65;
|
||||
if (x == 345) {
|
||||
|
||||
Reference in New Issue
Block a user