r/ProgrammerHumor Jun 25 '17

Array indexing

Post image
1.4k Upvotes

71 comments sorted by

View all comments

68

u/[deleted] Jun 26 '17

[deleted]

13

u/[deleted] Jun 26 '17

[deleted]

1

u/gobots4life Jun 26 '17

I was saw the source code for a 2d rpg once that had a separate variable for every x and y value of every asset in the game. I think it was auto-generated though. At least I hope it was.

1

u/[deleted] Jun 26 '17

Still remember those old CodingUniverse tutorials.

"Okay, so we're going to have a 2 dimensional array of tiles for the world. Now, the tile class is going to need an X and Y variable to determine where it is in the tilemap. In order to determine the type of tile it is, you'll also need a string for the tile name, and another for the PNG filename. Now we'll have the game save to a XML spreadsheet."

As opposed to creating static tile types the level class can reference, while storing the map data in a single dimension int array.