CG62 wrote:To be honest, I think we need one large landmass (the continent), with outlying islands, rather than an archipelago.
I mean, the game's style doesn't really support any kind of overly tropical environments.
#!/usr/bin/python
import os, sys, getopt, gd
import utils, mapio, map, terrain
c = utils.coord
area = utils.area
opts, args = getopt.getopt(sys.argv[1:], "v")
for o, a in opts:
if o == "-v":
utils.verbose = True
if len(args) < 5:
sys.stderr.write("usage: importmap [-v] IMAGE COLORMAP SG-X SG-Y OUTDIR\n")
sys.exit(1)
srcfile = args[0]
cmfile = args[1]
sgc = c(int(args[2]), int(args[3]))
outdir = args[4]
colormap = {}
cmf = open(cmfile, "r")
try:
for line in cmf:
if len(line.strip()) == 0: continue
if (line.strip())[0] == '#': continue
trnnm, r, g, b = line.split()
trn = terrain.byname(trnnm)
if trn is None:
sys.stderr.write("importmap: %s: no such terrain\n" % (trnnm,))
sys.exit(1)
colormap[(int(r), int(g), int(b))] = trn
finally:
cmf.close()
map.initmap(terrain.water, sgc)
src = gd.image(srcfile)
sz = c(*src.size())
if sz != map.gensz:
sys.stderr.write("importmap: %s must be %s, not %s\n" % (srcfile, map.gensz, sz))
sys.exit(1)
extent = area(c(0, 0), sz)
for sc in extent:
px = src.getPixel(sc)
col = (src.red(px), src.green(px), src.blue(px))
if col not in colormap:
sys.stderr.write("importmap: unlisted color %s at %s\nmatches:\n" % (col, sc))
matches = []
for mcol in colormap:
d = abs(col[0] - mcol[0]) + abs(col[1] - mcol[1]) + abs(col[2] - mcol[2])
matches.append((colormap[mcol], d))
matches.sort(key = lambda m: m[1])
for trn, d in matches:
sys.stderr.write("\t%s: %i\n" % (trn.name, d))
sys.exit(1)
map.sg.setPixel(sc, colormap[col].sgid)
mapio.writesg(outdir)
Jackard wrote:to be honest i'd like his generator just so i could play around with it
Users browsing this forum: Ahrefs [Bot], Claude [Bot] and 1 guest