Added basic line drawing to renderer

This commit is contained in:
Thomas Muller 2021-08-03 23:03:13 -04:00
parent ff7e296d92
commit 621760b453
Signed by: thomas
GPG key ID: AF006EB730564952

View file

@ -49,6 +49,24 @@ void Render::fill_rectangle_sz(Vector2<int> size, Color color) {
); );
} }
void Render::draw_lines(std::vector<Vector2<float>> points, Color color) {
auto prev_cache = m_matrix * m_view_matrix * Vector3<float>(points[0], 1);
for(size_t i = 1; i < points.size(); i++) {
auto start = prev_cache;
auto end = m_matrix * m_view_matrix * Vector3<float>(points[i], 1);
m_pge->DrawLine(
start.x(),
start.y(),
end.x(),
end.y(),
olc::Pixel(color.r(), color.g(), color.b())
);
prev_cache = end;
}
}
void Render::set_camera_pos(Vector2<int> camera_pos) { void Render::set_camera_pos(Vector2<int> camera_pos) {
m_camera_pos = camera_pos; m_camera_pos = camera_pos;
m_view_matrix = translation_matrix(camera_pos); m_view_matrix = translation_matrix(camera_pos);