Hjälp?
Ett stycke php-kod:
#include <iostream>
#include <time.h>
#include <vector>
#include <cmath>
#include <ctime>
#include <cstdlib>
static int arr[4096][4096];
int main()
{
std::cout << "generating map...This will take some time...." << std::endl;
for(int i = 0; i < 4096; i++)
{
for (int j = 0; j < 4096; ++j)
{
arr[i][j] = -1;
}
}
srand(time(NULL));
int tiles[5];
for(int it = 0; it < 5; it++)
{
tiles[it] = rand() % 50 + 10;
}
for(int i = 0; i < 4096; i++)
{
for(int j = 0; j < 4096; j++)
{
if(arr[i][j] != -1)
{
//std::cout << "not -1, skipping.." << std::endl;
continue;
}
unsigned int val = rand() % 5;
int size = 0;
int x = i, y = j;
for(unsigned int d = 0; d < sizeof(tiles); d++)
{
if(val == d)
{
size = tiles[d];
}
}
if(i - (x - (size/2) < 0))
{
x = x + std::abs((i - (x - (size/2))));
}
if(j - (y - (size/2) < 0))
{
y = y + std::abs((j - (y - (size/2))));
}
int x2 = x - (size/2) + size;
int y2 = y - (size/2) + size;
for(int it1 = x - (size/2); it1 < x2; it1++)
{
for(int it2 = y - (size/2); it2 < y2; it2++)
{
arr[it1][it2] = val;
}
}
}
}
for(int i = 0; i < 4096; i++)
{
for(int j = 0; j < 4096; j++)
{
std::cout << arr[i][j];
}
std::cout << std::endl;
}
return 0;
}
HareKrishnas gud sedan 2014