Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Could I have an in-memory data structure that stores which grid cells are occupied and by which tile? Resizing a tile would store which tile occupies which cells, so that could work. #257

Open
DrewNaylor opened this issue Sep 6, 2023 · 0 comments

Comments

@DrewNaylor
Copy link
Owner

So it'll be like (this is JSON):

{cell: [coords: 0-0, occupiedBy: 0-0], 
cell: [coords: 0-1, occupiedBy: 0-0], 
cell: [coords: 0-2, occupiedBy: 0-2], 
cell: [coords: 0-3, occupiedBy: 0-2], 
cell: [coords: 1-0, occupiedBy: 0-0], 
cell: [coords: 1-1, occupiedBy: 0-0], 
cell: [coords: 1-2, occupiedBy: 0-2], 
cell: [coords: 1-3, occupiedBy: 0-2]}

And so on. occupiedBy will be used to look up the tile in a specific spot if necessary, or simply calculate the tile's size if possible as that will be an easier way to see if another tile will fit nearby. If coordinates are not recorded in the data structure, then it's assumed that cell is empty but the tile will still need to be sure it can fit.

I'm not going to use the YAML layout file for this because I need to be able to update this in memory and I can't store too much in memory as that would be bloated.

When pinning, unpinning, and resizing, we will consult this data structure to see where the new tile should go, whether tiles can shift up (if all tiles in a row are unpinned; don't shift tiles around when unpinning if a row is not empty as that's not what WP did I think), and whether tiles need to be pushed to the next row or if they can be pushed to another column, respectively. This will also be used when loading tiles to ensure they don't overlap each other, which should only be a problem when converting the previous tile layout file to the new one with columns and rows.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant