granera con sarna no pica
This commit is contained in:
@@ -8,6 +8,7 @@
|
||||
#include "core/input/input.hpp" // Para Input, InputAction
|
||||
#include "core/rendering/sprite/animated_sprite.hpp" // Para AnimatedSprite
|
||||
#include "core/resources/resource_cache.hpp" // Para Resource
|
||||
#include "game/defaults.hpp" // Para Defaults::Game::Player, Defaults::Sound::Files
|
||||
#include "game/gameplay/room.hpp" // Para Room
|
||||
#include "game/gameplay/tile_collider.hpp" // Para TileCollider
|
||||
#include "game/options.hpp" // Para Cheat, Options
|
||||
@@ -24,7 +25,6 @@
|
||||
Player::Player(const Data& player)
|
||||
: room_(player.room) {
|
||||
initSprite(player.animations_path);
|
||||
setColor();
|
||||
applySpawnValues(player.spawn_data);
|
||||
placeSprite();
|
||||
initSounds();
|
||||
@@ -36,7 +36,7 @@ Player::Player(const Data& player)
|
||||
// ============================================================================
|
||||
|
||||
void Player::render() {
|
||||
sprite_->render(1, color_);
|
||||
sprite_->render();
|
||||
}
|
||||
|
||||
// ============================================================================
|
||||
@@ -560,35 +560,14 @@ void Player::animate(float delta_time) { // NOLINT(readability-make-member-func
|
||||
}
|
||||
|
||||
// ============================================================================
|
||||
// Color y skin
|
||||
// Skin
|
||||
// ============================================================================
|
||||
|
||||
void Player::setColor(Uint8 color) {
|
||||
if (color != 0) {
|
||||
color_ = color;
|
||||
return;
|
||||
}
|
||||
if (Options::game.player_color >= 0) {
|
||||
color_ = static_cast<Uint8>(Options::game.player_color);
|
||||
} else {
|
||||
color_ = 14;
|
||||
}
|
||||
if (room_ != nullptr && color_ == room_->getBGColor()) {
|
||||
color_ = (room_->getBGColor() != 14) ? 14 : 1;
|
||||
}
|
||||
}
|
||||
|
||||
auto Player::skinToAnimationPath(const std::string& skin_name) -> std::string {
|
||||
if (skin_name == "default") { return "player.yaml"; }
|
||||
if (skin_name == Defaults::Game::Player::SKIN) { return Defaults::Game::Player::DEFAULT_ANIMATION; }
|
||||
return skin_name + ".yaml";
|
||||
}
|
||||
|
||||
void Player::setSkin(const std::string& skin_name) {
|
||||
const auto FLIP = sprite_->getFlip();
|
||||
initSprite(skinToAnimationPath(skin_name));
|
||||
sprite_->setFlip(FLIP);
|
||||
}
|
||||
|
||||
// ============================================================================
|
||||
// Inicialización
|
||||
// ============================================================================
|
||||
@@ -602,8 +581,8 @@ void Player::initSprite(const std::string& animations_path) { // NOLINT(readabi
|
||||
}
|
||||
|
||||
void Player::initSounds() { // NOLINT(readability-convert-member-functions-to-static)
|
||||
jump_sound_ = Resource::Cache::get()->getSound("jump.wav");
|
||||
land_sound_ = Resource::Cache::get()->getSound("land.wav");
|
||||
jump_sound_ = Resource::Cache::get()->getSound(Defaults::Sound::Files::JUMP);
|
||||
land_sound_ = Resource::Cache::get()->getSound(Defaults::Sound::Files::LAND);
|
||||
}
|
||||
|
||||
void Player::applySpawnValues(const SpawnData& spawn) {
|
||||
|
||||
Reference in New Issue
Block a user