forked from jaildesigner-jailgames/jaildoctors_dilemma
Transició a surface: crec que falta room.cpp
This commit is contained in:
@@ -1,14 +1,14 @@
|
||||
#include "enemy.h"
|
||||
#include <SDL2/SDL_render.h> // for SDL_RendererFlip, SDL_FLIP_NONE, SDL_FL...
|
||||
#include <stdlib.h> // for rand
|
||||
#include "s_animated_sprite.h" // for AnimatedSprite
|
||||
#include "s_animated_sprite.h" // for SAnimatedSprite
|
||||
#include "options.h" // for Options, OptionsVideo, options
|
||||
#include "resource.h" // for Resource
|
||||
#include "surface.h" // for Texture
|
||||
|
||||
// Constructor
|
||||
Enemy::Enemy(const EnemyData &enemy)
|
||||
: sprite_(std::make_shared<AnimatedSprite>(Resource::get()->getSurface(enemy.texture_path), Resource::get()->getAnimations(enemy.animation_path))),
|
||||
: sprite_(std::make_shared<SAnimatedSprite>(Resource::get()->getSurface(enemy.surface_path), Resource::get()->getAnimations(enemy.animation_path))),
|
||||
color_string_(enemy.color),
|
||||
x1_(enemy.x1),
|
||||
x2_(enemy.x2),
|
||||
@@ -33,16 +33,13 @@ Enemy::Enemy(const EnemyData &enemy)
|
||||
collider_ = getRect();
|
||||
|
||||
// Coloca un frame al azar o el designado
|
||||
sprite_->setCurrentAnimationFrame(
|
||||
(enemy.frame == -1) ? (rand() % sprite_->getCurrentAnimationSize()) : enemy.frame);
|
||||
sprite_->setCurrentAnimationFrame((enemy.frame == -1) ? (rand() % sprite_->getCurrentAnimationSize()) : enemy.frame);
|
||||
}
|
||||
|
||||
// Pinta el enemigo en pantalla
|
||||
void Enemy::render()
|
||||
{
|
||||
sprite_->getTexture()->setColor(color_.r, color_.g, color_.b);
|
||||
sprite_->render();
|
||||
sprite_->getTexture()->setColor(255, 255, 255);
|
||||
sprite_->render(1, color_);
|
||||
}
|
||||
|
||||
// Actualiza las variables del objeto
|
||||
@@ -111,16 +108,4 @@ SDL_Rect Enemy::getRect()
|
||||
SDL_Rect &Enemy::getCollider()
|
||||
{
|
||||
return collider_;
|
||||
}
|
||||
|
||||
// Recarga la textura
|
||||
void Enemy::reLoadTexture()
|
||||
{
|
||||
sprite_->getTexture()->reLoad();
|
||||
}
|
||||
|
||||
// Asigna la paleta
|
||||
void Enemy::setPalette(Palette pal)
|
||||
{
|
||||
color_ = stringToColor(pal, color_string_);
|
||||
}
|
||||
Reference in New Issue
Block a user