added a generator with a world map

This commit is contained in:
HatjigeorgiouDimitri 2016-06-02 16:10:00 +02:00
parent 28edecb5b5
commit 807162bb0f
3 changed files with 13191 additions and 0 deletions

BIN
generators/image.gif Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 4.6 KiB

13155
generators/image.h Normal file

File diff suppressed because it is too large Load Diff

36
generators/realWorld.cpp Normal file
View File

@ -0,0 +1,36 @@
#include <map.h>
#include <stdlib.h>
#include "image.h"
// windows MinGW
// g++ -shared realWorld.cpp -o realWorld.dll -I../include
// linux gcc
// g++ -shared realWorld.cpp -o realWorld.so -I../include -fPIC
extern "C" void generate(Map *mapPtr)
{
Map &map = *mapPtr;
int w = map.getWidth();
int h = map.getHeight();
int n = map.getNbTeams();
for(int i = 0 ; i < h ; i++){
for(int j = 0 ; j < w ; j++){
int ti = i*height/h;
int tj = j*width/w;
int to = ti*width+tj;
unsigned char * pix = (unsigned char*)header_data_cmap[(unsigned char)header_data[to]];
map[j][i].type = pix[0]?BERRIES:GRASS;
}
}
for(int i=0; i<n; i++){
Coord c = Coord((w/(n*2))*(1+i*2)+rand()%20-10, h/2+rand()%20-10);
map.team(i) = c;
map[c].type = SPAWN;
map[c.x+1][c.y].type = GRASS;
map[c].data.teamId = i;
}
}