Page 1 of 1

How would i be able to create random tile generation?

Posted: Tue Dec 13, 2016 12:48 am
by trash_mann
Hello i've been using love2d on and off and have recently come back to it and love it!
I made a basic tile system (Using code from a tutorial i found but i understand it) and have been scratching at my head trying to figure out how to do random tile terrain generation.do i use love.math.random() or how do i do it.Sorry if this is a noob question.

Re: How would i be able to create random tile generation?

Posted: Tue Dec 13, 2016 1:02 am
by Jasoco
Look into love.math.noise. There's also a lot of resources on the internet if you Google. But basically noise is your starting point.

Re: How would i be able to create random tile generation?

Posted: Tue Dec 13, 2016 1:47 am
by raidho36
Dungeon (or terrain) generators are fun and difficult. There are a lot of hidden challenges in getting computer generated worlds to look at least somewhat natural, and there are many approaches to do so. Variety is so immense it can't be comprehensively covered even in extremely large article, so you'll just have to prod around individual solutions. Look up dungeon and map generators related articles on the web, try to come up with your own generators.

Note that love.math.noise is a simplex noise specifically, not just any kind of noise; it is perlin noise for 3 and 4 dimensional noise.

Re: How would i be able to create random tile generation?

Posted: Tue Dec 13, 2016 12:39 pm
by Smoggert
You can check out these fiddles for some inspiration (not heavily commented).

http://lovefiddle.com/H56HHtA4mCJnEM5pY (Random dungeon generator) This one is very well ilustrated in that it actually shows how its working visually.
http://lovefiddle.com/cNr47LHZn4vLJm44t (Simplex terrain height map) This one (a bit bloated cuz its made by me), lets u play around with some vars to create a randomly generated heightmap with the noise function.

I take it both have code that could be of use.
I've since optimised the code for the simplex map a fair amount but cba to rerwrite it for a new fiddle xD

Since a lot depends on the perspective you want to use and the scope of the game, the math will look a lot different depending on your actual game.