This isn't supposed to be a bunch of drunk mesas. What I've been trying to get (and failing consistently) is a single huge pit, with the occasional ledge, split path, or floating island as one continues down. I think I'll have to get someone else to handle the world gen stuff for this little project, and just focus on the actual game play instead.
This isn't supposed to be a bunch of drunk mesas. What I've been trying to get (and failing consistently) is a single huge pit, with the occasional ledge, split path, or floating island as one continues down. I think I'll have to get someone else to handle the world gen stuff for this little project, and just focus on the actual game play instead.
Previous Entry
Project reports
Comments
August 14, 2011 02:32 PM
YES.
Thing is, I pretty much need to generate it row-by-row, or at most screen-by-screen, in such a way to keep down generation time [i]and[/i] memory use. (Yay phone capabilities.) Part of the problem is I've been coding straight to those requirements, rather than adapting something that works to them.
Thing is, I pretty much need to generate it row-by-row, or at most screen-by-screen, in such a way to keep down generation time [i]and[/i] memory use. (Yay phone capabilities.) Part of the problem is I've been coding straight to those requirements, rather than adapting something that works to them.
August 20, 2011 03:31 PM
The algorithm I used is easy enough to do a row at a time as needed, but it does depend upon you having access to a basic Perlin noise fractal generator. Basically, this is what I did to generate the two previous images:
[code]
function pitBaseFunction(x,y)
if x<-0.5 or x>0.5 then return 1 else return 0 end
end
function pitFunction(x,y)
local turb=perlinFractal:get(x,y)
return pitBaseFunction(x+turb,y)
end
for x=0,255,1 do
for y=0,1023,1 do
local nx=x/255 * 4 - 2
local ny=y/1024 * 4
buf:set(x,y, pitFunction(nx,ny))
end
end
anl.saveDoubleArray("buf.tga", buf)
[/code]
[b]pitBaseFunction[/b] defines the basic cross-section of a single row of pit, by returning open (0) for any x in the range (-0.5,0.5) and returning solid (1) for anything beyond that range.
[b]pitFunction[/b] then calls a Perlin noise fractal with the input coordinates and uses the resulting value to perturb the x coordinate before calling [b]pitBaseFunction[/b]. The algorithm can be generated a cell at a time, a row at a time, a page at a time, however you need, and the generated pit is of basically infinite depth, although it will repeat if the Perlin function has a repeating period so if you want it to go a long way you'll need to construct your Perlin function to accommodate.
The character of the pit can be tweaked by tweaking the Perlin fractal frequency or by scaling the amplitude of the fractal output.
[code]
function pitBaseFunction(x,y)
if x<-0.5 or x>0.5 then return 1 else return 0 end
end
function pitFunction(x,y)
local turb=perlinFractal:get(x,y)
return pitBaseFunction(x+turb,y)
end
for x=0,255,1 do
for y=0,1023,1 do
local nx=x/255 * 4 - 2
local ny=y/1024 * 4
buf:set(x,y, pitFunction(nx,ny))
end
end
anl.saveDoubleArray("buf.tga", buf)
[/code]
[b]pitBaseFunction[/b] defines the basic cross-section of a single row of pit, by returning open (0) for any x in the range (-0.5,0.5) and returning solid (1) for anything beyond that range.
[b]pitFunction[/b] then calls a Perlin noise fractal with the input coordinates and uses the resulting value to perturb the x coordinate before calling [b]pitBaseFunction[/b]. The algorithm can be generated a cell at a time, a row at a time, a page at a time, however you need, and the generated pit is of basically infinite depth, although it will repeat if the Perlin function has a repeating period so if you want it to go a long way you'll need to construct your Perlin function to accommodate.
The character of the pit can be tweaked by tweaking the Perlin fractal frequency or by scaling the amplitude of the fractal output.
August 21, 2011 10:43 PM
Advertisement
Latest Entries
Project reports
1533 views
Project announcements
1384 views
Gone fusion...
1249 views
cIRCulation alpha release soon!
1286 views
cIRCulation tested, again!
1154 views
Project news
1148 views
cIRCulation's Live Test
1182 views
First there was one, then there were two...
1379 views
Advertisement
[img]http://i.imgur.com/wX8WR.png[/img]
or:
[img]http://i.imgur.com/DFZJf.png[/img]