Results 1 to 7 of 7
  1. #1
    totalspelnerd is offline Member
    Join Date
    Mar 2012
    Location
    Sweden
    Posts
    88
    Rep Power
    0

    Default Random World Generation like terraria?

    I have decided I want to make a game somewhat like terraria to get my coding skills up but there is one problem. The world generation. I have no idea how to make it so I would like someone to give me a good tutorial/tutorials on how i can make this work. I have looked around on google but I couldn't really find anything :(. FYI I haven't started on the project yet so I can't give out any code to you.

  2. #2
    Nyxeka is offline Member
    Join Date
    Mar 2012
    Posts
    4
    Rep Power
    0

    Default Re: Random World Generation like terraria?

    Start by creating a world with 3 levels of "blocks", all in "chunks"...
    Lets look at Minecraft.
    Have the bottom layer: unbreakable
    have the second layer: rock/harder/minerals
    have the third layer: dirt/soft

    Alright, first, you want to be able to generate a world with something like that.

    Following up, you would want to randomly generate a number for the X axis, and then generate a random Y value.

    Take this number on the x axis, and on that location, raise up the rock, Y height, then draw dirt over it again

    after this is done, you might want to add trees or something, and minerals/ores in the rock. Generate more random numbers, which are coordinates somewhere in the rock layer, and put ores there. For the rarer ores, generate larger random numbers, and maybe set the Y axis to be lower down in the rock, and space the rare ores as far apart as these randomly generated numbers.
    -same thing for the trees.

    Good luck ^_^

  3. #3
    totalspelnerd is offline Member
    Join Date
    Mar 2012
    Location
    Sweden
    Posts
    88
    Rep Power
    0

    Default Re: Random World Generation like terraria?

    thanks, one thing though, how can i generate cave structures? I don't want random one block caves everywhere

  4. #4
    Nyxeka is offline Member
    Join Date
    Mar 2012
    Posts
    4
    Rep Power
    0

    Default Re: Random World Generation like terraria?

    Quote Originally Posted by totalspelnerd View Post
    thanks, one thing though, how can i generate cave structures? I don't want random one block caves everywhere
    Eh, I would recommend just generating more random coordinates, and making round-ish holes, possibly generate 2 random coordinates near each-other, with a "cave" between them, then use some algorithm to make the cave slightly irregular in between...

  5. #5
    phyzix5761 is offline Member
    Join Date
    Nov 2012
    Posts
    43
    Rep Power
    0

    Default Re: Random World Generation like terraria?

    Here is something I wrote in lua. Maybe it can give you some ideas:

    [Lua] local randMove = 0 local prevMove = 0 local newMove = 0 local rTile = 0 lo - Pastebin.com

    Here is a variation(more complex) of the code written in C:

    [C] int randMove; int prevMove; int newMove; int rTile; int nTile; int move - Pastebin.com

    Note that this produces 2D landscape like Terraria.

  6. #6
    J-max04 is offline Member
    Join Date
    May 2012
    Posts
    17
    Rep Power
    0

    Default Re: Random World Generation like terraria?


  7. #7
    InfiniteCoder is offline Member
    Join Date
    Mar 2013
    Posts
    5
    Rep Power
    0

    Default Re: Random World Generation like terraria?

    Try [Moderator edit: link removed] user, he has a Minecraft 2D tutorial in pure java, and you can adapt it to yours!
    Last edited by DarrylBurke; 03-02-2013 at 09:41 PM. Reason: link removed

Similar Threads

  1. World Generation?
    By Alerhau in forum New To Java
    Replies: 11
    Last Post: 08-14-2011, 05:50 PM
  2. Random shape generation
    By zeeextra in forum New To Java
    Replies: 0
    Last Post: 12-04-2009, 06:57 AM
  3. Trouble with Random number generation
    By SteroidalPsycho in forum New To Java
    Replies: 9
    Last Post: 11-17-2009, 12:15 AM
  4. Random number generation
    By toasty in forum New To Java
    Replies: 1
    Last Post: 09-30-2009, 12:41 PM
  5. random generation
    By carlos123 in forum New To Java
    Replies: 10
    Last Post: 01-09-2008, 04:43 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •