Terrain Generator

Previous topic - Next topic


 ::) I tried to create a project with the library files but have errors. I am using the forum headerpack but still get compile errors. SBlectric, could you kindly make a project with the included header files! Is there updated headers I should be using?  :whistle:


I actually came up with a fix for that already. Just replace the inline code after the global declarations with this:
Code (glbasic) Select

typedef int time_t;
IMPORT "C" int time(void* timer);
IMPORT "C" void srand(unsigned int seed);
IMPORT "C" int rand();

I'll update the code on my website to include this new stuff soon. However, I still can't seem to get it working on Android, as it crashes on open.
Cool stuff and whatever


I updated the download link to v1.2, released today.

New in v1.2:
- changed library dependencies
- Save as binary file (could be useful as a raw import)
Binary file format:
*.bin or any file extension
File Header: TGBIN followed by newline
Header packet: TGH followed by width UWORD and height UWORD
File packet: TGF followed by newline, then the raw IEEE data stream of each pixel

Note that the IEEE data "pixels" range from 0.0 (lowest) to 1.0 (highest).

Download link: http://sblectric.com/downloads/TerrainGen-v1.2.zip
Cool stuff and whatever


Oh great that works and thank-you. If I change the palette to flat blue,green,red on the water, land and mountain then it's easy to directly import as a png. Perfect!  =D The palette option should be in the application.  ;)

Code (GLBasic) Select


FUNCTION preview:
LOCAL num, file$, map[], img%[], cl AS TG_MAPCOLORS
DIM map[256][256]
DIM img%[256][256]
file$ = PLATFORMINFO$("DOCUMENTS") + "/test.png"
TerrainGen(map[], img%[], cl, 256, 256, 0.65, 2.0, 16, file$, 0)
LOADSPRITE file$, num
DRAWSPRITE num, 0, 0