From e54edec78fc3f0493e67d39f1a6d64d8a25054fb Mon Sep 17 00:00:00 2001 From: Nick Gasson Date: Sat, 30 Aug 2008 17:57:55 +0100 Subject: [PATCH] Calculate correct step sizes --- src/ElectricGate.cpp | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/src/ElectricGate.cpp b/src/ElectricGate.cpp index 307a14d..85b0b09 100644 --- a/src/ElectricGate.cpp +++ b/src/ElectricGate.cpp @@ -139,9 +139,14 @@ void ElectricGate::Draw() void Lightning::Build(int length, bool vertical) { line.SwapXandY(vertical); + + const int POINT_STEP = 20; + int npoints = (length / POINT_STEP) + 1; + double delta = (double)length / (double)(npoints - 1); - line.AddPoint(0, 0); - line.AddPoint(length, 0); + for (int i = 0; i < npoints; i++) { + line.AddPoint(i*delta, 0); + } } void Lightning::Draw() const -- 2.39.2