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

Handle Hexagon-based tilemaps #141

Open
jamesnunn opened this issue Jul 18, 2024 · 8 comments
Open

Handle Hexagon-based tilemaps #141

jamesnunn opened this issue Jul 18, 2024 · 8 comments
Labels
✨ enhancement New feature or request

Comments

@jamesnunn
Copy link

jamesnunn commented Jul 18, 2024

I've tried using Gaea with my hex map but encountering some strange behaviour when using the chunking tools. It seems the actor position is calculated with square tiles in mind and there are multiple other places in the code where hexes aren't handled (e.g. grid_2d.gd SURROUNDING).

I'd be willing to contribute but this is my first time with Godot (but an experienced developer otherwise) so if you have pointers to parts of the code I'd need to focus on that will help me grok from there onwards I will give it a shot.

@BenjaTK
Copy link
Owner

BenjaTK commented Jul 19, 2024

Oh that's a good point, hadn't thought about that. Maybe we can add a tile_shape property in ChunkLoader and an enum for that, then check what type is selected when calculating.

@BenjaTK BenjaTK added the ✨ enhancement New feature or request label Jul 19, 2024
@jamesnunn
Copy link
Author

The map generation seems fine, it was just the chunk loading that wasn't behaving nicely. Would it only be the chunk loader calcs that need attention?

@BenjaTK
Copy link
Owner

BenjaTK commented Jul 19, 2024

Yup

@jamesnunn
Copy link
Author

jamesnunn commented Jul 19, 2024

image

Does this look like anything obvious to you why there is a void around the centre tile 0,0 where the actor is (actually the actor is offset by 1,1 because I'm using mouse coords without correcting position, 0,0 is the top left green tile of the 2x2 block)? I got the chunk loader working but those ones refuse to render.

@jamesnunn
Copy link
Author

Never mind, it was the load_on_ready flag set to true

@BenjaTK
Copy link
Owner

BenjaTK commented Jul 21, 2024

So setting load_on_ready to true fixed it? Or the other way? I feel like it should be the first one.

@jamesnunn
Copy link
Author

Yes but I hadn't actually got as far as implementing it all the way through the various chunkloader calls and signals yet so there was some weirdness going on that I can't explain.

@cullumi
Copy link
Contributor

cullumi commented Sep 14, 2024

@monotonehell over in the Discord suggested the following as a starting place for at least fixing the issue with the actor's position.

### in generate_2d.gd

## Returns the map coordinates of the cell containing the given [param global_position].
func global_to_map(pos: Vector2) -> Vector2i:
    return $"Ground-TileMapLayer".local_to_map(pos)

## Returns the global position of the cell at the given [param map_position].
func map_to_global(map_position: Vector2i) -> Vector2:
    return $"Ground-TileMapLayer".map_to_local(map_position)

Passing in the appropriate layers would make it so we're always transforming our position appropriately without having to bake up our own implementation. In fact, we could totally use a composition-based approach that could wrap TileMapLayers or just our own personal implementation however we want. A field for a "TileSettings" object or something like that.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
✨ enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

3 participants