14 Game::log("Generating Map");
16 for(int x = 0; x < MAPWIDTH; x++){
17 for(int y = 0; y < MAPHEIGHT; y++){
18 Game::map->setNode(x,y,MAPGEN_AIR);
23 for(int x = 0; x < MAPWIDTH; x++){
24 for(int y = 0; y < MAPHEIGHT; y++){
25 Game::map->setNode(x,y,MAPGEN_BEDROCK);
28 Game::log("LOL Seed 13", EASTEREGG);
33 bottom[0] = random(MAPHEIGHT/2 - MAPHEIGHT/10, MAPHEIGHT/2);
34 for(int x = 1; x < MAPWIDTH; x++){
35 bottom[x] = bottom[x-1] + random(-1,1);
38 for(int x = 1; x < MAPWIDTH-1; x++){
39 if(bottom[x] > bottom[x+1] && bottom[x] > bottom[x-1]) bottom[x]--;
40 else if(bottom[x] < bottom[x+1] && bottom[x] < bottom[x-1])bottom[x]++;
43 for(int x = 0; x < MAPWIDTH; x++){
44 Game::map->setNode(x,bottom[x],MAPGEN_GRASS);
47 for(int x = 0; x < MAPWIDTH; x++){
48 for(int y = bottom[x]+1; y < bottom[x]+5; y++){
49 Game::map->setNode(x,y,MAPGEN_DIRT);
53 for(int x = 0; x < MAPWIDTH; x++){
54 for(int y = bottom[x]+5; y < MAPHEIGHT; y++){
55 Game::map->setNode(x,y,MAPGEN_STONE);
59 for(int x = 0; x < MAPWIDTH; x++){
60 for(int y = bottom[x]+10; y < MAPHEIGHT; y++){
61 if((rand() % 100) == 0) Game::map->setNode(x,y,MAPGEN_MESE);
65 for(int x = 0; x < MAPWIDTH; x++){
66 Game::map->setNode(x,MAPHEIGHT-1,MAPGEN_BEDROCK);
68 Game::map->setNode(x,MAPHEIGHT-2,MAPGEN_BEDROCK);
70 Game::map->setNode(x,MAPHEIGHT-3,MAPGEN_BEDROCK);
76 for(int x = 1; x < MAPWIDTH; x++){
77 if(bottom[x] == bottom[x-1]) flatcount++;
78 else if(flatcount > 7){
79 int leftborder = rand() % 2;
80 int rightborder = rand() % 2;
81 for(int mx = x-flatcount-3; mx < x+2; mx++){
82 for(int y = bottom[mx];y < bottom[mx]+5;y++){
83 if(Game::map->getNode(mx,y) == MAPGEN_STONE) break;
84 if(Game::map->getNode(mx,y) == MAPGEN_DIRT || Game::map->getNode(mx,y) == MAPGEN_GRASS) Game::map->setNode(mx,y,MAPGEN_SAND);
87 for(int mx = x-flatcount+leftborder;mx < x-1-rightborder;mx++) Game::map->setNode(mx,bottom[x-1],MAPGEN_WATER);
88 for(int mx = x-flatcount+1+leftborder;mx < x-2-rightborder;mx++) Game::map->setNode(mx,bottom[x-1]+1,MAPGEN_WATER);
89 for(int mx = x-flatcount+2+leftborder; mx < x-3-rightborder;mx++) Game::map->setNode(mx,bottom[x-1]+2,MAPGEN_WATER);
95 int treecount = rand() % MAPWIDTH/10;
96 int treepos[treecount];
97 for(int i = 0; i < treecount; i++){
100 treepos[i] = rand() % MAPWIDTH;
101 for(int j = 0; j < i; j++){
102 if(abs(treepos[j]-treepos[i]) < 3) cont = false;
104 if(!(Game::map->getNode(treepos[i],bottom[treepos[i]]) == MAPGEN_GRASS)) cont = false;
108 int y = bottom[x] - 1;
109 Game::map->setNode(x,y,MAPGEN_WOOD);
110 Game::map->setNode(x,y-1,MAPGEN_WOOD);
111 Game::map->setNode(x,y-2,MAPGEN_LEAVES);
112 Game::map->setNode(x,y-3,MAPGEN_LEAVES);
113 Game::map->setNode(x,y-4,MAPGEN_LEAVES);
114 Game::map->setNode(x-1,y-2,MAPGEN_LEAVES);
115 Game::map->setNode(x-1,y-3,MAPGEN_LEAVES);
116 Game::map->setNode(x-1,y-4,MAPGEN_LEAVES);
117 Game::map->setNode(x+1,y-2,MAPGEN_LEAVES);
118 Game::map->setNode(x+1,y-3,MAPGEN_LEAVES);
119 Game::map->setNode(x+1,y-4,MAPGEN_LEAVES);