Which algorithm could I use to generate ore veins in a 2D (side) view? Where I can adjust how much the ore is generated?
Kind of like this
How to generate clumps of minerals?
- Gunroar:Cannon()
- Party member
- Posts: 1091
- Joined: Thu Dec 10, 2020 1:57 am
Re: How to generate clumps of minerals?
Have you tried thinking instead of asking?
- Pick a random coordinate
- Pick two random numbers for offset.
- If coordinate + offset is dirt, replace it with mineral.
- Repeat steps 2 and 3 as many times as desired.
- Gunroar:Cannon()
- Party member
- Posts: 1091
- Joined: Thu Dec 10, 2020 1:57 am
Re: How to generate clumps of minerals?
Hmmm, that's a nice and clean solution, I guess I was expecting something like cellular or perlin noise.
Also does that method deal with bigger clumps? From what I understand won't most of the clumps look the same?
Re: How to generate clumps of minerals?
Create particle, add some mineral here.Gunroar:Cannon() wrote: ↑Tue Oct 19, 2021 9:58 pm Also does that method deal with bigger clumps? From what I understand won't most of the clumps look the same?
Create new particle and move both of them in random direction.
Repeat until you want.
- Gunroar:Cannon()
- Party member
- Posts: 1091
- Joined: Thu Dec 10, 2020 1:57 am
Re: How to generate clumps of minerals?
What's a particle in your terminology?
Re: How to generate clumps of minerals?
The thing that will be created, it moves and disappears, maybe generates other particles.
It can move freeways as
Code: Select all
x,y=x+dt*vx,y+dt*vy
Code: Select all
x,y=x+math.random(-1,1)*chunkSize, y+math.random(-1,1)*chunkSize
After the movement it can check if it can place here some ore, creates another particle, counts one step down and if it is lower than lowest value, then disappears.
Re: How to generate clumps of minerals?
There are going to be dozens - if not hundreds - of ways to accomplish this. The "best" will be determined by your desired outcome. Do you want random blobs? Seams of ore that branch? Tiny specs here and there? etc... You could certainly use a cellular automata (you'll get a LOT of ore) or a 2D noise map (with a set threshold) for a more fine-tuneable setup.
Any code samples/ideas by me should be considered Public Domain (no attribution needed) license unless otherwise stated.
- Gunroar:Cannon()
- Party member
- Posts: 1091
- Joined: Thu Dec 10, 2020 1:57 am
Re: How to generate clumps of minerals?
I kind of want to use both random blobs (I guess pgimeno's method works for that) and seems of ore that branch...
Re: How to generate clumps of minerals?
Please try this solution (click on the screen):Gunroar:Cannon() wrote: ↑Wed Oct 20, 2021 1:44 pm I kind of want to use both random blobs (I guess pgimeno's method works for that) and seems of ore that branch...
- Gunroar:Cannon()
- Party member
- Posts: 1091
- Joined: Thu Dec 10, 2020 1:57 am
Re: How to generate clumps of minerals?
Woah, that's really cool though advanced. So I could just make the white parts minerals . I just ran it but haven't checked out the code, any way to scale it?
Who is online
Users browsing this forum: No registered users and 2 guests