Character draws itself.

This commit is contained in:
King_DuckZ 2017-03-15 09:14:22 +00:00
parent 2d05fd03db
commit 7a391c5743
3 changed files with 14 additions and 1 deletions

View file

@ -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 <ciso646>
#include <cassert>
#include <cstdint>
@ -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);

View file

@ -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;

View file

@ -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 {