How would i be able to create random tile generation?

Questions about the LÖVE API, installing LÖVE and other support related questions go here.
Forum rules
Before you make a thread asking for help, read this.
Post Reply
trash_mann
Prole
Posts: 1
Joined: Tue Dec 13, 2016 12:44 am

How would i be able to create random tile generation?

Post 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.
User avatar
Jasoco
Inner party member
Posts: 3725
Joined: Mon Jun 22, 2009 9:35 am
Location: Pennsylvania, USA
Contact:

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

Post 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.
User avatar
raidho36
Party member
Posts: 2063
Joined: Mon Jun 17, 2013 12:00 pm

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

Post 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.
User avatar
Smoggert
Prole
Posts: 29
Joined: Thu Nov 10, 2016 11:23 pm

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

Post 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.
Post Reply

Who is online

Users browsing this forum: Bing [Bot] and 194 guests