Browse Source

Update Random_Rect_Edges_mapgenerator.c

Rudy Boudewijn van Etten 5 years ago
parent
commit
f214f7514a
1 changed files with 9 additions and 3 deletions
  1. 9 3
      ProcGen/Random_Rect_Edges_mapgenerator.c

+ 9 - 3
ProcGen/Random_Rect_Edges_mapgenerator.c

@@ -23,6 +23,7 @@ static void makemap();
 static void makerect(int x,int y,int w,int h,bool force);
 static void makerect(int x,int y,int w,int h,bool force);
 static bool maprectcheck(int x,int y,int w,int h);
 static bool maprectcheck(int x,int y,int w,int h);
 static void edgeenhance();
 static void edgeenhance();
+static float edistance(float x1,float y1,float x2,float y2);
 
 
 int main(void)
 int main(void)
 {
 {
@@ -203,9 +204,9 @@ static void drawmap(){
                 
                 
             }
             }
             if(map[x][y]==1){// Floor tile
             if(map[x][y]==1){// Floor tile
-                
-                if(swx==0)DrawRectangle(dx,dy,tileWidth,tileHeight,(Color){150,150,150,255});
-                else DrawRectangle(dx,dy,tileWidth,tileHeight,(Color){120,120,120,255});                
+                int z=edistance(screenWidth/2,screenHeight/2,dx,dy)/5;                
+                if(swx==0)DrawRectangle(dx,dy,tileWidth,tileHeight,(Color){150-z,150-z,150-z,255});
+                else DrawRectangle(dx,dy,tileWidth,tileHeight,(Color){120-z,120-z,120-z,255});                
             }            
             }            
             if(map[x][y]==2){// Wall tile
             if(map[x][y]==2){// Wall tile
                 DrawRectangle(dx,dy,tileWidth,tileHeight,BROWN);
                 DrawRectangle(dx,dy,tileWidth,tileHeight,BROWN);
@@ -255,3 +256,8 @@ static void edgeenhance(){
 
 
     }}    
     }}    
 }
 }
+
+// Euclidean distance (more precise)
+float edistance(float x1,float y1,float x2,float y2){
+    return sqrt( (x1-x2)*(x1-x2)+(y1-y2)*(y1-y2) );
+}