From 4ae6300717a10c7fa850b800f18a730aee1d3e07 Mon Sep 17 00:00:00 2001 From: Bent Bisballe Nyeng Date: Fri, 5 Sep 2014 19:57:14 +0200 Subject: Internal code editor. Sound system. --- src/outputwindow.cc | 27 +++++++++++++++++++-------- 1 file changed, 19 insertions(+), 8 deletions(-) (limited to 'src/outputwindow.cc') diff --git a/src/outputwindow.cc b/src/outputwindow.cc index 43e691f..498af23 100644 --- a/src/outputwindow.cc +++ b/src/outputwindow.cc @@ -48,6 +48,16 @@ OutputWindow::OutputWindow() reset(); } +double OutputWindow::coordX() +{ + return x; +} + +double OutputWindow::coordY() +{ + return y; +} + void OutputWindow::stopScript() { stop = true; @@ -117,7 +127,7 @@ void OutputWindow::paintEvent(QPaintEvent *) p.setTransform(gt); QPen pen; - pen.setWidth(6); + pen.setWidth(4); /* p.setPen(pen); p.drawLines(points); @@ -148,7 +158,7 @@ void OutputWindow::paintEvent(QPaintEvent *) QColor c = colour; c.setAlpha(c.alpha() / 4); pen.setStyle(Qt::SolidLine); - pen.setWidth(6); + pen.setWidth(4); pen.setColor(c); p.setPen(pen); for(int i = 0; i < current_points.size(); i+=2) { @@ -183,9 +193,10 @@ static inline int sign(int x) return -1; } -void OutputWindow::forward(int dist) +void OutputWindow::forward(double dist) { sem.acquire(); + float target_x = sin(r * (M_PI / 180.0)) * dist; float target_y = cos(r * (M_PI / 180.0)) * dist; @@ -222,15 +233,15 @@ void OutputWindow::forward(int dist) } // Turn x degrees -void OutputWindow::turn(int x) +void OutputWindow::turn(double x) { - int spd = (speed * abs(x) / 80); - float offset = this->r; + double spd = (speed * abs(x) / 80.0); + double offset = this->r; sem.acquire(); for(int i = 0; i < spd; i++) { if(stop) return; - float p = (float)i / (float)spd; - this->r = offset + (float)x * p; + double p = (double)i / spd; + this->r = offset + x * p; sem.acquire(); } this->r = offset + x; -- cgit v1.2.3