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

Implement tilemap layers #1146

Merged

Conversation

OverloadedOrama
Copy link
Member

@OverloadedOrama OverloadedOrama commented Nov 30, 2024

Implements a new type of layer, tilemap layers. Tilemap layers are a type of pixel layers that are divided by grid cells, where each cell is mapped to a tile in a tileset. Tilesets are stored in projects, and multiple tilemap layers can use the same tileset.

This is a huge new feature that I wanted to try to have ready for v1.1, and while I did do a lot of tests before opening this PR, more testing would be greatly appreciated. I plan on merging this PR as soon as possible to make it easier for more people to test it.

2024-11-30.12-51-59.mp4

Current features:

  • Users can set the size of the tiles in the tileset while creating it. Tilesets are being created when adding a new tilemap layer, but tilemap layers can also re-use existing tilesets.
  • Manual tile editing mode, which modifies individual tiles without re-ordering the tileset, and the modifications get immediately applied to other cells in the tilemap which are mapped to the same tile. Modifications to tiles also get applied to other tilemap layers and cels that have the same tileset.
  • Auto tile editing mode, which automatically creates new tiles if they don't already exist, it modifies tiles that only exist once, and it deletes unused tiles.
  • Stack tile editing mode, which always creates new tiles every time the user makes a modification, without affecting the previous tiles.
  • Draw tiles mode, which directly places tiles from the tileset in the tilemap, instead of pixels. Can be used by pencil, eraser, bucket, shape and selection tools.
  • Resizing selections resizes tile indices, when drawing tiles mode is enabled.
  • Rotation and flipping support for when placing tiles in the tilemap.
  • A new tileset panel which contains all of the above options, plus the tileset of the currently selected tilemap layer. If no tilemap layer is selected, this panel is invisible.
  • The first grid always has the same size as the tile size, if a tilemap layer is selected, regardless of the size set in the Preferences. Other grids are not affected.
  • Show the index of each tile in the tilemap layer when Control is held.
  • Load images as tilesets.
  • Duplicate and delete tilesets from the project properties dialog.
  • Change which tileset the tilemap is using from its layer properties.
  • Layer/frame cloning, cel linking, drawing on multiple cels, undo/redo, layer merging, indexed mode, pxo saving/loading, image/layer effects, resizing should all work.
2024-11-30.21-12-17.mp4

Stuff that can be added later:

  • Use icons instead of text for the buttons in the tileset panel.
  • Add a small icon in the layer button in the timeline to differentiate it from other layer types. Should also be done for group and 3D layers.
  • Move tool on tilemap layers should move the tilemap offset.
  • Support isometric tiles. Perhaps other shapes as well, such as hexagons.
  • Autotiling.
  • Export to Godot TileSets and TileMapLayers.

Code is a bit meh, needs to be written better.
…leset and applied a layer effect to all cels of the layer work

This now creates an issue when manual mode is used and we undo. Other cels don't get updated, even though they were changed by manual mode.
Can only delete tilesets that are not currently used by a tilemap layer
…cept bucket

Also fixes issues with the draw tile mode with the pencil and eraser tools, such as leaving gaps if the mouse is moving fast, and support for spacing and fill inside tool options.
And rename _snap_to_grid_center() to _snap_to_rectangular_grid_center()
… tools

Only rectangle selection for now, and resizing doesn't yet work
@OverloadedOrama
Copy link
Member Author

2024-12-05.01-54-57.mp4

Managed to make selection tools and resizing work with the draw tiles mode. I think the tilemap layer system is pretty feature complete now, I'll merge this PR so Nightly version users can test it and give feedback.

@OverloadedOrama OverloadedOrama merged commit f91bb18 into Orama-Interactive:master Dec 5, 2024
4 checks passed
OverloadedOrama added a commit that referenced this pull request Dec 9, 2024
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.

1 participant