Optimization Ideas

Godot Version

4.6

Question

Hello! I’m working on a 2D block game similar to the likes of Terraria and Starbound.

My game utilizes servers to store world data rather than a local file. Authoritative servers are responsible for saving, loading and processing world data such as block and background positions.

I’m not the most tech savvy guy when it comes to optimization! I’ve spent most of my time learning other areas of development.

Currently, my world data is a huge array of dictionaries.

Each tile has a block id, background id, and metadata. This data tells the client what to load in that spot.

On my client, blocks have their own TileMapLayer and so do backgrounds.

My question is, is there a better way to store this world data and convert it later when loading?

Do you see any possible optimizations here?

The server code is written in Rust.

Start by profiling and determining the actual bottlenecks. Without knowing those, any optimization is a waste of time. And watch out not to succumb to premature optimization.

Bandwidth is a bottleneck you can’t control, so packing the data you send to the client and reducing the amount of requests may be helpful.

Probably making sure all the info fits into your Rust runtime’s working memory will help to prevent disk I/O. Keep image data with the client of course.

I’m sure these things are obvious to you already.