delta-time: title.cpp
This commit is contained in:
@@ -237,7 +237,7 @@ void Player::handlePlayingMovement() {
|
||||
// Fase 1: Movimiento time-based durante el juego
|
||||
void Player::handlePlayingMovement(float deltaTime) {
|
||||
// Mueve el jugador a derecha o izquierda (time-based)
|
||||
pos_x_ += vel_x_ * 60.0f * deltaTime;
|
||||
pos_x_ += vel_x_ * deltaTime / (1000.0f / 60.0f);
|
||||
|
||||
// Si el jugador abandona el area de juego por los laterales, restaura su posición
|
||||
const float MIN_X = play_area_.x - 5;
|
||||
@@ -388,7 +388,7 @@ void Player::handleCreditsMovement() {
|
||||
|
||||
// Fase 4: Movimiento general en la pantalla de créditos (time-based)
|
||||
void Player::handleCreditsMovement(float deltaTime) {
|
||||
pos_x_ += (vel_x_ / 2.0F) * 60.0f * deltaTime; // Convert frame-based movement to time-based
|
||||
pos_x_ += (vel_x_ / 2.0F) * deltaTime / (1000.0f / 60.0f); // Convert frame-based movement to time-based
|
||||
|
||||
if (vel_x_ > 0) {
|
||||
handleCreditsRightMovement();
|
||||
@@ -425,7 +425,7 @@ void Player::handleWaitingMovement() {
|
||||
// Fase 4: Controla la animación del jugador saludando (time-based)
|
||||
void Player::handleWaitingMovement(float deltaTime) {
|
||||
waiting_time_accumulator_ += deltaTime;
|
||||
float waiting_duration = static_cast<float>(WAITING_COUNTER) / 60.0f; // Convert frames to seconds
|
||||
float waiting_duration = static_cast<float>(WAITING_COUNTER) * (1000.0f / 60.0f); // Convert frames to milliseconds
|
||||
if (waiting_time_accumulator_ >= waiting_duration) {
|
||||
waiting_time_accumulator_ = 0.0f;
|
||||
player_sprite_->resetAnimation();
|
||||
|
||||
Reference in New Issue
Block a user