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

New System for Tile Map, Tile Set, and Brush #714

Open
wants to merge 27 commits into
base: master
Choose a base branch
from

Conversation

b-guild
Copy link
Contributor

@b-guild b-guild commented Dec 24, 2024

This tile map system is still a work in progress, but it is now a work in progress that is actually useable. It does everything the current tile map system can do and more. After weeks of working on it alone, I am making this pull request so that I can get some help with this enormous project. I cannot find all the problems with it myself, though I have tried and it seems to work quite well. There is just too much for one person.

It needs a lot more documentation and testing, but here are the major features that it already has:

  • Brushes and tile sets each contain multiple pages. Each page contains its own hashmap of tiles, and you can switch which page you are using by selecting a page from the area above the tiles, where each page is represented by a tile that serves as the icon for that page.
  • Brush pages allow a single brush to fill the role of multiple brushes. Instead of switching brushes, we can switch pages. Therefore I have simplified TileMap to remove the list of brushes that is no longer needed. If there is a need to switch brushes, the current brush can be changed by dragging a brush asset into the tile map control panel.
  • Tile set pages come in three flavors, each serving a different use:
    • The Material page allows you to specify a material and a tile size to easily create tiles from an atlas. Unlike the current system, this is not a one-time operation to create these tiles. Instead, the material can be replaced and the tile size can be changed at any time. Any tiles from that page in a tile map will adjust themselves accordingly, because tile map tiles know what page they are from and their position in the page.
    • The Freeform page allows you to create arbitrary tiles without needing an atlas. You can specify any material and the positions of the four corners of the tile in texture coordinates. You can put copies of existing tiles into the page by drawing them using the tile map control panel, much like drawing tiles to a tile map, but with the additional freedom to be able to flip and rotate any tile to any orientation. This allows the creation of mirrored or rotated versions of tiles from an atlas using the same material as the atlas but with different UVs.
    • The Transform Set page contains handles to tiles from other pages in groups of 8. These groups represent the ways in which a tile can be transformed by flipping and rotating. The 8 are arranged in a 2x4 rectangle. The left 2x2 area represents four 90-degree rotations, and the right 2x2 area represents those same rotations but horizontally mirrored. Thanks to this, we can flip and rotate tiles while editing a tile map, and the editor will automatically find the appropriate transformed version of the tile.
  • Collision now has multiple layers, with each layer identified by a name and UUID. The tile set editor has a tab for adding, removing, renaming, and changing the color of each layer. This is important because a single tile map will often need multiple physics bodies with different properties. Of course there is a solid rigid body for walls and floors, but often there will also be a need for icy surfaces and areas that the player can pass through, and so on. Each physics object can be assigned to a particular collision layer in the tile map.
  • A custom collider option has been added, allowing the user to specify arbitrary triangles. There is currently no GUI interface for this system; the user needs to type the triangles in as a list of points and index-triples in a provided text area. This is a clear place where improvement is possible.
  • Properties are now shared by all tiles in a tile set. Each tile does not have its own independent list of properties, but rather each tile set has a list of properties, and each tile has only its own values for those properties. This creates consistency across the tile set, with each property having a particular type, and optional list of named pre-defined values, and an order in which the properties will be presented in the tile set editor.
  • Tile map tool randomness is now a option that can be toggled using a button with a dice icon. A randomized rect fill will use random tiles from the current selection, while a non-randomized rect fill will repeat the current selection as many times as necessary to fill the area.
  • A preview widget shows the current selected tiles and adjusts itself to show those tiles after the rotations and flips have been applied. The tile map control panel now has rotation and flip buttons, though they are only fully effective for tiles that contain rotations and flips in some Transform Set page of the tile set.

@mrDIMAS
Copy link
Member

mrDIMAS commented Dec 24, 2024

17k lines... O. M. G. That's for sure will take some time to review :)

@b-guild
Copy link
Contributor Author

b-guild commented Dec 24, 2024

I think it might be wise to rename material pages to atlas pages and change the names of related concepts to match. I may not have given enough thought to what things are named in this project, so there may be other names that should be changed.

@b-guild
Copy link
Contributor Author

b-guild commented Dec 26, 2024

If anything is in any way confusing or unclear, I would be very happy to add comments, rename things, re-organize things, or in other ways adjust the PR so that it is easier to understand.

@mrDIMAS
Copy link
Member

mrDIMAS commented Dec 26, 2024

I'm on the review, the PR is just... too large. I mean it is probably one of the largest PR I've ever seen including ones at work. I'm half way through it.

@b-guild
Copy link
Contributor Author

b-guild commented Dec 27, 2024

It would be great to have advice on method names, parameter order, and generally making sure that everything fits in with a consistent Fyrox style.

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.

2 participants