Hi !
Featured games (90)
games approved by the League of Dukes
Games in Showcase (754)
Games in Android Showcase (229)
games submitted by our members
Games in WIP (842)
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  
  Procedural City Street Generation Using L-Systems  (Read 4360 times)
0 Members and 1 Guest are viewing this topic.
Offline Slyth2727
« Posted 2014-07-13 17:45:06 »

After a long hiatus from game programming I've returned with some decent ideas (in my mind).

First of all, I'm trying to procedurally generate a city for my game. It will be a game feature, so the player can play in different worlds.
I think that the best approach would be to generate a 2D texture of the road map, and then populate it with buildings in the 3D game world (also procedurally generated), so I did some research and decided that L-Systems would be the way to go simply because that's really the only thing I saw people using. After a few more days of research, I still don't fully understand how I would put it into code.

From what I understand, you have a predefined string which is basically the generation rule for the system. You can go forward and draw a line, rotate, switch draw states, and use the | symbol to do something else I don't really understand either. If anyone has any simple/beginner friendly street generation articles they know of, I'd appreciate it if they could share it as well as any advice!

Also, some time ago I saw a post from Riven (I believe?) of a city street generation exactly like what I'm going for. So if you're reading this Riven, mind popping in and either sharing some code or advice?

Online Riven

« JGO Overlord »

Medals: 1338
Projects: 4
Exp: 16 years

Hand over your head.

« Reply #1 - Posted 2014-07-13 17:58:34 »

L systems are a way to recursively turn a sequence of instructions, into another sequence of instructions.

This is a totally different thing than how to interprete these instructions.

Say you get these instructions: "FFLFRFLFRFF", where F is: go forward, L is: turn left, R is: turn right.

Exercise 1: follow the instructions in the sequence - draw the path
Exercise 2: turn every "FL" sequence into "FFRLFRL"
Exercise 3: goto #1

Repeat this, and you'll see the sequence (and therefore the drawing) getting more and more complex.

Having said that, my city generator did not use L systems.

Hi, appreciate more people! Σ ♥ = ¾
Learn how to award medals... and work your way up the social rankings!
Offline Slyth2727
« Reply #2 - Posted 2014-07-13 18:16:33 »

Ah, so I just customize the instructions to my needs. Those two sentences made it click for me! Thanks.
Now that you say your generator did not use L systems, I'm curious what you did use? I'd like to look into many options.
Games published by our own members! Check 'em out!
Legends of Yore - The Casual Retro Roguelike
Offline Sabomoth

Junior Devvie

Medals: 4
Exp: 3 years

« Reply #3 - Posted 2014-07-13 22:19:44 »

More stuff here, even making the houses;

Offline Slyth2727
« Reply #4 - Posted 2014-07-13 23:20:05 »

Thanks for the links! However, I've looked at those already.
I've already started working on the L-system thing. It's going okay I suppose.
Offline Slyth2727
« Reply #5 - Posted 2014-07-13 23:47:06 »

Okay, after a bit of work I have a base for L-systems down. Just doing the Hello World kind of thing for L systems in this example:

Now on to the more advanced stuff.
Thanks Riven!
Pages: [1]
  ignore  |  Print  

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

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

nelsongames (65 views)
2018-04-24 18:14:32

ivj94 (748 views)
2018-03-24 14:47:39

ivj94 (79 views)
2018-03-24 14:46:31

ivj94 (555 views)
2018-03-24 14:43:53

Solater (94 views)
2018-03-17 05:04:08

nelsongames (168 views)
2018-03-05 17:56:34

Gornova (338 views)
2018-03-02 22:15:33

buddyBro (998 views)
2018-02-28 16:59:18
Java Gaming Resources
by philfrei
2017-12-05 19:38:37

Java Gaming Resources
by philfrei
2017-12-05 19:37:39

Java Gaming Resources
by philfrei
2017-12-05 19:36:10

Java Gaming Resources
by philfrei
2017-12-05 19:33:10

List of Learning Resources
by elect
2017-03-13 14:05:44

List of Learning Resources
by elect
2017-03-13 14:04:45

SF/X Libraries
by philfrei
2017-03-02 08:45:19

SF/X Libraries
by philfrei
2017-03-02 08:44:05 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!