Tech Stuff – Data handling

This is a bit of a technical post where I try and explain how I’m handling the data during ship building. I hope with these posts I can provide info to anyone interested in game development, and maybe some answers to devs trying to do similar things later.  I’m not too used to writing blogs so I hope my content will improve over time!

This week I reworked the way the game stores item information as the standard grid method I was using was too inefficient.  In the original method, if a ship was a long flat shape, say 10×200 tiles, the standard grid method required a grid of 200×200, meaning an unused 36,100 (190×190) tiles were being stored.

Now, I’m trying to get the system working purely using 2D vectors (X and Y) relative to the ship actor’s origin.  To get their neighbours I’m adding the tile size to the X and/or Y coordinates.  Vectors get added to an array of “used” vectors as they are built on.  To restrain ship sizes, instead of having a list of grid edge tiles, I now just check to make sure the new tile is within a range; between XY:0 and XY:’Grid Size’.

There’s a big global list of items that stores their stats and unique ID number.  Rooms, zones, and individual tiles all have lists storing the ID Numbers of the items they contain.  The item info can then be retrieved using the reference.