Sunday, December 7, 2014

Beginnings of worldgen (with pics) and spinoff projects

I got some basic worldgen done this week. Just creating a bare island and walking around on it but that's not bad for one week starting from scratch with a language I'm still learning.



Building the island's elevation uses a blend of a few different techniques:

First, create a heightmap by throwing down a bunch of sorta-centered blobs with a random height and radius. A percentage of the blobs will have negative height and reduce the elevation. Keep throwing blobs until you have enough land. I think this has interesting and island-like coastlines with and good variation of height. It can be weirdly mesmerizing too.


Using the first heightmap, create a second heightmap based on the distance from the water. I think this looks neat on it's own and when there's jagged coastlines it reminds me of what real mountain ranges look like from above.


Using the first heightmap again, create a third heightmap based on simplex noise. Water has zero height and everything else is a noise lookup.


Once you have all three heightmaps, multiply each by a different weight and add them together form a final height map. By changing the multipliers for each, you can adjust the overall look to get the best of each map with few downsides.


Finally, I want the highest parts to really stand out above everything else so I do one last thing: cube each height (that is, set each height to height * height * height). This effectively pushes the lowest parts down and increases the contrast for the higher elevations.


That looks okay. I'm sure it will change more.
An in-game map.
Each tile on the map represents "chunk" of 30x30 tiles for now. As you walk around, nearby chunks are instantiated as needed based on the overall map. It's blocky and not very exciting though.
Much higher elevation to the west, much lower elevation to the east. One level higher to the south and one level lower to the south east.

I think I can do something like a midpoint displacement algorithm to make it less blocky. Adding up-slopes and down-slopes at elevation boundaries and hiding the interior of the higher elevation should help make it look better too. That should keep me busy for a week.

Edit: It took about three hours. The midpoint displacement wasn't working how I thought it would so I lerp the midpoints and add a bit of noise instead.



Doing all that was almost 350 lines of Clojure so I moved some functionality into separate open source libraries.

super-simple-window: Java Swing windows can have a ton of callbacks and settings that need to be done in a specific order and I always forget how to do it right. This is one function that creates a JFrame with a Canvas that uses all the settings and callbacks you supply: title, width, height, on-render, on-key-press, etc. Even makes a timer if you supply an on-timer callback.

render-terminal: Render terminal-like data to a Java Swing Graphics object. Call render with a map of points to character data. Does a bunch of caching to keep things fast. Supports 9x16, 10x10, and a 12x12 font so far but it's easy to extend.

33 comments:

  1. I’ve desired to post about something similar to this on one of my blogs and this has given me an idea. Cool Mat.
    python training in pune
    python online training
    python training in OMR

    ReplyDelete
  2. This is most informative and also this post most user friendly and super navigation to all posts... Thank you so much for giving this information to me.. 
    Devops training in velachery
    Devops training in annanagar
    Devops training in sholinganallur

    ReplyDelete
  3. The knowledge of technology you have been sharing thorough this post is very much helpful to develop new idea. here by i also want to share this.
    Blueprism training institute in Chennai

    Blueprism online training

    Blue Prism Training Course in Pune

    Blue Prism Training Institute in Bangalore

    ReplyDelete
  4. Thanks for this amazing post its help me a lot to solve my issues click here to download Kinemaster Mod APK

    ReplyDelete
  5. Hi,
    Good job & thank you very much for the new information, i learned something new. Very well written. It was sooo good to read and usefull to improve knowledge. Who want to learn this information most helpful. One who wanted to learn this technology IT employees will always suggest you take python training in bangalore. Because python course in Bangalore is one of the best that one can do while choosing the course.

    ReplyDelete
  6. Thanks for this amazing post
    "Sanjary Academy provides excellent training for Piping design course. Best Piping Design Training Institute in Hyderabad,
    Telangana. We have offer professional Engineering Course like Piping Design Course,QA / QC Course,document Controller
    course,pressure Vessel Design Course, Welding Inspector Course, Quality Management Course, #Safety officer course."
    Piping Design Course in India­
    Piping Design Course in Hyderabad
    Piping Design Course in Hyderabad
    QA / QC Course
    QA / QC Course in india
    QA / QC Course in Hyderabad
    Document Controller course
    Pressure Vessel Design Course
    Welding Inspector Course
    Quality Management Course
    Quality Management Course in india
    Safety officer course

    ReplyDelete
  7. Thanks For sharing information
    Yaaron Studios is one of the rapidly growing editing studios in Hyderabad. We are the best Video Editing services in Hyderabad. We provides best graphic works like logo reveals, corporate presentation Etc. And also we gives the best Outdoor/Indoor shoots and Ad Making services.

    Best video editing services in Hyderabad,ameerpet
    Best Graphic Designing services in Hyderabad,ameerpet­
    Best Ad Making services in Hyderabad,ameerpet­

    ReplyDelete
  8. Hey, very nice site. I came across this on Google, and I am stoked that I did. I will definitely be coming back here more often. Please feel free to visit our site. Thank you for sharing. Well written article Thank You for Sharing with Us

    ReplyDelete
  9. Thank a lot for this post that was very interesting. Keep posting like those amazing posts, this is really awesome :)
    Looking for PMP Certification, Visit on:thanks a lot guys.
    Ai & Artificial Intelligence Course in Chennai
    PHP Training in Chennai
    Ethical Hacking Course in Chennai Blue Prism Training in Chennai
    UiPath Training in Chennai

    ReplyDelete
  10. Thank you for sharing such beautiful information. If you want to buy Gift for men" then you can visit Ubiqart. Here we have different range of products.

    ReplyDelete
  11. If you're looking for something specific, you can always use the search bar to find exactly what you're looking for. Plus, movies flame is always updating their selection, so you'll never miss a new release.

    ReplyDelete
  12. For a quick and accurate Gali result, Deshawar result, you may visit Satta king Matka, a game that is popular among teenagers. 

    ReplyDelete
  13. Thanks for sharing. BEglobalus offers the Web Development Services in Michigan. You can quickly boost online traffic and attract more customers with proper assistance.

    ReplyDelete
  14. This website is incredibly educational, fascinating, and well-written, in my opinion. Keep up the good, excellent writing. best inventory management software

    ReplyDelete
  15. Thank you for Information its good research work

    Here is sharing some data integration and analytics AlterYX concepts may be its helpful to you.
    AlterYX Training

    ReplyDelete
  16. Enjoy flexible and affordable monthly car rental options in Bahrain. Choose from a wide range of reliable vehicles, benefit from competitive rates, and receive exceptional customer service. Monthly car rental in Bahrain

    ReplyDelete
  17. This comment has been removed by the author.

    ReplyDelete