Hi !
Featured games (90)
games approved by the League of Dukes
Games in Showcase (777)
Games in Android Showcase (231)
games submitted by our members
Games in WIP (856)
games currently in development
News: Read the Java Gaming Resources, or peek at the official Java tutorials
    Home     Help   Search   Login   Register   
Pages: [1]
  ignore  |  Print  
  Generating 'interesting' 2D tunnels  (Read 7330 times)
0 Members and 1 Guest are viewing this topic.
Offline namrog84

JGO Ninja

Medals: 46
Projects: 4

Keep programming!

« Posted 2013-08-15 07:22:43 »

So I am working on a 2D escape/sidescrolling game.
Essentially ship flying through tunnel.  Nothing too exciting.

However I am having issues solving tunnel generation.  I want to generate the tunnel(s) of various sizes of up and down.

failed - Simple approach (just pick a random distance from y=0, for 'bottom of tunnel' then offset minimum random distance for ceiling
--- While this does work,  it never generates very nice looking curves or anything 'interesting'

failed - bezier curves/splines
     --generate various curves and connect them together, and offset for distances.   A bit better, can generate some nice varied terrain, however it only ever produces various curves and not enough of 'interesting' or 'variance'

I was hoping to go with a noise(perlin/simplex/???) approach for 2 reasons.  More variance and ideally 1 of the 'interesting'(occasionally floating islands?) things I would like is for it to split off occasionally, so that you could have a choice of going between 2 tunnels or more?

However,  I cannot have 'dead ends'  so if it splits, it needs to reconnect at some point or it perpetually has any number of tunnels?  (bound to a particular height of world of course

I vaguely saw some things talking about 'perlin worms' or 'perlin tunnels' or 'rivers'(such as on a 2d top down terrain map)  However I couldn't find much samples or code to reference from?

Any suggestions or links would be greatly appreciated!

edit:  While I am not ready to post a WiP, if you need an example of what I am talking about. here is a rough concept of whats happening right now.

edit2:  going to bed, but going to attempt something else tomorrow?
Generate some perlin noise for map,   then use A* to generate a path between some endpoints.  Then distort the path with some midpoint displacement.   
Possibly generating more than 1 path?  Perhaps ill generate 2 worlds, 2 paths,  then flatten them together? Seems like a lot of work but that could give 2 seperate paths(sometimes will be the same)  and if they are 'slightly' off, they would be able to generate 'islands'    Or find some way of 'eroding' the map based upon the paths?  is there an easy way to do this?

"Experience is what you get when you did not get what you wanted"
Offline HeroesGraveDev

JGO Kernel

Medals: 382
Projects: 11
Exp: 4 years

┬─┬ノ(ಠ_ಠノ)(╯°□°)╯︵ ┻━┻

« Reply #1 - Posted 2013-08-15 08:09:55 »

1. Move the position in a random direction.
2. Clear a circle around the position.
3. Repeat as much as you like. Also create branches if you want.

Offline RobinB

JGO Ninja

Medals: 45
Projects: 1
Exp: 3 years

Spacegame in progress

« Reply #2 - Posted 2013-08-15 08:39:56 »

use value = Abs(noise)
the output would be like this:

Black is value around 0.
these are the best caves you could create using noise.
Games published by our own members! Check 'em out!
Legends of Yore - The Casual Retro Roguelike
Offline Opiop
« Reply #3 - Posted 2013-08-15 13:34:39 »

If you want an easier way to generate simple tunnels, you could also use this method:
Its super simple, and you could use a* to connect the paths together. Of course, an actual noise algorithm would probably produce more interesting results but this way is easier and creates some interesting tunnels/caves.
Offline namrog84

JGO Ninja

Medals: 46
Projects: 4

Keep programming!

« Reply #4 - Posted 2013-08-15 15:34:24 »

Thanks all, exactly what i was hoping for !

I will try and implement them today and see how it works out!

"Experience is what you get when you did not get what you wanted"
Offline Several Kilo-Bytes

Senior Devvie

Medals: 11

« Reply #5 - Posted 2013-08-16 19:58:42 »

I like the abs(noise) version because it can be made to wrap around or support generating seamless levels in chunks. A similar technique is to use the boundaries of a Voronoi diagram. It can be done without rasterizing, all areas will be connected, and most forks will have approximately equal angles. More noise could be used to displace/noisify the tunnels in either method.

I have seen a cellular automata algorithm (like Conway's game of life) that generates large open spaces that look cave-like, but I do not have a link. This looks good for top-down and side views, but you can't really distinguish tunnels from open spaces and extra work may be necessary to make everything connected.
Pages: [1]
  ignore  |  Print  

hadezbladez (295 views)
2018-11-16 13:46:03

hadezbladez (164 views)
2018-11-16 13:41:33

hadezbladez (295 views)
2018-11-16 13:35:35

hadezbladez (75 views)
2018-11-16 13:32:03

EgonOlsen (2156 views)
2018-06-10 19:43:48

EgonOlsen (2183 views)
2018-06-10 19:43:44

EgonOlsen (1370 views)
2018-06-10 19:43:20

DesertCoockie (1988 views)
2018-05-13 18:23:11

nelsongames (1631 views)
2018-04-24 18:15:36

nelsongames (2279 views)
2018-04-24 18:14:32
Deployment and Packaging
by mudlee
2018-08-22 18:09:50

Java Gaming Resources
by gouessej
2018-08-22 08:19:41

Deployment and Packaging
by gouessej
2018-08-22 08:04:08

Deployment and Packaging
by gouessej
2018-08-22 08:03:45

Deployment and Packaging
by philfrei
2018-08-20 02:33:38

Deployment and Packaging
by philfrei
2018-08-20 02:29:55

Deployment and Packaging
by philfrei
2018-08-19 23:56:20

Deployment and Packaging
by philfrei
2018-08-19 23:54:46 is not responsible for the content posted by its members, including references to external websites, and other references that may or may not have a relation with our primarily gaming and game production oriented community. inquiries and complaints can be sent via email to the info‑account of the company managing the website of java‑
Powered by MySQL Powered by PHP Powered by SMF 1.1.18 | SMF © 2013, Simple Machines | Managed by Enhanced Four Valid XHTML 1.0! Valid CSS!