Terrain::getTangent and Terrain::getNormal must be implemented. Everything else should be there. Still: Not tested, not
authorsaiam
Sun, 30 Nov 2008 14:01:06 +0000
changeset 145 fc572ad7326a
parent 144 d02f642625ec
child 146 329953407fdc
Terrain::getTangent and Terrain::getNormal must be implemented. Everything else should be there. Still: Not tested, not
used.
src/proto2/Terrain.cc
--- a/src/proto2/Terrain.cc	Sun Nov 30 13:52:48 2008 +0000
+++ b/src/proto2/Terrain.cc	Sun Nov 30 14:01:06 2008 +0000
@@ -104,12 +104,23 @@
     return false; // No Collision
 }
 
-void Terrain::removeGround(const Vector &pos, const float r) {
+void Terrain::removeGround(const Vector &pos, const float radius) {
     // TODO: Implement. Some circle algoritmh should be usefull here,
     // though the current impelementation doesn't seem too bad either.
 
-    Vector midpoint = getPixelLocation(pos);
-
+    Vector mid = getPixelLocation(pos);
+    uint16_t r = scale(radius);
+    for (uint16_t i = mid.x-r; i < mid.x+r; i++) {
+        for (uint_16_t j = mid.y-r; j < mid.y+r; j++) {
+            if (getType(i, j) != ROCK) { // getType returns ROCK if
+                                         // out of bounds
+                if ((i-mid.x)*(i-mid.x)+(j-mid.y)*(j-mid.y) < r*r) {
+                    terrain[i][j] = EMPTY;
+                    terr.draw_pixel(i, j, COLOR_EMPTY);
+                }
+            }
+        }
+    }
 }