refactor: JI_* a Ji:: i JG_* a Jg::
This commit is contained in:
@@ -38,7 +38,7 @@ void Bola::update() {
|
||||
}
|
||||
|
||||
// Augmentem el frame
|
||||
if (JG_GetCycleCounter() % this->cycles_per_frame == 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;
|
||||
|
||||
@@ -32,7 +32,7 @@ Engendro::Engendro(Jd8::Surface gfx, Uint16 x, Uint16 y)
|
||||
auto Engendro::update() -> bool {
|
||||
bool mort = false;
|
||||
|
||||
if (JG_GetCycleCounter() % this->cycles_per_frame == 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;
|
||||
|
||||
@@ -72,13 +72,13 @@ void Mapa::update() {
|
||||
}
|
||||
|
||||
if (this->porta_oberta && sam->x == 150 && sam->y == 30) {
|
||||
if (JI_KeyPressed(SDL_SCANCODE_UP)) {
|
||||
if (Ji::keyPressed(SDL_SCANCODE_UP)) {
|
||||
this->sam->o = 4;
|
||||
this->sam->y -= 15;
|
||||
}
|
||||
}
|
||||
|
||||
if (JG_GetCycleCounter() % 8 == 0) {
|
||||
if (Jg::getCycleCounter() % 8 == 0) {
|
||||
this->frame_torxes++;
|
||||
this->frame_torxes = this->frame_torxes % 4;
|
||||
}
|
||||
|
||||
@@ -9,7 +9,7 @@
|
||||
|
||||
ModuleGame::ModuleGame() {
|
||||
this->gfx_ = Jd8::loadSurface(info::ctx.pepe_activat ? "gfx/frames2.gif" : "gfx/frames.gif");
|
||||
JG_SetUpdateTicks(10);
|
||||
Jg::setUpdateTicks(10);
|
||||
|
||||
this->sam_ = std::make_unique<Prota>(this->gfx_);
|
||||
this->mapa_ = std::make_unique<Mapa>(this->gfx_, this->sam_.get());
|
||||
@@ -92,7 +92,7 @@ void ModuleGame::tick(int delta_ms) {
|
||||
}
|
||||
|
||||
auto ModuleGame::nextState() const -> int {
|
||||
if (JG_Quitting()) {
|
||||
if (Jg::quitting()) {
|
||||
return -1;
|
||||
}
|
||||
if (info::ctx.num_habitacio == 1 ||
|
||||
@@ -133,8 +133,8 @@ void ModuleGame::draw() {
|
||||
}
|
||||
|
||||
void ModuleGame::update() {
|
||||
if (JG_ShouldUpdate()) {
|
||||
JI_Update();
|
||||
if (Jg::shouldUpdate()) {
|
||||
Ji::update();
|
||||
|
||||
this->final_ = this->sam_->update();
|
||||
const auto erased = std::erase_if(this->momies_, [](auto& m) { return m->update(); });
|
||||
@@ -148,14 +148,14 @@ void ModuleGame::update() {
|
||||
info::ctx.momies++;
|
||||
}
|
||||
|
||||
if (JI_CheatActivated("reviu")) {
|
||||
if (Ji::cheatActivated("reviu")) {
|
||||
info::ctx.vida = 5;
|
||||
}
|
||||
if (JI_CheatActivated("alone")) {
|
||||
if (Ji::cheatActivated("alone")) {
|
||||
this->momies_.clear();
|
||||
info::ctx.momies = 0;
|
||||
}
|
||||
if (JI_CheatActivated("obert")) {
|
||||
if (Ji::cheatActivated("obert")) {
|
||||
for (int i = 0; i < 16; i++) {
|
||||
this->mapa_->tombes[i].costat[0] = true;
|
||||
this->mapa_->tombes[i].costat[1] = true;
|
||||
@@ -165,8 +165,8 @@ void ModuleGame::update() {
|
||||
}
|
||||
}
|
||||
|
||||
if (JI_KeyPressed(SDL_SCANCODE_ESCAPE)) {
|
||||
JG_QuitSignal();
|
||||
if (Ji::keyPressed(SDL_SCANCODE_ESCAPE)) {
|
||||
Jg::quitSignal();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -16,14 +16,14 @@
|
||||
// Escena de gameplay pur. Reemplaça el vell `Go()` bloquejant amb
|
||||
// l'interfície `scenes::Scene` tick-based: `onEnter()` arranca la
|
||||
// música i un fade-in, el `tick()` avança un frame (Draw + Update
|
||||
// gated per JG_ShouldUpdate), i quan la partida acaba fa un fade-out
|
||||
// gated per Jg::shouldUpdate), i quan la partida acaba fa un fade-out
|
||||
// abans de retornar el next state.
|
||||
//
|
||||
// Tres fases internes:
|
||||
// 1. FADING_IN — fade-in 32 passos mentre el render segueix viu.
|
||||
// 2. Playing — gameplay normal; `final_` es setja quan el prota mor
|
||||
// o canvia de sala. `Update()` només avança cada 10 ms
|
||||
// via `JG_ShouldUpdate` (ticker fix del jail).
|
||||
// via `Jg::shouldUpdate` (ticker fix del jail).
|
||||
// 3. FADING_OUT — fade-out 32 passos mantenint l'últim frame visible
|
||||
// (substituïx el `JD8_FadeOut` bloquejant que feia el
|
||||
// destructor legacy).
|
||||
@@ -51,7 +51,7 @@ class ModuleGame : public scenes::Scene {
|
||||
};
|
||||
|
||||
void draw(); // render a `screen`; no crida Jd8::flip (ho fa el caller)
|
||||
void update(); // gated per JG_ShouldUpdate
|
||||
void update(); // gated per Jg::shouldUpdate
|
||||
|
||||
void iniciarMomies();
|
||||
void applyFinalTransitions() const; // muta info::ctx quan final_ passa a !=0
|
||||
|
||||
@@ -74,7 +74,7 @@ void Momia::draw() {
|
||||
Sprite::draw();
|
||||
|
||||
if (info::ctx.num_piramide == 4) {
|
||||
if ((JG_GetCycleCounter() % 40) < 20) {
|
||||
if ((Jg::getCycleCounter() % 40) < 20) {
|
||||
Jd8::blitCK(this->x, this->y, this->gfx, 220, 80, 15, 15, 255);
|
||||
} else {
|
||||
Jd8::blitCK(this->x, this->y, this->gfx, 235, 80, 15, 15, 255);
|
||||
@@ -93,7 +93,7 @@ auto Momia::update() -> bool {
|
||||
return morta;
|
||||
}
|
||||
|
||||
if (this->sam->o < 4 && (this->dimoni || info::ctx.num_piramide == 5 || JG_GetCycleCounter() % 2 == 0)) {
|
||||
if (this->sam->o < 4 && (this->dimoni || info::ctx.num_piramide == 5 || Jg::getCycleCounter() % 2 == 0)) {
|
||||
if ((this->x - 20) % 65 == 0 && (this->y - 30) % 35 == 0) {
|
||||
if (this->dimoni) {
|
||||
if (rand() % 2 == 0) {
|
||||
@@ -147,7 +147,7 @@ auto Momia::update() -> bool {
|
||||
break;
|
||||
}
|
||||
|
||||
if (JG_GetCycleCounter() % this->cycles_per_frame == 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;
|
||||
|
||||
@@ -91,7 +91,7 @@ void Prota::draw() {
|
||||
Sprite::draw();
|
||||
|
||||
if (info::ctx.num_piramide == 4 && this->o != 4) {
|
||||
if ((JG_GetCycleCounter() % 40) < 20) {
|
||||
if ((Jg::getCycleCounter() % 40) < 20) {
|
||||
Jd8::blitCK(this->x, this->y, this->gfx, 220, 80, 15, 15, 255);
|
||||
} else {
|
||||
Jd8::blitCK(this->x, this->y, this->gfx, 235, 80, 15, 15, 255);
|
||||
@@ -104,25 +104,25 @@ auto Prota::update() -> Uint8 {
|
||||
|
||||
if (this->o < 4) {
|
||||
Uint8 dir = 4;
|
||||
if (JI_KeyPressed(SDL_SCANCODE_DOWN)) {
|
||||
if (Ji::keyPressed(SDL_SCANCODE_DOWN)) {
|
||||
if ((this->x - 20) % 65 == 0) {
|
||||
this->o = 0;
|
||||
}
|
||||
dir = this->o;
|
||||
}
|
||||
if (JI_KeyPressed(SDL_SCANCODE_UP)) {
|
||||
if (Ji::keyPressed(SDL_SCANCODE_UP)) {
|
||||
if ((this->x - 20) % 65 == 0) {
|
||||
this->o = 1;
|
||||
}
|
||||
dir = this->o;
|
||||
}
|
||||
if (JI_KeyPressed(SDL_SCANCODE_RIGHT)) {
|
||||
if (Ji::keyPressed(SDL_SCANCODE_RIGHT)) {
|
||||
if ((this->y - 30) % 35 == 0) {
|
||||
this->o = 2;
|
||||
}
|
||||
dir = this->o;
|
||||
}
|
||||
if (JI_KeyPressed(SDL_SCANCODE_LEFT)) {
|
||||
if (Ji::keyPressed(SDL_SCANCODE_LEFT)) {
|
||||
if ((this->y - 30) % 35 == 0) {
|
||||
this->o = 3;
|
||||
}
|
||||
@@ -161,7 +161,7 @@ auto Prota::update() -> Uint8 {
|
||||
if (this->frame_pejades == 15) {
|
||||
this->frame_pejades = 0;
|
||||
}
|
||||
if (JG_GetCycleCounter() % this->cycles_per_frame == 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;
|
||||
@@ -170,7 +170,7 @@ auto Prota::update() -> Uint8 {
|
||||
}
|
||||
eixir = 0U;
|
||||
} else {
|
||||
if (JG_GetCycleCounter() % this->cycles_per_frame == 0) {
|
||||
if (Jg::getCycleCounter() % this->cycles_per_frame == 0) {
|
||||
this->cur_frame++;
|
||||
if (this->cur_frame == entitat.animacions[this->o].frames.size()) {
|
||||
if (this->o == 4) {
|
||||
|
||||
@@ -48,7 +48,7 @@ namespace scenes {
|
||||
break;
|
||||
|
||||
case Phase::Showing:
|
||||
if (JI_AnyKey()) {
|
||||
if (Ji::anyKey()) {
|
||||
remaining_ms_ = 0;
|
||||
} else {
|
||||
remaining_ms_ -= delta_ms;
|
||||
|
||||
@@ -29,7 +29,7 @@ namespace {
|
||||
};
|
||||
|
||||
constexpr int CONTADOR_MAX = 3100; // ~62 s de crèdits a 20 ms/tick
|
||||
constexpr int TICK_MS = 20; // JG_SetUpdateTicks heretat del doSlides previ
|
||||
constexpr int TICK_MS = 20; // Jg::setUpdateTicks heretat del doSlides previ
|
||||
constexpr int BG_INDEX = 255;
|
||||
|
||||
} // namespace
|
||||
@@ -111,7 +111,7 @@ namespace scenes {
|
||||
switch (phase_) {
|
||||
case Phase::Rolling: {
|
||||
// Avancem el contador en passos discrets de 20 ms, igual
|
||||
// que feia JG_ShouldUpdate(20) al vell doCredits.
|
||||
// que feia Jg::shouldUpdate(20) al vell doCredits.
|
||||
contador_acc_ms_ += delta_ms;
|
||||
while (contador_acc_ms_ >= TICK_MS) {
|
||||
contador_acc_ms_ -= TICK_MS;
|
||||
@@ -121,7 +121,7 @@ namespace scenes {
|
||||
coche_.tick(delta_ms);
|
||||
render();
|
||||
|
||||
if (JI_AnyKey() || contador_ >= CONTADOR_MAX) {
|
||||
if (Ji::anyKey() || contador_ >= CONTADOR_MAX) {
|
||||
writeTrickIni();
|
||||
fade_.startFadeOut();
|
||||
phase_ = Phase::FadingOut;
|
||||
|
||||
@@ -137,7 +137,7 @@ namespace scenes {
|
||||
// TOTA la intro (inclou saltar la fase de sprites). Durant Sprites
|
||||
// deixem que la sub-escena gestione el seu propi skip (que a més
|
||||
// respecta la fase "final" no skippable de la variant 0).
|
||||
if (phase_ != Phase::Sprites && phase_ != Phase::Done && JI_AnyKey()) {
|
||||
if (phase_ != Phase::Sprites && phase_ != Phase::Done && Ji::anyKey()) {
|
||||
info::ctx.num_piramide = 0;
|
||||
phase_ = Phase::Done;
|
||||
return;
|
||||
|
||||
@@ -7,7 +7,7 @@
|
||||
|
||||
namespace {
|
||||
|
||||
// Timings idèntics als del vell `doIntro()`: el JG_SetUpdateTicks(1000)
|
||||
// Timings idèntics als del vell `doIntro()`: el Jg::setUpdateTicks(1000)
|
||||
// inicial, (100) per a les 3 primeres lletres (J, A, I), (200) per a
|
||||
// "JAIL" i el seu clear, (100) per a les 4 lletres centrals
|
||||
// (G, A, M, E) i (200) per a la resta fins al cicle de paleta.
|
||||
@@ -152,7 +152,7 @@ namespace scenes {
|
||||
// (inclou saltar la fase de sprites). Durant Sprites deixem que
|
||||
// la sub-escena gestione el seu propi skip internament, que a més
|
||||
// respecta la fase "final" no skippable de la variant 0.
|
||||
if (phase_ != Phase::Sprites && phase_ != Phase::Done && JI_AnyKey()) {
|
||||
if (phase_ != Phase::Sprites && phase_ != Phase::Done && Ji::anyKey()) {
|
||||
info::ctx.num_piramide = 0;
|
||||
phase_ = Phase::Done;
|
||||
return;
|
||||
|
||||
@@ -9,7 +9,7 @@
|
||||
|
||||
namespace {
|
||||
|
||||
// Duració d'un pas. El vell doIntroSprites feia JG_SetUpdateTicks(20);
|
||||
// Duració d'un pas. El vell doIntroSprites feia Jg::setUpdateTicks(20);
|
||||
// cada iteració del seu for (i) consumia un tick de 20 ms.
|
||||
constexpr int TICK_MS = 20;
|
||||
|
||||
@@ -346,7 +346,7 @@ namespace scenes {
|
||||
// Skip per tecla. Durant la fase marcada com a no skippable (només
|
||||
// v0Final al vell codi) s'ignora — preserva la semàntica del vell
|
||||
// bucle final de la variant 0 que no cridava wait_frame_or_skip.
|
||||
if (phases[phase_].skippable && JI_AnyKey()) {
|
||||
if (phases[phase_].skippable && Ji::anyKey()) {
|
||||
done_ = true;
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -98,9 +98,9 @@ namespace scenes {
|
||||
// Qualsevol tecla tanca el menú. Llegim 'P' explícitament abans
|
||||
// de reiniciar el flag de input perquè `info::ctx.pepe_activat`
|
||||
// reflecteixca si l'usuari estava polsant P al moment d'eixir.
|
||||
if (JI_AnyKey() || JI_KeyPressed(SDL_SCANCODE_P)) {
|
||||
info::ctx.pepe_activat = JI_KeyPressed(SDL_SCANCODE_P);
|
||||
JI_DisableKeyboard(60);
|
||||
if (Ji::anyKey() || Ji::keyPressed(SDL_SCANCODE_P)) {
|
||||
info::ctx.pepe_activat = Ji::keyPressed(SDL_SCANCODE_P);
|
||||
Ji::disableKeyboard(60);
|
||||
info::ctx.num_piramide = 1;
|
||||
fade_.startFadeOut();
|
||||
phase_ = Phase::FadingOut;
|
||||
|
||||
@@ -11,7 +11,7 @@ namespace scenes {
|
||||
|
||||
void MortScene::onEnter() {
|
||||
playMusic("music/mort.ogg");
|
||||
JI_DisableKeyboard(60);
|
||||
Ji::disableKeyboard(60);
|
||||
info::ctx.vida = 5;
|
||||
|
||||
gfx_ = SurfaceHandle("gfx/gameover.gif");
|
||||
@@ -38,7 +38,7 @@ namespace scenes {
|
||||
break;
|
||||
|
||||
case Phase::Showing:
|
||||
if (JI_AnyKey()) {
|
||||
if (Ji::anyKey()) {
|
||||
remaining_ms_ = 0;
|
||||
} else {
|
||||
remaining_ms_ -= delta_ms;
|
||||
|
||||
@@ -12,7 +12,7 @@
|
||||
|
||||
namespace {
|
||||
|
||||
constexpr int TICK_MS = 20; // JG_SetUpdateTicks(20) del vell doSecreta
|
||||
constexpr int TICK_MS = 20; // Jg::setUpdateTicks(20) del vell doSecreta
|
||||
|
||||
// Durades per fase, derivades dels contador-thresholds del vell:
|
||||
// tomba1 scroll: 127 passos (contador 1→128) × 20ms
|
||||
@@ -85,7 +85,7 @@ namespace scenes {
|
||||
// Skip per tecla (després del fade inicial, no mentre). Salta
|
||||
// directament al FinalFadeOut. Mateix patró que el vell, on
|
||||
// qualsevol tecla sortia del loop.
|
||||
if (!skip_triggered_ && phase_ != Phase::InitialFadeOut && JI_AnyKey()) {
|
||||
if (!skip_triggered_ && phase_ != Phase::InitialFadeOut && Ji::anyKey()) {
|
||||
skip_triggered_ = true;
|
||||
beginFinalFade();
|
||||
}
|
||||
|
||||
@@ -103,7 +103,7 @@ namespace scenes {
|
||||
// Skip: qualsevol tecla salta directament al fade final. Per fidelitat
|
||||
// al vell doSlides, el skip NO atura la música explícitament — només
|
||||
// el final natural crida Ja::fadeOutMusic (beginFinalFade() distingeix).
|
||||
if (!skip_triggered_ && JI_AnyKey()) {
|
||||
if (!skip_triggered_ && Ji::anyKey()) {
|
||||
skip_triggered_ = true;
|
||||
if (num_piramide_at_start_ != 7) {
|
||||
Audio::get()->fadeOutMusic(250);
|
||||
|
||||
Reference in New Issue
Block a user