Created
          March 14, 2021 23:00 
        
      - 
      
- 
        Save victorholt/78e3019a2e6d7a6c3d07d155c951caee to your computer and use it in GitHub Desktop. 
Revisions
- 
        victorholt created this gist Mar 14, 2021 .There are no files selected for viewingThis file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,41 @@ #include <iostream> #include <string> #include <vector> static std::vector<int> map; static int mapSize = 3; int initMap() { for (int i = 0; i < (mapSize * mapSize); i++) { map.push_back(0); } } int setMapValue(int index, int value) { auto nx = index % mapSize; auto ny = index / mapSize; auto mIndex = nx + ny * mapSize; map[mIndex] = value; std::cout << "Setting Map Data at (" << nx << ", " << ny << ")" << std::endl; } void printMap() { for (int y = 0; y < mapSize; y++) { std::cout << "[ "; for (int x = 0; x < mapSize; x++) { std::cout << map[x + y * mapSize] << " "; } std::cout << "]" << std::endl; } } int main() { initMap(); setMapValue(0, 5); printMap(); }