developers, developers!
This commit is contained in:
Binary file not shown.
|
Before Width: | Height: | Size: 428 B After Width: | Height: | Size: 583 B |
@@ -1,7 +1,7 @@
|
|||||||
# player animation
|
# player animation
|
||||||
tileSetFile: player.gif
|
tileSetFile: player.gif
|
||||||
frameWidth: 8
|
frameWidth: 12
|
||||||
frameHeight: 16
|
frameHeight: 24
|
||||||
|
|
||||||
animations:
|
animations:
|
||||||
- name: stand
|
- name: stand
|
||||||
|
|||||||
@@ -25,22 +25,22 @@ tilemap:
|
|||||||
- [210, 180, 210, 212, 210, 180, 210, 211, 212, 210, 180, 210, 210, 211, 210, 212, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42]
|
- [210, 180, 210, 212, 210, 180, 210, 211, 212, 210, 180, 210, 210, 211, 210, 212, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42]
|
||||||
- [163, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 163, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42]
|
- [163, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 163, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42]
|
||||||
- [42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42]
|
- [42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42]
|
||||||
- [42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33]
|
- [0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 2, 264, 264, 264, 264, 264, 264, 264, 264, 264, 264, 264, 264, 264, 264, 264]
|
||||||
- [42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 33, 33, 33, 33, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 33, 33, 33]
|
- [24, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 26, 33, 33, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1]
|
||||||
- [33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 33, 33]
|
- [48, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, 50, 33, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1]
|
||||||
- [33, 33, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 33, 33, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 33]
|
- [33, 33, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 33, 116, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1]
|
||||||
- [33, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 33, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 33]
|
- [33, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 116, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1]
|
||||||
- [33, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 33, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 33]
|
- [33, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 116, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1]
|
||||||
- [33, 33, 33, 33, 33, 33, 33, 33, 33, -1, -1, -1, -1, -1, -1, -1, 33, 137, 138, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 33]
|
- [7, 7, 7, 7, 7, 7, 7, 7, 8, -1, -1, -1, -1, -1, -1, -1, 116, 137, 138, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1]
|
||||||
- [33, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 33, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 33]
|
- [33, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 116, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1]
|
||||||
- [33, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 134, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 33]
|
- [33, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 116, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1]
|
||||||
- [33, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 134, -1, -1, -1, -1, -1, -1, -1, -1, -1, 33, 33, 33, 33, 33, 33]
|
- [33, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 116, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1]
|
||||||
- [33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 545, -1, -1, -1, -1, -1, 33, 33, 33, 33, 33, 33]
|
- [7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 8, 545, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1]
|
||||||
- [26, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 545, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1]
|
- [26, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 545, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1]
|
||||||
- [26, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 545, -1, -1, -1, -1, -1, -1, -1, -1, -1]
|
- [26, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 545, -1, -1, -1, -1, -1, -1, -1, -1, -1]
|
||||||
- [26, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 303, 303, -1, -1, -1, -1, -1, -1, -1]
|
- [26, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 303, 303, -1, -1, -1, -1, -1, -1, -1]
|
||||||
- [26, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1]
|
- [26, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1]
|
||||||
- [26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26]
|
- [51, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1]
|
||||||
|
|
||||||
# Enemigos en esta habitación
|
# Enemigos en esta habitación
|
||||||
enemies:
|
enemies:
|
||||||
|
|||||||
@@ -20,19 +20,19 @@ room:
|
|||||||
# Tilemap: 21 filas x 32 columnas @ 8px/tile
|
# Tilemap: 21 filas x 32 columnas @ 8px/tile
|
||||||
# Índices de tiles (-1 = vacío)
|
# Índices de tiles (-1 = vacío)
|
||||||
tilemap:
|
tilemap:
|
||||||
- [191, 191, 191, 191, 191, 191, 191, 191, 191, 191, 191, 191, 191, 191, 191, 191, 191, 191, 191, 191, 191, 191, 191, 191, 191, 191, 191, 42, 42, 42, 42, 42]
|
- [191, 191, 191, 191, 191, 191, 191, 191, 191, 191, 191, 191, 191, 191, 191, 191, 191, 191, 191, 191, 191, 191, 191, 191, 191, 191, 191, 48, 5, 25, 25, 25]
|
||||||
- [42, 165, 165, 166, 167, 165, 184, 166, 165, 184, 165, 165, 167, 165, 165, 166, 165, 165, 184, 165, 165, 165, 184, 166, 165, 165, 165, 184, 24, 24, 24, 24]
|
- [42, 165, 165, 166, 167, 165, 184, 166, 165, 184, 165, 165, 167, 165, 165, 166, 165, 165, 184, 165, 165, 165, 184, 166, 165, 165, 165, 184, 48, 49, 49, 49]
|
||||||
- [42, 42, 210, 211, 211, 210, 180, 210, 212, 210, 180, 210, 211, 212, 210, 180, 210, 210, 210, 210, 211, 212, 210, 180, 210, 212, 180, 210, -1, -1, -1, -1]
|
- [42, 42, 210, 211, 211, 210, 180, 210, 212, 210, 180, 210, 211, 212, 210, 180, 210, 210, 210, 210, 211, 212, 210, 180, 210, 212, 180, 210, -1, -1, -1, -1]
|
||||||
- [42, 42, 42, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1]
|
- [42, 42, 42, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1]
|
||||||
- [42, 42, 42, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 24, 24, 24, 24]
|
- [42, 42, 42, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 6, 1, 1, 1]
|
||||||
- [33, 33, 303, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 24, 24, 24]
|
- [33, 33, 303, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 48, 5, 25]
|
||||||
- [33, 33, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 302, 24, 24]
|
- [33, 33, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 302, 24, 25]
|
||||||
- [33, 33, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 24, 24]
|
- [33, 33, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 24, 25]
|
||||||
- [33, 33, -1, 412, 412, 412, 412, -1, -1, -1, -1, 412, 303, 412, 412, 412, -1, -1, -1, -1, 412, 303, 412, 412, 412, 412, 303, -1, -1, -1, 24, 24]
|
- [33, 33, -1, 412, 412, 412, 412, -1, -1, -1, -1, 412, 303, 412, 412, 412, -1, -1, -1, -1, 412, 303, 412, 412, 412, 412, 303, -1, -1, -1, 24, 25]
|
||||||
- [33, 33, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 24, 24]
|
- [33, 33, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 24, 25]
|
||||||
- [33, 33, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 410, 24, 24]
|
- [33, 33, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 410, 24, 25]
|
||||||
- [33, 33, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 24, 24]
|
- [33, 33, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 24, 25]
|
||||||
- [33, 33, 412, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 410, 24, 24]
|
- [33, 33, 412, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 410, 48, 49]
|
||||||
- [-1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1]
|
- [-1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1]
|
||||||
- [-1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1]
|
- [-1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1]
|
||||||
- [-1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1]
|
- [-1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1]
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
room:
|
room:
|
||||||
bgColor: 0
|
bgColor: 0
|
||||||
border: 1
|
border: 0
|
||||||
tileSetFile: standard.gif
|
tileSetFile: standard.gif
|
||||||
|
|
||||||
# Conexiones de la habitación (null = sin conexión)
|
# Conexiones de la habitación (null = sin conexión)
|
||||||
|
|||||||
@@ -64,7 +64,9 @@ void Player::handleInput() {
|
|||||||
wanna_go_ = Direction::NONE;
|
wanna_go_ = Direction::NONE;
|
||||||
}
|
}
|
||||||
|
|
||||||
wanna_jump_ = Input::get()->checkAction(InputAction::JUMP);
|
const bool JUMP_PRESSED = Input::get()->checkAction(InputAction::JUMP);
|
||||||
|
wanna_jump_ = JUMP_PRESSED && !jump_held_; // Solo en el flanco de pulsación
|
||||||
|
jump_held_ = JUMP_PRESSED;
|
||||||
wanna_down_ = Input::get()->checkAction(InputAction::DOWN);
|
wanna_down_ = Input::get()->checkAction(InputAction::DOWN);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -416,7 +418,7 @@ void Player::switchBorders() {
|
|||||||
void Player::applyGravity(float delta_time) {
|
void Player::applyGravity(float delta_time) {
|
||||||
if (state_ == State::ON_AIR) {
|
if (state_ == State::ON_AIR) {
|
||||||
// Si está subiendo y ha soltado el botón de salto, gravedad aumentada para cortar el salto
|
// Si está subiendo y ha soltado el botón de salto, gravedad aumentada para cortar el salto
|
||||||
const float GRAVITY = (vy_ < 0.0F && !wanna_jump_)
|
const float GRAVITY = (vy_ < 0.0F && !jump_held_)
|
||||||
? GRAVITY_FORCE * LOW_JUMP_GRAVITY_MULT
|
? GRAVITY_FORCE * LOW_JUMP_GRAVITY_MULT
|
||||||
: GRAVITY_FORCE;
|
: GRAVITY_FORCE;
|
||||||
vy_ += GRAVITY * delta_time;
|
vy_ += GRAVITY * delta_time;
|
||||||
@@ -582,15 +584,26 @@ void Player::setColor(Uint8 color) {
|
|||||||
|
|
||||||
// Actualiza los puntos de colisión
|
// Actualiza los puntos de colisión
|
||||||
void Player::updateColliderPoints() {
|
void Player::updateColliderPoints() {
|
||||||
const SDL_FRect RECT = getRect();
|
// 3 columnas × 4 filas: garantiza que cada tile de 8×8 que solape el jugador tenga al menos un punto
|
||||||
collider_points_[0] = {.x = RECT.x, .y = RECT.y};
|
const float L = x_;
|
||||||
collider_points_[1] = {.x = RECT.x + 7, .y = RECT.y};
|
const float M = x_ + (WIDTH / 2);
|
||||||
collider_points_[2] = {.x = RECT.x + 7, .y = RECT.y + 7};
|
const float R = x_ + WIDTH - 1;
|
||||||
collider_points_[3] = {.x = RECT.x, .y = RECT.y + 7};
|
const float Y0 = y_;
|
||||||
collider_points_[4] = {.x = RECT.x, .y = RECT.y + 8};
|
const float Y1 = y_ + 8;
|
||||||
collider_points_[5] = {.x = RECT.x + 7, .y = RECT.y + 8};
|
const float Y2 = y_ + 16;
|
||||||
collider_points_[6] = {.x = RECT.x + 7, .y = RECT.y + 15};
|
const float Y3 = y_ + HEIGHT - 1;
|
||||||
collider_points_[7] = {.x = RECT.x, .y = RECT.y + 15};
|
collider_points_[0] = {.x = L, .y = Y0};
|
||||||
|
collider_points_[1] = {.x = M, .y = Y0};
|
||||||
|
collider_points_[2] = {.x = R, .y = Y0};
|
||||||
|
collider_points_[3] = {.x = L, .y = Y1};
|
||||||
|
collider_points_[4] = {.x = M, .y = Y1};
|
||||||
|
collider_points_[5] = {.x = R, .y = Y1};
|
||||||
|
collider_points_[6] = {.x = L, .y = Y2};
|
||||||
|
collider_points_[7] = {.x = M, .y = Y2};
|
||||||
|
collider_points_[8] = {.x = R, .y = Y2};
|
||||||
|
collider_points_[9] = {.x = L, .y = Y3};
|
||||||
|
collider_points_[10] = {.x = M, .y = Y3};
|
||||||
|
collider_points_[11] = {.x = R, .y = Y3};
|
||||||
}
|
}
|
||||||
|
|
||||||
// Actualiza los puntos de los pies
|
// Actualiza los puntos de los pies
|
||||||
|
|||||||
@@ -36,7 +36,7 @@ class Player {
|
|||||||
static constexpr float HORIZONTAL_VELOCITY = 60.0F; // Velocidad horizontal objetivo en pixels/segundo
|
static constexpr float HORIZONTAL_VELOCITY = 60.0F; // Velocidad horizontal objetivo en pixels/segundo
|
||||||
static constexpr float HORIZONTAL_ACCEL = 500.0F; // Aceleración/deceleración horizontal en pixels/segundo² (inercia ligera)
|
static constexpr float HORIZONTAL_ACCEL = 500.0F; // Aceleración/deceleración horizontal en pixels/segundo² (inercia ligera)
|
||||||
static constexpr float MAX_VY = 160.0F; // Velocidad vertical máxima en pixels/segundo
|
static constexpr float MAX_VY = 160.0F; // Velocidad vertical máxima en pixels/segundo
|
||||||
static constexpr float JUMP_VELOCITY = -140.0F; // Velocidad inicial del salto en pixels/segundo
|
static constexpr float JUMP_VELOCITY = -170.0F; // Velocidad inicial del salto en pixels/segundo
|
||||||
static constexpr float GRAVITY_FORCE = 360.0F; // Fuerza de gravedad en pixels/segundo²
|
static constexpr float GRAVITY_FORCE = 360.0F; // Fuerza de gravedad en pixels/segundo²
|
||||||
static constexpr float LOW_JUMP_GRAVITY_MULT = 3.0F; // Multiplicador de gravedad al soltar el botón de salto (salto variable)
|
static constexpr float LOW_JUMP_GRAVITY_MULT = 3.0F; // Multiplicador de gravedad al soltar el botón de salto (salto variable)
|
||||||
|
|
||||||
@@ -87,8 +87,8 @@ class Player {
|
|||||||
|
|
||||||
private:
|
private:
|
||||||
// --- Constantes ---
|
// --- Constantes ---
|
||||||
static constexpr int WIDTH = 8; // Ancho del jugador
|
static constexpr int WIDTH = 12; // Ancho del jugador
|
||||||
static constexpr int HEIGHT = 16; // ALto del jugador
|
static constexpr int HEIGHT = 24; // Alto del jugador
|
||||||
static constexpr int MAX_FALLING_HEIGHT = Tile::SIZE * 4; // Altura maxima permitida de caída en pixels
|
static constexpr int MAX_FALLING_HEIGHT = Tile::SIZE * 4; // Altura maxima permitida de caída en pixels
|
||||||
|
|
||||||
// --- Objetos y punteros ---
|
// --- Objetos y punteros ---
|
||||||
@@ -105,6 +105,7 @@ class Player {
|
|||||||
Direction wanna_go_ = Direction::NONE;
|
Direction wanna_go_ = Direction::NONE;
|
||||||
bool wanna_jump_ = false;
|
bool wanna_jump_ = false;
|
||||||
bool wanna_down_ = false;
|
bool wanna_down_ = false;
|
||||||
|
bool jump_held_ = false; // true mientras la tecla de salto esté pulsada (para detectar flanco)
|
||||||
|
|
||||||
// --- Variables de estado ---
|
// --- Variables de estado ---
|
||||||
State state_ = State::ON_GROUND; // Estado en el que se encuentra el jugador. Util apara saber si está saltando o cayendo
|
State state_ = State::ON_GROUND; // Estado en el que se encuentra el jugador. Util apara saber si está saltando o cayendo
|
||||||
@@ -112,7 +113,7 @@ class Player {
|
|||||||
|
|
||||||
// --- Variables de colisión ---
|
// --- Variables de colisión ---
|
||||||
SDL_FRect collider_box_{}; // Caja de colisión con los enemigos u objetos
|
SDL_FRect collider_box_{}; // Caja de colisión con los enemigos u objetos
|
||||||
std::array<SDL_FPoint, 8> collider_points_{}; // Puntos de colisión con el mapa
|
std::array<SDL_FPoint, 12> collider_points_{}; // Puntos de colisión con el mapa (3 columnas × 4 filas, gap ≤ 8px)
|
||||||
SDL_FPoint under_left_foot_ = {.x = 0.0F, .y = 0.0F}; // El punto bajo la esquina inferior izquierda del jugador
|
SDL_FPoint under_left_foot_ = {.x = 0.0F, .y = 0.0F}; // El punto bajo la esquina inferior izquierda del jugador
|
||||||
SDL_FPoint under_right_foot_ = {.x = 0.0F, .y = 0.0F}; // El punto bajo la esquina inferior derecha del jugador
|
SDL_FPoint under_right_foot_ = {.x = 0.0F, .y = 0.0F}; // El punto bajo la esquina inferior derecha del jugador
|
||||||
const LineDiagonal* current_slope_{nullptr}; // Rampa actual sobe la que está el jugador
|
const LineDiagonal* current_slope_{nullptr}; // Rampa actual sobe la que está el jugador
|
||||||
|
|||||||
@@ -26,8 +26,6 @@ Room::Room(const std::string& room_path, std::shared_ptr<Scoreboard::Data> data)
|
|||||||
item_manager_ = std::make_unique<ItemManager>(room->number, data_);
|
item_manager_ = std::make_unique<ItemManager>(room->number, data_);
|
||||||
|
|
||||||
initializeRoom(*room);
|
initializeRoom(*room);
|
||||||
openTheJail(); // Abre la Jail si se da el caso
|
|
||||||
|
|
||||||
// Crea el mapa de colisiones (necesita tile_map_, tile_set_width_, conveyor_belt_direction_)
|
// Crea el mapa de colisiones (necesita tile_map_, tile_set_width_, conveyor_belt_direction_)
|
||||||
collision_map_ = std::make_unique<CollisionMap>(tile_map_, tile_set_width_, conveyor_belt_direction_);
|
collision_map_ = std::make_unique<CollisionMap>(tile_map_, tile_set_width_, conveyor_belt_direction_);
|
||||||
|
|
||||||
@@ -80,25 +78,6 @@ void Room::initializeRoom(const Data& room) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Abre la jail para poder entrar
|
|
||||||
void Room::openTheJail() { // NOLINT(readability-convert-member-functions-to-static)
|
|
||||||
if (data_->jail_is_open && number_ == Defaults::Game::Room::END_ROOM) {
|
|
||||||
// Elimina el último enemigo (Bry debe ser el último enemigo definido en el fichero)
|
|
||||||
if (!enemy_manager_->isEmpty()) {
|
|
||||||
enemy_manager_->removeLastEnemy();
|
|
||||||
}
|
|
||||||
|
|
||||||
// Abre las puertas
|
|
||||||
constexpr int TILE_A = 16 + (13 * 32);
|
|
||||||
constexpr int TILE_B = 16 + (14 * 32);
|
|
||||||
if (TILE_A < tile_map_.size()) {
|
|
||||||
tile_map_[TILE_A] = -1;
|
|
||||||
}
|
|
||||||
if (TILE_B < tile_map_.size()) {
|
|
||||||
tile_map_[TILE_B] = -1;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// Dibuja el mapa en pantalla
|
// Dibuja el mapa en pantalla
|
||||||
void Room::renderMap() {
|
void Room::renderMap() {
|
||||||
|
|||||||
@@ -137,5 +137,4 @@ class Room {
|
|||||||
|
|
||||||
// --- Funciones ---
|
// --- Funciones ---
|
||||||
void initializeRoom(const Data& room); // Inicializa los valores
|
void initializeRoom(const Data& room); // Inicializa los valores
|
||||||
void openTheJail(); // Abre la jail para poder entrar
|
|
||||||
};
|
};
|
||||||
@@ -598,10 +598,6 @@ void Game::handleDebugEvents(const SDL_Event& event) { // NOLINT(readability-co
|
|||||||
player_->setColor();
|
player_->setColor();
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case SDLK_3:
|
|
||||||
toggleCheat(Options::cheats.jail_is_open, Locale::get()->get("game.cheat_jail_open")); // NOLINT(readability-static-accessed-through-instance)
|
|
||||||
break;
|
|
||||||
|
|
||||||
case SDLK_7:
|
case SDLK_7:
|
||||||
Notifier::get()->show({Locale::get()->get("achievements.header"), Locale::get()->get("achievements.c11")}, Notifier::Style::CHEEVO, -1, false, "F7"); // NOLINT(readability-static-accessed-through-instance)
|
Notifier::get()->show({Locale::get()->get("achievements.header"), Locale::get()->get("achievements.c11")}, Notifier::Style::CHEEVO, -1, false, "F7"); // NOLINT(readability-static-accessed-through-instance)
|
||||||
break;
|
break;
|
||||||
|
|||||||
Reference in New Issue
Block a user