Infinite 2D Terrain Generation (Open Source)

Introduction

A while ago @Beeplets and I worked on a project named ‘FlatMine’. It is a two dimensional mining game that is mainly inspired by Terraria and Minecraft. It features terrain generation with biomes and caves. The textures and models were made by @Beeplets.

The open sourced game can be found here. I figured that it would be a shame to let it sit in my games catalog. Therefore, I decided to publish it to at least share it with people.

Also, there is a spawn protection with a radius of about 20 blocks, which prevents players from mining the spawn.

Terrain Generation

Rendering a nearly infinite world


Generated terrain from a distance.

FlatMine’s terrain is made to be nearly infinite. The game draws the terrain on the client and only selects cells that are visible within the user’s point of view. This gives the game a limited amount of cells to render. Each cell can be either cached (due to interactions with the world like mining) or generated.

The game’s terrain generation is based on a seed. This makes it completely pseudo-random. World are recreatable with a seed just like in Minecraft.

Biomes


A mountain biome.


A desert biome.

The game features multiple biomes that are based on noise.

Caves


Some randomly generated caves.

The caves are also based on noise. They become thinner by depth.

UI


The in-game shop UI.

At the moment, there is a shop and inventory UI. The user can buy a new pickaxe in the shop and select it in the inventory.

The shop items have a three dimensional preview, which might be interesting to look at if you want to make one yourself.

Discussion

Security

The terrain generation processes are client-side and therefore vulnerable to potential attacks. Attackers can directly influence the terrain generation by accessing the client-sided scripts.

Lack of gameplay elements

I am an engineer type of guy who struggles with creating beautiful UI and solid gameplay elements, which is one of the reasons why I decided to discontinue this project. This game is far from finished, cause there is no real gameplay. At the moment, it is no more than a showcase.

26 Likes

This is a really cool creation and it is sad to see it be discontinued, however, it is very respectable to see you open-sourced it for anyone else to continue the legacy. I’ll probably try this out at some point in the near future as it is interesting and honestly the first time I have seen something “Terraria-like” in Roblox. Good work.

2 Likes

I might make another game like this. Feel free to take a look!

2 Likes

I know it’s very old, but I would like to say I cannot access the game, I would really like to, it looks great

That is strange. It is public and ‘Place Copying’ is enabled, so you really should be able to edit the place in studio.

Wait o feel dumb, I’m not on PC that might be why LOL

Also thanks for the response

This is solid. Wish 2D games had a larger appeal in the community.