forked from jaildesigner-jailgames/jaildoctors_dilemma
Resuelto el bug de quedarse atascado en una rampa al caer
This commit is contained in:
@@ -99,6 +99,8 @@ Player::Player(player_t player)
|
|||||||
#ifdef DEBUG
|
#ifdef DEBUG
|
||||||
rx = {0, 0, 0, 0};
|
rx = {0, 0, 0, 0};
|
||||||
ry = {0, 0, 0, 0};
|
ry = {0, 0, 0, 0};
|
||||||
|
debugColor = {0, 255, 0};
|
||||||
|
debugPoint = {0, 0};
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -128,7 +130,7 @@ void Player::render()
|
|||||||
SDL_RenderDrawPoint(renderer, underFeet[1].x, underFeet[1].y);
|
SDL_RenderDrawPoint(renderer, underFeet[1].x, underFeet[1].y);
|
||||||
|
|
||||||
// Pinta rectangulo del jugador
|
// Pinta rectangulo del jugador
|
||||||
SDL_SetRenderDrawColor(renderer, 0, 255, 0, 192);
|
SDL_SetRenderDrawColor(renderer, debugColor.r, debugColor.g, debugColor.b, 192);
|
||||||
SDL_Rect rect = getRect();
|
SDL_Rect rect = getRect();
|
||||||
SDL_RenderFillRect(renderer, &rect);
|
SDL_RenderFillRect(renderer, &rect);
|
||||||
SDL_SetRenderDrawColor(renderer, 0, 255, 255, 255);
|
SDL_SetRenderDrawColor(renderer, 0, 255, 255, 255);
|
||||||
@@ -144,6 +146,10 @@ void Player::render()
|
|||||||
{
|
{
|
||||||
SDL_RenderFillRect(renderer, &ry);
|
SDL_RenderFillRect(renderer, &ry);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Pinta el punto de debug
|
||||||
|
SDL_SetRenderDrawColor(renderer, rand() % 256, rand() % 256, rand() % 256, 255);
|
||||||
|
SDL_RenderDrawPoint(renderer, debugPoint.x, debugPoint.y);
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
@@ -293,14 +299,14 @@ void Player::checkState()
|
|||||||
vy = 0.0f;
|
vy = 0.0f;
|
||||||
jumpCounter = 0;
|
jumpCounter = 0;
|
||||||
fallCounter = 0;
|
fallCounter = 0;
|
||||||
/*if (!isOnFloor() && !isOnAutoSurface())
|
if (!isOnFloor() && !isOnAutoSurface() && !isOnDownSlope())
|
||||||
{
|
{
|
||||||
setState(s_falling);
|
setState(s_falling);
|
||||||
vx = 0.0f;
|
vx = 0.0f;
|
||||||
vy = maxVY;
|
vy = maxVY;
|
||||||
fallCounter++;
|
fallCounter++;
|
||||||
playFallSound();
|
playFallSound();
|
||||||
}*/
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
else if (state == s_jumping)
|
else if (state == s_jumping)
|
||||||
@@ -373,6 +379,10 @@ void Player::move()
|
|||||||
applyGravity(); // Aplica gravedad al jugador
|
applyGravity(); // Aplica gravedad al jugador
|
||||||
checkState(); // Comprueba el estado del jugador
|
checkState(); // Comprueba el estado del jugador
|
||||||
|
|
||||||
|
#ifdef DEBUG
|
||||||
|
debugColor = {0, 255, 0};
|
||||||
|
#endif
|
||||||
|
|
||||||
// Se mueve hacia la izquierda
|
// Se mueve hacia la izquierda
|
||||||
if (vx < 0.0f)
|
if (vx < 0.0f)
|
||||||
{
|
{
|
||||||
@@ -544,11 +554,18 @@ void Player::move()
|
|||||||
// Calcula la nueva posición
|
// Calcula la nueva posición
|
||||||
y = p - h;
|
y = p - h;
|
||||||
setState(s_standing);
|
setState(s_standing);
|
||||||
|
#ifdef DEBUG
|
||||||
|
debugColor = {255, 255, 0};
|
||||||
|
debugPoint = {(int)x + (w / 2), p};
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{ // No está saltando y no hay colisón con una rampa
|
{ // No está saltando y no hay colisón con una rampa
|
||||||
// Calcula la nueva posición
|
// Calcula la nueva posición
|
||||||
y += vy;
|
y += vy;
|
||||||
|
#ifdef DEBUG
|
||||||
|
debugColor = {255, 0, 0};
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
|||||||
@@ -89,8 +89,10 @@ public:
|
|||||||
int maxFallHeight; // Altura maxima permitida de caída.
|
int maxFallHeight; // Altura maxima permitida de caída.
|
||||||
|
|
||||||
#ifdef DEBUG
|
#ifdef DEBUG
|
||||||
SDL_Rect rx; // Rectangulo de desplazamiento para el modo debug
|
SDL_Rect rx; // Rectangulo de desplazamiento para el modo debug
|
||||||
SDL_Rect ry; // Rectangulo de desplazamiento para el modo debug
|
SDL_Rect ry; // Rectangulo de desplazamiento para el modo debug
|
||||||
|
color_t debugColor; // Color del recuadro de debug del jugador
|
||||||
|
SDL_Point debugPoint; // Punto para debug
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
// Comprueba las entradas y modifica variables
|
// Comprueba las entradas y modifica variables
|
||||||
|
|||||||
Reference in New Issue
Block a user