37 lines
830 B
C++
37 lines
830 B
C++
#include <map.h>
|
|
#include <cmath>
|
|
#include <cstdlib>
|
|
#include <algorithm>
|
|
|
|
// g++ -shared test_library.cpp -o test_library.so -I../src -fPIC
|
|
|
|
extern "C" void generate(Map *mapPtr)
|
|
{
|
|
Map &map = *mapPtr;
|
|
int w = map.getWidth();
|
|
int h = map.getHeight();
|
|
int n = map.getNbTeams();
|
|
int i, j, k;
|
|
|
|
for(i=0;i<w;i++){
|
|
for(j=0;j<h;j++){
|
|
map[i][j].type = GRASS;
|
|
}
|
|
}
|
|
|
|
for(i=0; i<n; i++)
|
|
map.team(i) = Coord((w/(n*2))*(1+i*2), h/2);
|
|
|
|
Coord north = Coord(NORTH);
|
|
for(i=0; i<n; i++){
|
|
// Coord &spawn = map.team(i);
|
|
Coord lib(map.team(i));
|
|
lib+=north;
|
|
lib+=north;
|
|
map[map.team(i)].type=SPAWN;
|
|
map[map.team(i)].data.nbRes = 1;
|
|
map[lib].type=LIBRARY;
|
|
map[lib].data.knowledge = new char[LIBRARY_SIZE];
|
|
}
|
|
}
|