Skip to content

Improve documentation of tile indexing in Outpost 2 #332

Description

@Brett208

Could we add more detail to the Map class explaining how tile indexing works? It could be placed in the map header or within the GetTileIndex function.

I wanted to write a function that allows changing the map size dynamically, but to do that, I need to understand the indexing better.

// Helper method to handle complex tile data indexing
std::size_t Map::GetTileIndex(std::size_t x, std::size_t y) const
{
	auto lowerX = x & 0x1F; // ... 0001 1111
	auto upperX = x >> 5;   // ... 1110 0000
	return (upperX * heightInTiles + y) * 32 + lowerX;
}

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions