DevLog 003 — Zoom levels
Although, it’s been almost two weeks since I finished implementing changing zoom levels I didn’t want to make a post about it until I’m done with some more refactoring.
The best thing about it is that it works relatively simply when combined with hex texture cache (which I wrote about the last time). When I change zoom level I remove all cache sprites and create them again for the new zoom level. This required some refactoring on my part which at the end simplified and decoupled things very nicely.
Since I’m using RxJS Observables a lot, updating minimap viewport or any other plugin works very smoothly. Changing zoom level changes map scroll offset which triggers viewport update.
There’s not much more to say. As a part of this I also started preparing the map component to be able to handle changing the underlying grid which means changing its size and more importantly hex textures on fly. This means disposing all cached textures (for all enabled plugins) and recreating them.
The simplified map component now requires only two inputs. Grid size and a function that returns a texture for each hex on the map.
This is going to make my life easier in the future because the next step is creating UI for world generator which is going to require switching grids and redrawing map a lot.