aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGravatar jonas <himself@jonasgunz.de> 2019-01-22 10:49:21 +0100
committerGravatar jonas <himself@jonasgunz.de> 2019-01-22 10:49:21 +0100
commit072e6b2901c046d80284fa72af2513fe9d8df997 (patch)
treec359805b11a2f88e7144192d546dde8fd3046802
parentc1186bf65902f47a2d618280384bce700a688ec1 (diff)
downloadtermgl-072e6b2901c046d80284fa72af2513fe9d8df997.tar.gz
Fixed Issue #5: cRender:drawLine() now also fills lines with |gradient| > 1
-rw-r--r--cRender.cpp13
1 files changed, 10 insertions, 3 deletions
diff --git a/cRender.cpp b/cRender.cpp
index 293901b..f563199 100644
--- a/cRender.cpp
+++ b/cRender.cpp
@@ -118,15 +118,22 @@ int cRender::drawLine(char _c, sPos _pos1, sPos _pos2, bool _overrideCollision,
if(abs(fGradient) > 1)
{
int dy = (int)(((i + 1) * fGradient + _pos1.y + 0.5) - (i * fGradient + _pos1.y + 0.5));
- if(abs(dy) > 0)
+
+ if(dy > 0 && ((int)(i * fGradient + _pos1.y + 0.5) + dy) <= _pos2.y)
{
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},
+ sPos{i + _pos1.x, (int)(i * fGradient + _pos1.y + 0.5) + dy },
_overrideCollision, _color);
}//if
+ else if(dy < 0 && ((int)(i * fGradient + _pos1.y + 0.5) + dy) >= (_pos2.y) )
+ {
+ drawLine(_c,
+ sPos{i + _pos1.x, (int)(i * fGradient + _pos1.y + 0.5) + dy },
+ sPos{i + _pos1.x, (int)(i * fGradient + _pos1.y + 0.5)},
+ _overrideCollision, _color);
+ }//else if
}//if
-
}//for
}//else