aboutsummaryrefslogtreecommitdiff
path: root/cRender.cpp
diff options
context:
space:
mode:
authorGravatar Jonas Gunz <himself@jonasgunz.de> 2019-01-21 20:09:06 +0100
committerGravatar Jonas Gunz <himself@jonasgunz.de> 2019-01-21 20:09:06 +0100
commit57c9687d64a6e4f90276e93797758a875555a401 (patch)
tree9bcbca3a67bf1df98efb99cdc71f52057a6c28d0 /cRender.cpp
parent8693fd830680355d0633d6a4b681386832183b0d (diff)
downloadtermgl-57c9687d64a6e4f90276e93797758a875555a401.tar.gz
Begin Issue #5
Diffstat (limited to 'cRender.cpp')
-rw-r--r--cRender.cpp12
1 files changed, 12 insertions, 0 deletions
diff --git a/cRender.cpp b/cRender.cpp
index 41908e1..1b3b08d 100644
--- a/cRender.cpp
+++ b/cRender.cpp
@@ -114,6 +114,18 @@ int cRender::drawLine(char _c, sPos _pos1, sPos _pos2, bool _overrideCollision,
for (int i = 0; i <= abs(dX); i++)
{
drawPoint(_c, sPos{i + _pos1.x, (int)(i * fGradient + _pos1.y + 0.5)}, _overrideCollision, _color); //+0.5 for rounding error
+
+ if(abs(fGradient) > 1)
+ {
+ int dy = (int)(((i + 1) * fGradient + _pos1.y + 0.5) - (i * fGradient + _pos1.y + 0.5));
+ if(abs(dy) > 0)
+ {
+ drawLine(_c,
+ sPos{i + _pos1.x, (int)(i * fGradient + _pos1.y + 0.5)},
+ sPos{i + _pos1.x, (int)(i * fGradient + _pos1.y + 0.5) + dy},
+ _overrideCollision, _color);
+ }
+ }
}
}