Page 1 of 1

Random Generated World

Posted: Tue Apr 28, 2015 6:42 pm
by ArterianGames
Hey guys!

Im pretty new to Love2D, so I dont know how to do anything.... I would like to learn how could I make as the title says, random generated world. It would be like 2D Minecraft, Terraria, Magicite or something 2D Blocky... :D If you can, pm me your skype name, so if I need anything else, I can directly ask you.

Re: Random Generated World

Posted: Tue Apr 28, 2015 7:52 pm
by Bigbadbeee
What type of map are you using EX: map = { 1,4,3,2 }, Tiled?

If you are using map = {} then
if you want just the first 3 layers to be random then do this

Code: Select all

 tile = {}
           tile[1] = "path.to.tile.image"
           tile[2] = "path.to.tile.image"
           tile[3] = "path.to.tile.image"
           tile[4] = "path.to.tile.image"
tilepick = math.random(1,4) -- you have "4" tiles
map = {tilepick,tilepick,tilepick
           tilepick,tilepick,tilepick
           tilepick,tilepick,tilepick
           4,4,4 }

Re: Random Generated World

Posted: Wed Apr 29, 2015 1:15 am
by I~=Spam
If you want to use a seed just like minecraft where if you have the same seed it will always generate the same map, you would use perlin noise. I don't think I said that very well... Oh well. Anyway, here's some links: ;)

http://en.wikipedia.org/wiki/Perlin_noise
http://devmag.org.za/2009/04/25/perlin-noise/

Perlin noise has a lot of advantages... I am not expert but one of them is that you will get groups of about the same value. This makes it so that it is not entirely "random". If you were to make something similar to minecraft you want clusters of ore to form not just scattered in random places.

Here is a picture of perlin noise.

Image

Re: Random Generated World

Posted: Wed Apr 29, 2015 6:10 am
by ArterianGames
BigBadBeee, I didn't really do anything yet, I just made the simple functions, window, and a player image... I don't even know how to use the tiles... Anybody I could add on skype for help? pls? :D