forked from jaildesigner-jailgames/jaildoctors_dilemma
Terminadas las nuevas colisiones. Ya no se detiene al colisionar horizontalmente
This commit is contained in:
@@ -7,6 +7,7 @@ Game::Game(SDL_Renderer *renderer, Screen *screen, Asset *asset, Input *input)
|
|||||||
clock = SDL_GetTicks();
|
clock = SDL_GetTicks();
|
||||||
currentRoom = "01.room";
|
currentRoom = "01.room";
|
||||||
spawnPoint = {2 * 8, 12 * 8, 0, 0, 0, s_standing, SDL_FLIP_NONE};
|
spawnPoint = {2 * 8, 12 * 8, 0, 0, 0, s_standing, SDL_FLIP_NONE};
|
||||||
|
spawnPoint = {154, 72, 0, 0, 0, s_standing, SDL_FLIP_NONE};
|
||||||
debug = true;
|
debug = true;
|
||||||
|
|
||||||
// Copia los punteros
|
// Copia los punteros
|
||||||
|
|||||||
@@ -244,18 +244,20 @@ void Player::move()
|
|||||||
{ // Bajando
|
{ // Bajando
|
||||||
y -= ((int)y + h) % tileSize;
|
y -= ((int)y + h) % tileSize;
|
||||||
state = s_standing;
|
state = s_standing;
|
||||||
|
vy = 0.0f;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{ // Subiendo
|
{ // Subiendo
|
||||||
y += tileSize - ((int)y % tileSize);
|
y += tileSize - ((int)y % tileSize);
|
||||||
state = s_falling;
|
state = s_falling;
|
||||||
|
vy = maxVY;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
// Si no colisiona con los muros, haz comprobaciones extra
|
// Si no colisiona con los muros, haz comprobaciones extra
|
||||||
{
|
{
|
||||||
const int a = (lastPosition.y + h) / tileSize;
|
const int a = (lastPosition.y + h - 1) / tileSize;
|
||||||
const int b = ((int)y + h) / tileSize;
|
const int b = ((int)y + h - 1) / tileSize;
|
||||||
const bool tile_change = a != b;
|
const bool tile_change = a != b;
|
||||||
|
|
||||||
bool going_down = vy >= 0.0f;
|
bool going_down = vy >= 0.0f;
|
||||||
@@ -268,6 +270,7 @@ void Player::move()
|
|||||||
if (isOnFloor())
|
if (isOnFloor())
|
||||||
{ // Y deja al jugador de pie
|
{ // Y deja al jugador de pie
|
||||||
state = s_standing;
|
state = s_standing;
|
||||||
|
vy = 0.0f;
|
||||||
|
|
||||||
// Si ademas ha habido un cambio de tile recoloca al jugador
|
// Si ademas ha habido un cambio de tile recoloca al jugador
|
||||||
if (tile_change)
|
if (tile_change)
|
||||||
@@ -280,6 +283,7 @@ void Player::move()
|
|||||||
else if (state != s_jumping)
|
else if (state != s_jumping)
|
||||||
{
|
{
|
||||||
state = s_falling;
|
state = s_falling;
|
||||||
|
vy = maxVY;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -292,6 +296,7 @@ void Player::move()
|
|||||||
if (state != s_jumping)
|
if (state != s_jumping)
|
||||||
{
|
{
|
||||||
state = s_falling;
|
state = s_falling;
|
||||||
|
vy = maxVY;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Si está alineado con el tile mira el suelo (para que no lo mire si está
|
// Si está alineado con el tile mira el suelo (para que no lo mire si está
|
||||||
@@ -301,6 +306,7 @@ void Player::move()
|
|||||||
if (isOnFloor())
|
if (isOnFloor())
|
||||||
{
|
{
|
||||||
state = s_standing;
|
state = s_standing;
|
||||||
|
vy = 0.0f;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -334,6 +340,7 @@ void Player::checkJumpEnd()
|
|||||||
if (y >= jump_ini)
|
if (y >= jump_ini)
|
||||||
{
|
{
|
||||||
state = s_falling;
|
state = s_falling;
|
||||||
|
vy = maxVY;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user