Last active
November 15, 2018 11:44
-
-
Save mishazawa/ae453536534c275b11c9b76ce2262320 to your computer and use it in GitHub Desktop.
1d array vs 2d array
This 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 characters
| // 1d array | |
| for (int i = 0; i < array.size(); i++) { | |
| int row = i / mapWidth; | |
| int column = i % mapWidth; | |
| drawImage (column * tileWidth, row * tileHeight); | |
| } | |
| // 2d array | |
| for (int x = 0; x < array.size(); x++) { | |
| for (int y = 0; y < array[x].size(); y++) { | |
| drawImage(x * tileWidth, y * tileHeight) | |
| } | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment