Character draws itself.
This commit is contained in:
parent
2d05fd03db
commit
7a391c5743
3 changed files with 14 additions and 1 deletions
|
@ -22,6 +22,9 @@
|
||||||
#include "gameactions.hpp"
|
#include "gameactions.hpp"
|
||||||
#include "worldgrid.hpp"
|
#include "worldgrid.hpp"
|
||||||
#include "grid_raytrace.hpp"
|
#include "grid_raytrace.hpp"
|
||||||
|
#include "drawing_queue.hpp"
|
||||||
|
#include "worldviewport.hpp"
|
||||||
|
#include "texture.hpp"
|
||||||
#include <ciso646>
|
#include <ciso646>
|
||||||
#include <cassert>
|
#include <cassert>
|
||||||
#include <cstdint>
|
#include <cstdint>
|
||||||
|
@ -110,6 +113,15 @@ namespace curry {
|
||||||
m_speed = parSpeed;
|
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) {
|
void Character::on_texture_size_changed (const vec2f& parOldSz, const vec2f& parNewSz) {
|
||||||
if (m_position.get_min() != m_position.get_max())
|
if (m_position.get_min() != m_position.get_max())
|
||||||
m_position.change_minmax(m_position.get_min(), m_position.get_max() + parOldSz - parNewSz);
|
m_position.change_minmax(m_position.get_min(), m_position.get_max() + parOldSz - parNewSz);
|
||||||
|
|
|
@ -46,6 +46,7 @@ namespace curry {
|
||||||
virtual void world_size_changed (const vec2us& parSize, const vec2i& parPixelSize) override;
|
virtual void world_size_changed (const vec2us& parSize, const vec2i& parPixelSize) override;
|
||||||
virtual void do_movement (float parDeltaT) override;
|
virtual void do_movement (float parDeltaT) override;
|
||||||
void set_speed (float parSpeed);
|
void set_speed (float parSpeed);
|
||||||
|
virtual void draw (DrawingQueue& parDQ, const WorldViewport& parViewport) override;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
virtual void on_texture_size_changed (const vec2f& parOldSz, const vec2f& parNewSz) override;
|
virtual void on_texture_size_changed (const vec2f& parOldSz, const vec2f& parNewSz) override;
|
||||||
|
|
|
@ -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->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 {
|
void IngameScene::on_destroy() noexcept {
|
||||||
|
|
Loading…
Reference in a new issue