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

Spacing fixes #309

Merged
merged 4 commits into from
Oct 10, 2022
Merged

Spacing fixes #309

merged 4 commits into from
Oct 10, 2022

Conversation

StarArawn
Copy link
Owner

Fixes: #260
Closes: #301

@StarArawn StarArawn requested a review from bzm3r October 9, 2022 14:52
@StarArawn
Copy link
Owner Author

@antoinePaulinB7
I kept your commits here, fixed some of the math, and provided an example.

(texture_size.x + tile_spacing.x) / (tile_size.x + tile_spacing.x);
let tile_count_y =
(texture_size.y + tile_spacing.y) / (tile_size.y + tile_spacing.y);
let tile_count_x = ((texture_size.x) / (tile_size.x + tile_spacing.x)).floor();
Copy link
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You need to floor here because otherwise you can get tile counts that are larger than what's available in the atlas.

+ spacing.x;
let sprite_sheet_y: f32 = (i as f32 / columns).floor()
* (tile_size.y + spacing.y) as f32
+ spacing.y;
Copy link
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Don't divide by 2 here. This is because spacing is treated as the "space" between tiles. This is what tiled map editor does and I think it's something we should stick with.

@@ -0,0 +1,80 @@
use bevy::{prelude::*, render::texture::ImageSettings};
Copy link
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Simple example based off of the layer example(just to show multiple tiles). The spacing is 8 pixels between each tile on both the X and Y axes.

Copy link
Collaborator

@bzm3r bzm3r left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, this looks good to me!

@bzm3r
Copy link
Collaborator

bzm3r commented Oct 9, 2022

@antoinePaulinB7 This is similar to your PR, but the main change is that the spacing is to the left/below tiles, rather than all around them.

@StarArawn StarArawn merged commit edaa754 into main Oct 10, 2022
@StarArawn StarArawn deleted the spacing-fixes branch October 10, 2022 12:42
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

Successfully merging this pull request may close these issues.

WGPU Validation Error (CommandEncoder::copy_texture_to_texture)
3 participants