Author Topic: Terrain Generator  (Read 14865 times)

Offline matchy

  • Prof. Inline
  • *****
  • Posts: 1545
    • View Profile
Re: Terrain Generator
« Reply #30 on: 2014-Jul-29 »
 ::) 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:

Offline SBlectric

  • Mc. Print
  • *
  • Posts: 49
  • Coding is neat I guess
    • View Profile
    • SBlectric Studios
Re: Terrain Generator
« Reply #31 on: 2014-Jul-29 »
I actually came up with a fix for that already. Just replace the inline code after the global declarations with this:
Code: (glbasic) [Select]
INLINE
typedef int time_t;
ENDINLINE
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.
« Last Edit: 2014-Jul-29 by SBlectric »
Cool stuff and whatever

Offline SBlectric

  • Mc. Print
  • *
  • Posts: 49
  • Coding is neat I guess
    • View Profile
    • SBlectric Studios
Re: Terrain Generator
« Reply #32 on: 2014-Jul-29 »
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

Offline matchy

  • Prof. Inline
  • *****
  • Posts: 1545
    • View Profile
Re: Terrain Generator
« Reply #33 on: 2014-Jul-29 »
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]
preview()

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)
num = GENSPRITE()
LOADSPRITE file$, num
CLEARSCREEN
DRAWSPRITE num, 0, 0
SHOWSCREEN
MOUSEWAIT
ENDFUNCTION
« Last Edit: 2014-Jul-29 by matchy »