Luolaa
authorekku
Thu, 20 Nov 2008 23:54:41 +0000
changeset 90 c1a072928790
parent 89 825c4613e087
child 91 0a6d675099dc
Luolaa
src/proto2/Graphics.cc
src/proto2/Physics.cc
--- a/src/proto2/Graphics.cc	Thu Nov 20 23:51:46 2008 +0000
+++ b/src/proto2/Graphics.cc	Thu Nov 20 23:54:41 2008 +0000
@@ -12,13 +12,13 @@
 
     Vector tmp;
     CL_Color color;
-    CL_PixelBuffer terr(MAP_WIDTH, MAP_HEIGHT, 3*MAP_WIDTH, CL_PixelFormat::rgb888);
+    CL_PixelBuffer terr(MAP_WIDTH, MAP_HEIGHT, 4*MAP_WIDTH, CL_PixelFormat::rgba8888);
     
     
     for (tmp.x = 0; tmp.x < MAP_WIDTH; tmp.x++) {
         for (tmp.y = 0; tmp.y < MAP_HEIGHT; tmp.y++) {
             if (state.getType(tmp) == EMPTY) {
-                color = CL_Color(80, 35, 0);
+                color = CL_Color(86, 41, 0);
             } else if (state.getType(tmp) == DIRT) {
                 color = CL_Color(144, 82, 23);
             } else if (state.getType(tmp) == ROCK) {
@@ -27,7 +27,7 @@
                 // Fale
             }
             terr.draw_pixel(tmp.x, tmp.y, color);
-            }
+     	}
     }
     terrain = CL_Surface(terr);
  
--- a/src/proto2/Physics.cc	Thu Nov 20 23:51:46 2008 +0000
+++ b/src/proto2/Physics.cc	Thu Nov 20 23:54:41 2008 +0000
@@ -7,7 +7,7 @@
 #include <cmath>
 
 PhysicsWorld::PhysicsWorld (Vector gravity, Vector dimensions)
-    : tick_timer(PHYSICS_TICK_MS), gravity(gravity), dimensions(dimensions), terrain(dimensions.x, std::vector<TerrainType>(dimensions.y, EMPTY)) {
+    : tick_timer(PHYSICS_TICK_MS), gravity(gravity), dimensions(dimensions), terrain(dimensions.x, std::vector<TerrainType>(dimensions.y, DIRT)) {
 
 	generateTerrain(1337);
 
@@ -196,7 +196,7 @@
     // some constants to control random generation
     const int min_range = 10;
     const int max_range = 40;
-    const int num = 1;
+    const int num = 30;
     const int rock_rarity = 4; // 1 / rock_rarity will be rock circle
 
     // loops for amount of circles
@@ -209,19 +209,21 @@
         // put first circle in the middle of the cave
 		// so that we have some area we can certainly spawn into 
 		if(i == 0) {
-			midx = 60;
-			midy = 60;
-			range = 50;
+			midx = dimensions.x/2;
+			midy = dimensions.y/2;
+			range = 150;
 		}
 
-        TerrainType type = DIRT;
+        TerrainType type = EMPTY;
         if(rand()%rock_rarity == 0) {
             type = ROCK;
         }
+
+    	Engine::log(DEBUG, "PhysicsObject.generta") << "Dims: " << dimensions.x << " " << dimensions.y;
         // loops for every pixel of circle
         for(int x = std::max(0, midx-range); x < std::min((int)dimensions.x, midx+range); x++) {
             for(int y = std::max(0, midy-range); y < std::min((int)dimensions.y, midy+range); y++) {
-                if(x*x+y*y < range*range) {
+                if((x-midx) * (x-midx) + (y-midy) * (y-midy) < range*range) {
                     // and sets it to type
                     terrain[x][y] = type;
                 }