【初心者歓迎】C/C++室 Ver.43【環境依存OK】
■ このスレッドは過去ログ倉庫に格納されています
0448デフォルトの名無しさん
2007/10/10(水) 23:58:04static const int vector_x[] = {0, 0, -1, 1};
static const int vector_y[] = {1, -1, 0, 0};
int directions[] = {0, 1, 2, 3};
int direction_count;
maze[y][x] = FLOOR;
for (direction_count = 4; direction_count > 0; --direction_count) {
int direction_index = (int) ((double) direction_count) * rand() / (RAND_MAX + 1.0);
int direction = directions[direction_index];
int moved_x = x + vector_x[direction] * 2;
int moved_y = y + vector_y[direction] * 2;
if (moved_x > 0 && moved_x < WIDTH && moved_y > 0
&& moved_y < HEIGHT
&& maze[moved_y][moved_x] == WALL){
maze[y + vector_y[direction]][x - vector_x[direction]]
dig(maze, moved_x, moved_y);
}
directions[direction_index] = directions[direction_count - 1];
}
return;
}
■ このスレッドは過去ログ倉庫に格納されています