Share your repls and programming experiences

← Back to all posts
Terrain Generation
h
DynamicSquid (3294)

YES
Yes @HahaYes Yes Haha YES

I-I don't know why I did that...


Anyway, here's some terrain generation for you guys! Green is land, blue is water.

Here's how I did it:

  1. Randomly assign each value in a grid to be either water or grass
  2. Count how many land tiles surround each tile
  3. If it's more than four, then turn it to land
  4. Repeat step 3 about 8 times
  5. That's it!

It's not the best, and there are way better algorithms than this, but this is meant to be a quick way of doing so. I also made this in about an hour, so it may not be too good...

Enjoy :)

Commentshotnewtop
DynamicSquid (3294)

@TheForArkLD Thanks! But this code can be easily turned into js

TheForArkLD (714)

@DynamicSquid ow.
can you teach cpp to me?

DynamicSquid (3294)

@TheForArkLD well, it's just a bunch of for loops and if statements. Also, I'm a little too busy to be a teacher, but if you got a question, I'd be happy to answer it :)

TheForArkLD (714)

@DynamicSquid if you are free then i want do c# with you :)

DynamicSquid (3294)

@TheForArkLD umm... I'm not really trying to do C# right now..

Highwayman (1341)

NOICE

Too bad your moving away from this for a bit? How did you make the square grid thingies?

DynamicSquid (3294)

@Highwayman yeah, I really want to keep making cool stuff in the console like this, but I'm busy with other stuff. I'm working on creating a language, and when I'm done with that, I'm moving away from C++ and learning Unity, so this is probably my last console thing for a while...

also I used this: ■

Highwayman (1341)

@DynamicSquid oh.. Unity sounds cool tho :P also ty

ridark (52)

Next: DynamicSquid, makes terrain generator and makes a player that can be moved by W, A, S, D. (Just an idea).

DynamicSquid (3294)

@Programmer567 oh yeah, that's definitely in my bucket list! but I'm going to leave console games for a while since I have some other stuff I want to get done

DynamicSquid (3294)

@Programmer567 sry for the late reply btw :)

adityaru (150)

Nice! This is some what like cellular automaton (Conway's game of life)...

HahaYes (1190)

Hey Dynamic Squid - HAHA Y E S S S S S

Cookiezz (65)

Cool! But why are there question marks in the terrain?

DynamicSquid (3294)

@Cookiezz yeah that's actually a good question, I have no clue. Sometimes they're there, sometimes they aren't

sugarfi (521)

@DynamicSquid that could be an issue with printing the ANSI escape character (\x1b or whatever) in the wrong place.

Cookiezz (65)

@DynamicSquid Isn't it 2:37 for you? Why are you still awake? lol

Cookiezz (65)

@DynamicSquid ... uh sorry then I probably got confused.. Oh so your in the US right?

DynamicSquid (3294)

@Cookiezz Nope Canada, I'm in MT time

Cookiezz (65)

@DynamicSquid My brain right now: 😵🤯🙃🤪

Cookiezz (65)

@DynamicSquid Im so confused... because somebody else said BST... and I forgot who it is.. I thought it was you, but I guess not.. well whatever

sugarfi (521)

@DynamicSquid you know how you have to print out \x1b or \033 to print stuff in color? If you put that in the wrong spot, it would probably show up as a question mark.

DynamicSquid (3294)

@sugarfi ohhh okay, but sometimes it shows the question mark, and sometimes it doesn't...

HahaYes (1190)

@DynamicSquid you canadian? Your highways must be measured in maple syrup and mooses

DynamicSquid (3294)

@HahaYes nope, my highways are measured using the normal units, kilometers

HahaYes (1190)

@DynamicSquid O not maple syrup?
I thought you lived in Canadia

DynamicSquid (3294)

@HahaYes no I do but that was joke, since km are "normal" units

HahaYes (1190)

@DynamicSquid me american be like: football fields?

DynamicSquid (3294)

@HahaYes we're so similar but also so different it's kinda funny sometimes

HahaYes (1190)

@DynamicSquid you have maple syrup, I have..... hot dogs?

Cookiezz (65)

@DynamicSquid For us, normal is mph lol

Cookiezz (65)

@HahaYes hot dawgs and burgerzz =D

CarlosRosiles (179)

Nice. Its like how Minecraft generates infinite land!

MrTrex (16)

How did you color the squares?

MrTrex (16)

This would be great for survival

HackerMan0303 (2)

Where did you learn how to code ?

DynamicSquid (3294)

@HackerMan0303 I'm self taught. Been reading books and looking at whatever I find on the internet.

HackerMan0303 (2)

@DynamicSquid Wich books did you read ? Im trying to learning how to code, apologise for my bad english

EDKTHEPRO (16)

That's cool! Do you think you can make it to make random terrains?

HahaYes (1190)

@DynamicSquid I'm bout to make Crappybird

HahaYes (1190)

@DynamicSquid can I get a picture of your OG squid? Need it for my game.(or can you crop that squid picture from the background?)