Java-Gaming.org    
Featured games (79)
games approved by the League of Dukes
Games in Showcase (475)
Games in Android Showcase (106)
games submitted by our members
Games in WIP (530)
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 1822 times)
0 Members and 1 Guest are viewing this topic.
Offline namrog84

JGO Ninja


Medals: 46
Projects: 4


Keep programming!


« Posted 2013-08-15 09: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.
http://84bit.com/runnergame-desktop_fat.jar


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: 238
Projects: 11
Exp: 2 years


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


« Reply #1 - Posted 2013-08-15 10: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: 44
Projects: 1
Exp: 3 years


Spacegame in progress


« Reply #2 - Posted 2013-08-15 10: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 opiop65

JGO Kernel


Medals: 153
Projects: 7
Exp: 3 years


JumpButton Studios


« Reply #3 - Posted 2013-08-15 15:34:39 »

If you want an easier way to generate simple tunnels, you could also use this method:
http://roguebasin.roguelikedevelopment.org/index.php?title=Basic_directional_dungeon_generation
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 17: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 Member


Medals: 11



« Reply #5 - Posted 2013-08-16 21: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  
 
 
You cannot reply to this message, because it is very, very old.

 

Add your game by posting it in the WIP section,
or publish it in Showcase.

The first screenshot will be displayed as a thumbnail.

ctomni231 (37 views)
2014-07-18 06:55:21

Zero Volt (35 views)
2014-07-17 23:47:54

danieldean (28 views)
2014-07-17 23:41:23

MustardPeter (31 views)
2014-07-16 23:30:00

Cero (46 views)
2014-07-16 00:42:17

Riven (47 views)
2014-07-14 18:02:53

OpenGLShaders (36 views)
2014-07-14 16:23:47

Riven (36 views)
2014-07-14 11:51:35

quew8 (32 views)
2014-07-13 13:57:52

SHC (68 views)
2014-07-12 17:50:04
HotSpot Options
by dleskov
2014-07-08 03:59:08

Java and Game Development Tutorials
by SwordsMiner
2014-06-14 00:58:24

Java and Game Development Tutorials
by SwordsMiner
2014-06-14 00:47:22

How do I start Java Game Development?
by ra4king
2014-05-17 11:13:37

HotSpot Options
by Roquen
2014-05-15 09:59:54

HotSpot Options
by Roquen
2014-05-06 15:03:10

Escape Analysis
by Roquen
2014-04-29 22:16:43

Experimental Toys
by Roquen
2014-04-28 13:24:22
java-gaming.org 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‑gaming.org
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!