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

TilemapBundle::grid_size should scale images #337

Open
Laocoon7 opened this issue Nov 7, 2022 · 2 comments · May be fixed by #376
Open

TilemapBundle::grid_size should scale images #337

Laocoon7 opened this issue Nov 7, 2022 · 2 comments · May be fixed by #376

Comments

@Laocoon7
Copy link

Laocoon7 commented Nov 7, 2022

I believe it should be in TilemapBundle, but I may be wrong.

Currently, TilemapBundle::grid_size cuts images off if smaller than TilemapBundle::tile_size or adds padding to the left and above if larger. The expected result is a scaled tile image which matches TilemapBundle::grid_size.

This would allow a custom orthographic projection mapping where world space coordinates are the same as tile position without needing to re-adjust the orthographic projection's scale per tileset size. This would also allow use of multiple tileset's where the aspect ratio is identical even if the tile sizes are not. Traditionally Bevy's Sprite::custom_size could be used to achieve the same result.

If I have misinterpreted grid_size, or a breaking change like this is not allowed, an additional field for TilemapBundle::tile_custom_size or the like would be requested.

@bzm3r
Copy link
Collaborator

bzm3r commented Nov 11, 2022

@Laocoon7

In the case when grid size > tile size:

  • no padding is added, it appears as if there is padding because the tile size is not scaled

In the case when grid size < tile size:

  • no cutting off is done: it appears as if mages are being cut off because the tile size is not scaled

Grid size is the "logical size" of the grid positions of the underlying tile map. Put differently, it is the distance between grid positions. For example, if grid size is (10, 20), the x-distance between position (0, 0) and (1, 0) will be 10 while the distance between (0, 0) and (0, 1) will be 20.

Tile size is the "physical size" of the tiles being placed at each grid position. In particular, it is used to figure out the region of input texture that should be read from in order to visualize the tile.

So, if scaling is required by the user, the best thing to do would be to provide a tile_custom_size which by default will be tile_size. This is something we can do.

@rparrett
Copy link
Collaborator

rparrett commented Jan 13, 2023

Adding another component to control "tile world size" is probably the better solution, but

  • Is it possible to accomplish this sort of thing by modifying the Tilemap's Transform's scale?
  • What about adding a TileScale field that could default to Vec2::splat(1.)

I have a concern that the TilemapBundle is becoming quite unwieldy with a bunch of components that are not super clearly distinguished that a typical user will be setting the same value.

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