linter
This commit is contained in:
@@ -6,9 +6,10 @@
|
||||
#include <algorithm> // Para max
|
||||
#include <array> // Para array
|
||||
#include <cstdlib> // Para rand, abs
|
||||
#include <string> // Para basic_string
|
||||
|
||||
#include "audio.hpp" // Para Audio
|
||||
#include "param.hpp" // Para Param, ParamGame, param
|
||||
#include "param.hpp" // Para Param, param, ParamGame, ParamTabe
|
||||
#include "resource.hpp" // Para Resource
|
||||
#include "utils.hpp" // Para Zone
|
||||
|
||||
@@ -18,11 +19,11 @@ Tabe::Tabe()
|
||||
timer_(Timer(param.tabe.min_spawn_time, param.tabe.max_spawn_time)) {}
|
||||
|
||||
// Actualiza la lógica (time-based)
|
||||
void Tabe::update(float deltaTime) {
|
||||
void Tabe::update(float delta_time) {
|
||||
if (enabled_ && !timer_.is_paused) {
|
||||
sprite_->update(deltaTime);
|
||||
move(deltaTime);
|
||||
updateState(deltaTime);
|
||||
sprite_->update(delta_time);
|
||||
move(delta_time);
|
||||
updateState(delta_time);
|
||||
}
|
||||
|
||||
timer_.update();
|
||||
@@ -39,10 +40,10 @@ void Tabe::render() {
|
||||
}
|
||||
|
||||
// Mueve el objeto (time-based)
|
||||
void Tabe::move(float deltaTime) {
|
||||
void Tabe::move(float delta_time) {
|
||||
const int X = static_cast<int>(x_);
|
||||
speed_ += accel_ * deltaTime;
|
||||
x_ += speed_ * deltaTime;
|
||||
speed_ += accel_ * delta_time;
|
||||
x_ += speed_ * delta_time;
|
||||
fly_distance_ -= std::abs(X - static_cast<int>(x_));
|
||||
|
||||
// Comprueba si sale por los bordes
|
||||
@@ -77,8 +78,8 @@ void Tabe::move(float deltaTime) {
|
||||
if (fly_distance_ <= 0) {
|
||||
if (waiting_counter_ > 0) {
|
||||
accel_ = speed_ = 0.0F;
|
||||
waiting_counter_ -= deltaTime;
|
||||
if (waiting_counter_ < 0) waiting_counter_ = 0;
|
||||
waiting_counter_ -= delta_time;
|
||||
waiting_counter_ = std::max<float>(waiting_counter_, 0);
|
||||
} else {
|
||||
constexpr int CHOICES = 4;
|
||||
const std::array<Direction, CHOICES> LEFT = {
|
||||
@@ -129,22 +130,22 @@ void Tabe::enable() {
|
||||
void Tabe::setRandomFlyPath(Direction direction, int length) {
|
||||
direction_ = direction;
|
||||
fly_distance_ = length;
|
||||
waiting_counter_ = 0.083f + (rand() % 15) * 0.0167f; // 5-20 frames converted to seconds (5/60 to 20/60)
|
||||
waiting_counter_ = 0.083F + (rand() % 15) * 0.0167F; // 5-20 frames converted to seconds (5/60 to 20/60)
|
||||
Audio::get()->playSound("tabe.wav");
|
||||
|
||||
constexpr float SPEED = 120.0f; // 2 pixels/frame * 60fps = 120 pixels/second
|
||||
constexpr float SPEED = 120.0F; // 2 pixels/frame * 60fps = 120 pixels/second
|
||||
|
||||
switch (direction) {
|
||||
case Direction::TO_THE_LEFT: {
|
||||
speed_ = -1.0F * SPEED;
|
||||
accel_ = -1.0F * (1 + rand() % 10) * 2.0f; // Converted from frame-based to seconds
|
||||
accel_ = -1.0F * (1 + rand() % 10) * 2.0F; // Converted from frame-based to seconds
|
||||
sprite_->setFlip(SDL_FLIP_NONE);
|
||||
break;
|
||||
}
|
||||
|
||||
case Direction::TO_THE_RIGHT: {
|
||||
speed_ = SPEED;
|
||||
accel_ = (1 + rand() % 10) * 2.0f; // Converted from frame-based to seconds
|
||||
accel_ = (1 + rand() % 10) * 2.0F; // Converted from frame-based to seconds
|
||||
sprite_->setFlip(SDL_FLIP_HORIZONTAL);
|
||||
break;
|
||||
}
|
||||
@@ -166,7 +167,7 @@ void Tabe::setState(State state) {
|
||||
|
||||
case State::HIT:
|
||||
sprite_->setCurrentAnimation("hit");
|
||||
hit_counter_ = 0.083f; // 5 frames converted to seconds (5/60)
|
||||
hit_counter_ = 0.083F; // 5 frames converted to seconds (5/60)
|
||||
++number_of_hits_;
|
||||
break;
|
||||
|
||||
@@ -177,9 +178,9 @@ void Tabe::setState(State state) {
|
||||
}
|
||||
|
||||
// Actualiza el estado (time-based)
|
||||
void Tabe::updateState(float deltaTime) {
|
||||
void Tabe::updateState(float delta_time) {
|
||||
if (state_ == State::HIT) {
|
||||
hit_counter_ -= deltaTime;
|
||||
hit_counter_ -= delta_time;
|
||||
if (hit_counter_ <= 0) {
|
||||
setState(State::FLY);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user