The code is pretty solid in this respect, I think. The way it works is, instead of writing every single tile on the map, it places various chunks of land. It starts off with a blank map covered in water. The map is 50x50, but can easily be changed to make larger or smaller maps by changing some variables. The first thing it does is create several "continents" which are just areas where chunks of land I call "shapes" can spawn. These shapes are random terrain and shape that can overlap, so the land masses that form transition seamlessly most of the time.
Tell me what you think. Criticism is much appreciated and expected. Veteran programmers, any comments?
Code:
include, gen.hsi
include, plotscr.hsd
include, Scancode.hsi
global variable, begin
1, mapsize
2, currentx
3, currenty
4, xincriment
5, yincriment
6, tera
7, terahigh
8, teralow
end
#main runs as new game script
plotscript, main, begin
mapsize:=50
terahigh := 11
teralow := 0
#terahigh will determine what tiles will be placed
variable(cut)
cut :=12
for(cut, 1, 12, +1)
do(cont)
# "cut" determines how many "continents" will be placed on the entire map
end
plotscript, cont, begin
xincriment := random(5, mapsize--6)
yincriment := random(5, mapsize--6)
variable(con)
con :=25
for(con, 1, 25, +1)
do(generator)
# con determines how many "shapes" will be placed within "continents"
end
plotscript, generator, begin
#This places 1 "continent" on the map. It's an area where a shape can be placed.
currentx := random(xincriment--5, xincriment+5)
currenty := random(yincriment--5, yincriment+5)
pickshape
end
plotscript, pickshape, begin
#"shapes" are small units of land that are of a certain type of terrain
variable(shape)
shape := random(1,10)
if (shape == 1 || shape == 2 || shape== 3) then (cross)
if (shape == 4) then (square)
if (shape == 5) then (corner1)
if (shape ==6) then (corner2)
if (shape ==7) then (block1)
if (shape==8) then (block2)
if (shape==9) then (line1)
if (shape==10) then (line2)
end
script, cross, begin
tera := random(teralow,terahigh)
write map block (currentx + 1, currenty, tera, 1)
write map block (currentx, currenty+1, tera, 1)
write map block (currentx--1, currenty, tera, 1)
write map block (currentx, currenty--1, tera, 1)
write map block (currentx, currenty, tera, 1)
end
script, square, begin
tera := random(teralow,terahigh)
write map block (currentx--1, currenty+1, tera, 1)
write map block (currentx, currenty+1, tera, 1)
write map block (currentx+1, currenty+1, tera, 1)
write map block (currentx+1, currenty, tera, 1)
write map block (currentx+1, currenty--1, tera, 1)
write map block (currentx, currenty--1, tera, 1)
write map block (currentx--1, currenty--1, tera, 1)
write map block (currentx--1, currenty, tera, 1)
write map block (currentx, currenty, tera, 1)
set hero position (0, currentx, currenty)
end
script, corner1, begin
tera := random(teralow,terahigh)
write map block (currentx+1, currenty, tera, 1)
write map block (currentx, currenty--1, tera, 1)
write map block (currentx--1, currenty--1, tera, 1)
write map block (currentx, currenty, tera, 1)
end
script, corner2, begin
tera := random(teralow,terahigh)
write map block (currentx+1, currenty, tera, 1)
write map block (currentx, currenty+1, tera, 1)
write map block (currentx+1, currenty--1, tera, 1)
write map block (currentx, currenty, tera, 1)
end
script, block1, begin
tera := random(teralow,terahigh)
write map block (currentx+1, currenty, tera, 1)
write map block (currentx, currenty+1, tera, 1)
write map block (currentx, currenty--1, tera, 1)
write map block (currentx+1, currenty--1, tera, 1)
write map block (currentx, currenty--1, tera, 1)
end
script, block2, begin
tera := random(teralow,terahigh)
write map block (currentx--1, currenty, tera, 1)
write map block (currentx--1, currenty--1, tera, 1)
write map block (currentx, currenty--1, tera, 1)
write map block (currentx+1, currenty--1, tera, 1)
write map block (currentx+1, currenty, tera, 1)
write map block (currentx, currenty, tera, 1)
end
script, line1, begin
tera := random(teralow,terahigh)
write map block (currentx+1, currenty, tera, 1)
write map block (currentx--1, currenty, tera, 1)
write map block (currentx, currenty, tera, 1)
end
script, line2, begin
tera := random(teralow,terahigh)
write map block (currentx, currenty--1, tera, 1)
write map block (currentx, currenty+1, tera, 1)
write map block (currentx, currenty, tera, 1)
end
include, gen.hsi
include, plotscr.hsd
include, Scancode.hsi
global variable, begin
1, mapsize
2, currentx
3, currenty
4, xincriment
5, yincriment
6, tera
7, terahigh
8, teralow
end
#main runs as new game script
plotscript, main, begin
mapsize:=50
terahigh := 11
teralow := 0
#terahigh will determine what tiles will be placed
variable(cut)
cut :=12
for(cut, 1, 12, +1)
do(cont)
# "cut" determines how many "continents" will be placed on the entire map
end
plotscript, cont, begin
xincriment := random(5, mapsize--6)
yincriment := random(5, mapsize--6)
variable(con)
con :=25
for(con, 1, 25, +1)
do(generator)
# con determines how many "shapes" will be placed within "continents"
end
plotscript, generator, begin
#This places 1 "continent" on the map. It's an area where a shape can be placed.
currentx := random(xincriment--5, xincriment+5)
currenty := random(yincriment--5, yincriment+5)
pickshape
end
plotscript, pickshape, begin
#"shapes" are small units of land that are of a certain type of terrain
variable(shape)
shape := random(1,10)
if (shape == 1 || shape == 2 || shape== 3) then (cross)
if (shape == 4) then (square)
if (shape == 5) then (corner1)
if (shape ==6) then (corner2)
if (shape ==7) then (block1)
if (shape==8) then (block2)
if (shape==9) then (line1)
if (shape==10) then (line2)
end
script, cross, begin
tera := random(teralow,terahigh)
write map block (currentx + 1, currenty, tera, 1)
write map block (currentx, currenty+1, tera, 1)
write map block (currentx--1, currenty, tera, 1)
write map block (currentx, currenty--1, tera, 1)
write map block (currentx, currenty, tera, 1)
end
script, square, begin
tera := random(teralow,terahigh)
write map block (currentx--1, currenty+1, tera, 1)
write map block (currentx, currenty+1, tera, 1)
write map block (currentx+1, currenty+1, tera, 1)
write map block (currentx+1, currenty, tera, 1)
write map block (currentx+1, currenty--1, tera, 1)
write map block (currentx, currenty--1, tera, 1)
write map block (currentx--1, currenty--1, tera, 1)
write map block (currentx--1, currenty, tera, 1)
write map block (currentx, currenty, tera, 1)
set hero position (0, currentx, currenty)
end
script, corner1, begin
tera := random(teralow,terahigh)
write map block (currentx+1, currenty, tera, 1)
write map block (currentx, currenty--1, tera, 1)
write map block (currentx--1, currenty--1, tera, 1)
write map block (currentx, currenty, tera, 1)
end
script, corner2, begin
tera := random(teralow,terahigh)
write map block (currentx+1, currenty, tera, 1)
write map block (currentx, currenty+1, tera, 1)
write map block (currentx+1, currenty--1, tera, 1)
write map block (currentx, currenty, tera, 1)
end
script, block1, begin
tera := random(teralow,terahigh)
write map block (currentx+1, currenty, tera, 1)
write map block (currentx, currenty+1, tera, 1)
write map block (currentx, currenty--1, tera, 1)
write map block (currentx+1, currenty--1, tera, 1)
write map block (currentx, currenty--1, tera, 1)
end
script, block2, begin
tera := random(teralow,terahigh)
write map block (currentx--1, currenty, tera, 1)
write map block (currentx--1, currenty--1, tera, 1)
write map block (currentx, currenty--1, tera, 1)
write map block (currentx+1, currenty--1, tera, 1)
write map block (currentx+1, currenty, tera, 1)
write map block (currentx, currenty, tera, 1)
end
script, line1, begin
tera := random(teralow,terahigh)
write map block (currentx+1, currenty, tera, 1)
write map block (currentx--1, currenty, tera, 1)
write map block (currentx, currenty, tera, 1)
end
script, line2, begin
tera := random(teralow,terahigh)
write map block (currentx, currenty--1, tera, 1)
write map block (currentx, currenty+1, tera, 1)
write map block (currentx, currenty, tera, 1)
end









It's looking really promising thus far, and I'm excited to see where you go with it.




