37 lines
854 B
C++
37 lines
854 B
C++
#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;
|
|
}
|
|
|
|
|
|
}
|