added a generator with a world map
This commit is contained in:
parent
28edecb5b5
commit
807162bb0f
BIN
generators/image.gif
Normal file
BIN
generators/image.gif
Normal file
Binary file not shown.
After Width: | Height: | Size: 4.6 KiB |
13155
generators/image.h
Normal file
13155
generators/image.h
Normal file
File diff suppressed because it is too large
Load Diff
36
generators/realWorld.cpp
Normal file
36
generators/realWorld.cpp
Normal 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;
|
||||
}
|
||||
|
||||
|
||||
}
|
Loading…
x
Reference in New Issue
Block a user