diff --git a/src/gamelib/character.cpp b/src/gamelib/character.cpp index de29eff..c02df13 100644 --- a/src/gamelib/character.cpp +++ b/src/gamelib/character.cpp @@ -22,6 +22,9 @@ #include "gameactions.hpp" #include "worldgrid.hpp" #include "grid_raytrace.hpp" +#include "drawing_queue.hpp" +#include "worldviewport.hpp" +#include "texture.hpp" #include #include #include @@ -110,6 +113,15 @@ namespace curry { m_speed = parSpeed; } + void Character::draw (DrawingQueue& parDQ, const WorldViewport& parViewport) { + DrawingQueue::ItemInfo item; + item.source = source_rect(); + item.destination = destination_rect(parViewport.position()); + item.texture = texture(); + parDQ.add_for_rendering(0 , std::move(item)); + assert(not item.texture); + } + void Character::on_texture_size_changed (const vec2f& parOldSz, const vec2f& parNewSz) { if (m_position.get_min() != m_position.get_max()) m_position.change_minmax(m_position.get_min(), m_position.get_max() + parOldSz - parNewSz); diff --git a/src/gamelib/character.hpp b/src/gamelib/character.hpp index 63e6ca2..73b0665 100644 --- a/src/gamelib/character.hpp +++ b/src/gamelib/character.hpp @@ -46,6 +46,7 @@ namespace curry { virtual void world_size_changed (const vec2us& parSize, const vec2i& parPixelSize) override; virtual void do_movement (float parDeltaT) override; void set_speed (float parSpeed); + virtual void draw (DrawingQueue& parDQ, const WorldViewport& parViewport) override; private: virtual void on_texture_size_changed (const vec2f& parOldSz, const vec2f& parNewSz) override; diff --git a/src/gamelib/ingamescene.cpp b/src/gamelib/ingamescene.cpp index aed8d9b..4540dd4 100644 --- a/src/gamelib/ingamescene.cpp +++ b/src/gamelib/ingamescene.cpp @@ -138,7 +138,7 @@ namespace curry { this->draw(layer_id_def(), m_local_data->worldtiles, src_rect, dst_rect); } } - this->draw(layer_id_def(), m_local_data->character.texture(), m_local_data->character.source_rect(), m_local_data->character.destination_rect(viewport.position())); + m_local_data->character.draw(drawing_queue(), viewport); } void IngameScene::on_destroy() noexcept {