Quantcast
Channel: Community | MonoGame - Latest topics
Viewing all articles
Browse latest Browse all 6821

Infinite tile generation

$
0
0

@Jelle wrote:

I've recently made a simple infinite tile generator for a running project.
I think that it works decent, but it has room for improvement. I'm curious as to what improvements I can make to make it run better on older computers. The generation system does not have complex generation code yet.

You can download the generator here (it's the Speed Farmers infinite world test v1, project page is very old)

The infinite generator works with a Region class. A region is similar to a chunk in Minecraft, but in 2d. It currently holds 16 x 16 tiles. Each region has a position, and a RegionManager class manages which regions need to be loaded (/unloaded).

The region manager executes the loading and unloading functions each time the camera moves, and the regions that get out of the screen boundaries are unloaded and encoded to a binary file on the drive. Regions that need to be loaded are newly generated or loaded from the drive when they already exist.

Unloaded regions are removed from memory and the tiles that are in the region are also gone, so only the regions that can be seen on the screen are drawn.

The Tile class is a child class of the ObjectInstance class. This class is the parent class for all types of objects in the game (tiles, items, ...). It currently holds a position (vector2) and a GameObject (and maybe a future texture index int for autotiling). The game object has all the shared information of that type of object. This demo currently has 2 game objects: grass and a field.

Some images of the generator:

Posts: 2

Participants: 2

Read full topic


Viewing all articles
Browse latest Browse all 6821

Trending Articles