tidy-fix automàtic (sense naming)
This commit is contained in:
+59
-27
@@ -1,6 +1,6 @@
|
||||
#include "game/prota.hpp"
|
||||
|
||||
#include <stdlib.h>
|
||||
#include <cstdlib>
|
||||
|
||||
#include "core/jail/jgame.hpp"
|
||||
#include "core/jail/jinput.hpp"
|
||||
@@ -14,7 +14,9 @@ Prota::Prota(JD8_Surface gfx)
|
||||
Frame f;
|
||||
f.w = 15;
|
||||
f.h = 15;
|
||||
if (info::ctx.num_piramide == 4) f.h -= 5;
|
||||
if (info::ctx.num_piramide == 4) {
|
||||
f.h -= 5;
|
||||
}
|
||||
f.x = x * 15;
|
||||
f.y = 20 + (y * 15);
|
||||
entitat.frames.push_back(f);
|
||||
@@ -26,7 +28,9 @@ Prota::Prota(JD8_Surface gfx)
|
||||
Frame f;
|
||||
f.w = 15;
|
||||
f.h = 30;
|
||||
if (info::ctx.num_piramide == 4) f.h -= 5;
|
||||
if (info::ctx.num_piramide == 4) {
|
||||
f.h -= 5;
|
||||
}
|
||||
f.x = x;
|
||||
f.y = y;
|
||||
entitat.frames.push_back(f);
|
||||
@@ -38,7 +42,9 @@ Prota::Prota(JD8_Surface gfx)
|
||||
Frame f;
|
||||
f.w = 15;
|
||||
f.h = 15;
|
||||
if (info::ctx.num_piramide == 4) f.h -= 5;
|
||||
if (info::ctx.num_piramide == 4) {
|
||||
f.h -= 5;
|
||||
}
|
||||
f.x = x;
|
||||
f.y = y;
|
||||
entitat.frames.push_back(f);
|
||||
@@ -48,23 +54,29 @@ Prota::Prota(JD8_Surface gfx)
|
||||
entitat.animacions.resize(6);
|
||||
for (int i = 0; i < 4; i++) {
|
||||
entitat.animacions[i].frames = {
|
||||
static_cast<Uint8>(0 + i * 5),
|
||||
static_cast<Uint8>(1 + i * 5),
|
||||
static_cast<Uint8>(2 + i * 5),
|
||||
static_cast<Uint8>(1 + i * 5),
|
||||
static_cast<Uint8>(0 + i * 5),
|
||||
static_cast<Uint8>(3 + i * 5),
|
||||
static_cast<Uint8>(4 + i * 5),
|
||||
static_cast<Uint8>(3 + i * 5),
|
||||
static_cast<Uint8>(0 + (i * 5)),
|
||||
static_cast<Uint8>(1 + (i * 5)),
|
||||
static_cast<Uint8>(2 + (i * 5)),
|
||||
static_cast<Uint8>(1 + (i * 5)),
|
||||
static_cast<Uint8>(0 + (i * 5)),
|
||||
static_cast<Uint8>(3 + (i * 5)),
|
||||
static_cast<Uint8>(4 + (i * 5)),
|
||||
static_cast<Uint8>(3 + (i * 5)),
|
||||
};
|
||||
}
|
||||
|
||||
entitat.animacions[4].frames.resize(50);
|
||||
for (int i = 0; i < 50; i++) entitat.animacions[4].frames[i] = i + 20;
|
||||
for (int i = 0; i < 50; i++) {
|
||||
entitat.animacions[4].frames[i] = i + 20;
|
||||
}
|
||||
|
||||
entitat.animacions[5].frames.resize(48);
|
||||
for (int i = 0; i < 12; i++) entitat.animacions[5].frames[i] = i + 70;
|
||||
for (int i = 12; i < 48; i++) entitat.animacions[5].frames[i] = 81;
|
||||
for (int i = 0; i < 12; i++) {
|
||||
entitat.animacions[5].frames[i] = i + 70;
|
||||
}
|
||||
for (int i = 12; i < 48; i++) {
|
||||
entitat.animacions[5].frames[i] = 81;
|
||||
}
|
||||
|
||||
cur_frame = 0;
|
||||
x = 150;
|
||||
@@ -87,40 +99,56 @@ void Prota::draw() {
|
||||
}
|
||||
}
|
||||
|
||||
Uint8 Prota::update() {
|
||||
auto Prota::update() -> Uint8 {
|
||||
Uint8 eixir = 0;
|
||||
|
||||
if (this->o < 4) {
|
||||
Uint8 dir = 4;
|
||||
if (JI_KeyPressed(SDL_SCANCODE_DOWN)) {
|
||||
if ((this->x - 20) % 65 == 0) this->o = 0;
|
||||
if ((this->x - 20) % 65 == 0) {
|
||||
this->o = 0;
|
||||
}
|
||||
dir = this->o;
|
||||
}
|
||||
if (JI_KeyPressed(SDL_SCANCODE_UP)) {
|
||||
if ((this->x - 20) % 65 == 0) this->o = 1;
|
||||
if ((this->x - 20) % 65 == 0) {
|
||||
this->o = 1;
|
||||
}
|
||||
dir = this->o;
|
||||
}
|
||||
if (JI_KeyPressed(SDL_SCANCODE_RIGHT)) {
|
||||
if ((this->y - 30) % 35 == 0) this->o = 2;
|
||||
if ((this->y - 30) % 35 == 0) {
|
||||
this->o = 2;
|
||||
}
|
||||
dir = this->o;
|
||||
}
|
||||
if (JI_KeyPressed(SDL_SCANCODE_LEFT)) {
|
||||
if ((this->y - 30) % 35 == 0) this->o = 3;
|
||||
if ((this->y - 30) % 35 == 0) {
|
||||
this->o = 3;
|
||||
}
|
||||
dir = this->o;
|
||||
}
|
||||
|
||||
switch (dir) {
|
||||
case 0:
|
||||
if (this->y < 170) this->y++;
|
||||
if (this->y < 170) {
|
||||
this->y++;
|
||||
}
|
||||
break;
|
||||
case 1:
|
||||
if (this->y > 30) this->y--;
|
||||
if (this->y > 30) {
|
||||
this->y--;
|
||||
}
|
||||
break;
|
||||
case 2:
|
||||
if (this->x < 280) this->x++;
|
||||
if (this->x < 280) {
|
||||
this->x++;
|
||||
}
|
||||
break;
|
||||
case 3:
|
||||
if (this->x > 20) this->x--;
|
||||
if (this->x > 20) {
|
||||
this->x--;
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
@@ -128,13 +156,17 @@ Uint8 Prota::update() {
|
||||
this->cur_frame = 0;
|
||||
} else {
|
||||
this->frame_pejades++;
|
||||
if (this->frame_pejades == 15) this->frame_pejades = 0;
|
||||
if (this->frame_pejades == 15) {
|
||||
this->frame_pejades = 0;
|
||||
}
|
||||
if (JG_GetCycleCounter() % this->cycles_per_frame == 0) {
|
||||
this->cur_frame++;
|
||||
if (this->cur_frame == entitat.animacions[this->o].frames.size()) this->cur_frame = 0;
|
||||
if (this->cur_frame == entitat.animacions[this->o].frames.size()) {
|
||||
this->cur_frame = 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
eixir = false;
|
||||
eixir = 0u;
|
||||
} else {
|
||||
if (JG_GetCycleCounter() % this->cycles_per_frame == 0) {
|
||||
this->cur_frame++;
|
||||
|
||||
Reference in New Issue
Block a user