corregides cridades a SDL3 i migrat casi tot de int a float. Falta jail_shader
This commit is contained in:
@@ -217,7 +217,7 @@ void Player::applyGravity() {
|
||||
|
||||
// Recalcula la posición del jugador y su animación
|
||||
void Player::move() {
|
||||
last_position_ = {static_cast<int>(x_), static_cast<int>(y_)}; // Guarda la posicion actual antes de modificarla
|
||||
last_position_ = {x_, y_}; // Guarda la posicion actual antes de modificarla
|
||||
applyGravity(); // Aplica gravedad al jugador
|
||||
checkState(); // Comprueba el estado del jugador
|
||||
|
||||
@@ -228,7 +228,7 @@ void Player::move() {
|
||||
// Se mueve hacia la izquierda
|
||||
if (vx_ < 0.0f) {
|
||||
// Crea el rectangulo de proyección en el eje X para ver si colisiona
|
||||
SDL_Rect proj;
|
||||
SDL_FRect proj;
|
||||
proj.x = static_cast<int>(x_ + vx_);
|
||||
proj.y = static_cast<int>(y_);
|
||||
proj.h = HEIGHT_;
|
||||
@@ -268,7 +268,7 @@ void Player::move() {
|
||||
// Se mueve hacia la derecha
|
||||
else if (vx_ > 0.0f) {
|
||||
// Crea el rectangulo de proyección en el eje X para ver si colisiona
|
||||
SDL_Rect proj;
|
||||
SDL_FRect proj;
|
||||
proj.x = static_cast<int>(x_) + WIDTH_;
|
||||
proj.y = static_cast<int>(y_);
|
||||
proj.h = HEIGHT_;
|
||||
@@ -322,7 +322,7 @@ void Player::move() {
|
||||
// Se mueve hacia arriba
|
||||
if (vy_ < 0.0f) {
|
||||
// Crea el rectangulo de proyección en el eje Y para ver si colisiona
|
||||
SDL_Rect proj;
|
||||
SDL_FRect proj;
|
||||
proj.x = static_cast<int>(x_);
|
||||
proj.y = static_cast<int>(y_ + vy_);
|
||||
proj.h = static_cast<int>(std::ceil(std::fabs(vy_))); // Para evitar que tenga una altura de 0 pixels
|
||||
@@ -349,7 +349,7 @@ void Player::move() {
|
||||
// Se mueve hacia abajo
|
||||
else if (vy_ > 0.0f) {
|
||||
// Crea el rectangulo de proyección en el eje Y para ver si colisiona
|
||||
SDL_Rect proj;
|
||||
SDL_FRect proj;
|
||||
proj.x = static_cast<int>(x_);
|
||||
proj.y = static_cast<int>(y_) + HEIGHT_;
|
||||
proj.h = ceil(vy_); // Para evitar que tenga una altura de 0 pixels
|
||||
@@ -360,7 +360,7 @@ void Player::move() {
|
||||
#endif
|
||||
|
||||
// Comprueba la colisión con las superficies normales y las automáticas
|
||||
const int POS = std::max(room_->checkTopSurfaces(&proj), room_->checkAutoSurfaces(&proj));
|
||||
const float POS = std::max(room_->checkTopSurfaces(&proj), room_->checkAutoSurfaces(&proj));
|
||||
if (POS > -1) {
|
||||
// Si hay colisión lo mueve hasta donde no colisiona y pasa a estar sobre la superficie
|
||||
y_ = POS - HEIGHT_;
|
||||
@@ -373,7 +373,7 @@ void Player::move() {
|
||||
if (state_ != PlayerState::JUMPING) { // Las rampas no se miran si se está saltando
|
||||
const LineVertical LEFT_SIDE = {proj.x, proj.y, proj.y + proj.h - 1};
|
||||
const LineVertical RIGHT_SIDE = {proj.x + proj.w - 1, proj.y, proj.y + proj.h - 1};
|
||||
const int POINT = std::max(room_->checkRightSlopes(&RIGHT_SIDE), room_->checkLeftSlopes(&LEFT_SIDE));
|
||||
const float POINT = std::max(room_->checkRightSlopes(&RIGHT_SIDE), room_->checkLeftSlopes(&LEFT_SIDE));
|
||||
if (POINT > -1) {
|
||||
// No está saltando y hay colisión con una rampa
|
||||
// Calcula la nueva posición
|
||||
@@ -381,7 +381,7 @@ void Player::move() {
|
||||
setState(PlayerState::STANDING);
|
||||
#ifdef DEBUG
|
||||
debug_color_ = static_cast<Uint8>(PaletteColor::YELLOW);
|
||||
debug_point_ = {(int)x_ + (WIDTH_ / 2), POINT};
|
||||
debug_point_ = {x_ + (WIDTH_ / 2), POINT};
|
||||
#endif
|
||||
} else {
|
||||
// No está saltando y no hay colisón con una rampa
|
||||
@@ -559,7 +559,7 @@ void Player::setColor() {
|
||||
|
||||
// Actualiza los puntos de colisión
|
||||
void Player::updateColliderPoints() {
|
||||
const SDL_Rect rect = getRect();
|
||||
const SDL_FRect rect = getRect();
|
||||
collider_points_[0] = {rect.x, rect.y};
|
||||
collider_points_[1] = {rect.x + 7, rect.y};
|
||||
collider_points_[2] = {rect.x + 7, rect.y + 7};
|
||||
@@ -572,7 +572,7 @@ void Player::updateColliderPoints() {
|
||||
|
||||
// Actualiza los puntos de los pies
|
||||
void Player::updateFeet() {
|
||||
const SDL_Point p = {static_cast<int>(x_), static_cast<int>(y_)};
|
||||
const SDL_FPoint p = {x_, y_};
|
||||
|
||||
under_feet_[0] = {p.x, p.y + HEIGHT_};
|
||||
under_feet_[1] = {p.x + 7, p.y + HEIGHT_};
|
||||
@@ -637,7 +637,7 @@ void Player::renderDebugInfo() {
|
||||
surface->putPixel(under_feet_[1].x, under_feet_[1].y, static_cast<Uint8>(PaletteColor::BRIGHT_MAGENTA));
|
||||
|
||||
// Pinta rectangulo del jugador
|
||||
SDL_Rect rect = getRect();
|
||||
SDL_FRect rect = getRect();
|
||||
surface->drawRectBorder(&rect, static_cast<Uint8>(PaletteColor::BRIGHT_CYAN));
|
||||
|
||||
// Pinta el rectangulo de movimiento
|
||||
|
||||
Reference in New Issue
Block a user