Main Page | Alphabetical List | Class List | File List | Class Members | File Members

editor/transform_smooth.c

Go to the documentation of this file.
00001 
00002 //{{{
00003 int tile_is_wall(int x, int y)
00004 {
00005     if(!is_in_bounds(x,y)) return 0;
00006     switch(current_map->t[y][x])
00007     {
00008         case TILE_WALL: case TILE_WALL_1: case TILE_WALL_2:
00009         case TILE_WALL_3: case TILE_WALL_4: case TILE_WALL_6:
00010         case TILE_WALL_7: case TILE_WALL_8: case TILE_WALL_9:
00011             return 1;
00012         default:
00013             return 0;
00014     }
00015 }
00016 //}}}
00017 //{{{
00018 int wall_map[16] =
00019 // Bit N in an index into wall_map corresponds to whether relative position N 
00020 // contains a wall or not.
00021 //     +---+
00022 //     |   |
00023 //     | 1 |
00024 //     |   |
00025 // +---+---+---+
00026 // |   |###|   |
00027 // | 0 |###| 2 |
00028 // |   |###|   |
00029 // +---+---+---+
00030 //     |   |
00031 //     | 3 |
00032 //     |   |
00033 //     +---+
00034     {
00035     // Position 0 clear
00036         // Position 1 clear
00037             // Position 2 clear
00038             TILE_WALL,  // Position 3 clear
00039             TILE_WALL8, // Position 3 set
00040             // Position 2 set
00041             TILE_WALL4,  // Position 3 clear
00042             TILE_WALL7, // Position 3 set
00043         // Position 1 set
00044             // Position 2 clear
00045             TILE_WALL2, // Position 3 clear
00046             TILE_WALL,  // Position 3 set
00047             // Position 2 set
00048             TILE_WALL1, // Position 3 clear
00049             TILE_WALL,  // Position 3 set
00050     // Position 0 set
00051         // Position 1 clear
00052             // Position 2 clear
00053             TILE_WALL6, // Position 3 clear
00054             TILE_WALL9, // Position 3 set
00055             // Position 2 set
00056             TILE_WALL,  // Position 3 clear
00057             TILE_WALL,  // Position 3 set
00058         // Position 1 set
00059             // Position 2 clear
00060             TILE_WALL3, // Position 3 clear
00061             TILE_WALL,  // Position 3 set
00062             // Position 2 set
00063             TILE_WALL,  // Position 3 clear
00064             TILE_WALL,  // Position 3 set
00065     };
00066 //}}}
00067 //{{{
00068 void transform_smooth(void)
00069 {
00070     int xi, yi;
00071     int dirs[4];
00072     
00073     for(yi=0; yi<FIELD_HEIGHT; yi++)
00074     for(xi=0; xi<FIELD_WIDTH; xi++)
00075     {
00076         if(!tile_is_wall(xi, yi)) continue;
00077         dirs[0] = tile_is_wall(xi-1, yi);
00078         dirs[1] = tile_is_wall(xi, yi-1);
00079         dirs[2] = tile_is_wall(xi+1, yi);
00080         dirs[3] = tile_is_wall(xi, yi+1);
00081         current_map->t[yi][xi] = wall_map[ dirs[0]<<3 | dirs[1]<<2 | dirs[2]<<1 | dirs[3] ];
00082     }
00083 }
00084 //}}}
00085 
00086 

Generated on Thu Apr 22 14:06:32 2004 for SKye by doxygen 1.3.6