My current project is a 2D platformer in an infinite world, where players can build and mine. This is basically a follow-up of one of my last projects. The game only renders cells that are visible on the player’s screen.
The issue here is that I only have dirt at the moment. I want to implement biomes in a performant way, but I am not sure how. The game finds the material of each cell by its position, so I need to build a system that is able to take in the coordinates of a cell and output its material. The following code (written in TypeScript with roblox-ts) is what I have right now, but it does not support biomes and only returns dirt and air.
import CellTypeName from "./CellTypeName";
const a = 50;
export default abstract class WorldGeneration {
public static GetCellTypeName(x: number, y: number, z: number): CellTypeName {
return y < math.noise(x / 30, y / 30, 123) * a - a ? "Dirt" : "Air";
}
}
I was thinking about generating noise maps for variables such as moisture and temperature, although I am not sure how to get a biome and material from that.
Please let me know if you find TypeScript confusing, cause I can translate it to Luau!