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

Added ability to rotate and flip the brush when painting in tilemap. #8973

Merged
merged 8 commits into from
May 24, 2024

Conversation

AGulev
Copy link
Contributor

@AGulev AGulev commented May 23, 2024

Now it's possible to flip and to rotate the brush when editing tile map using the following hotkeys:

  • X - flip the brush horizontally
  • Y - flip the brush vertically
  • Z - rotate the brush 90° clockwise

Fix #3296

PR checklist

  • Code
    • Add engine and/or editor unit tests.
    • New and changed code follows the overall code style of existing code
    • Add comments where needed
  • Documentation
    • Make sure that API documentation is updated in code comments
    • Make sure that manuals are updated (in github.com/defold/doc)
  • Prepare pull request and affected issue for automatic release notes generator
    • Pull request - Write a message that explains what this pull request does. What was the problem? How was it solved? What are the changes to APIs or the new APIs introduced? This message will be used in the generated release notes. Make sure it is well written and understandable for a user of Defold.
    • Pull request - Write a pull request title that in a sentence summarises what the pull request does. Do not include "Issue-1234 ..." in the title. This text will be used in the generated release notes.
    • Pull request - Link the pull request to the issue(s) it is closing. Use on of the approved closing keywords.
    • Affected issue - Assign the issue to a project. Do not assign the pull request to a project if there is an issue which the pull request closes.
    • Affected issue - Assign the "breaking change" label to the issue if introducing a breaking change.
    • Affected issue - Assign the "skip release notes" is the issue should not be included in the generated release notes.

Example of a well written PR description:

  1. Start with the user facing changes. This will end up in the release notes.
  2. Add one of the GitHub approved closing keywords
  3. Optionally also add the technical changes made. This is information that might help the reviewer. It will not show up in the release notes. Technical changes are identified by a line starting with one of these:
    1. ### Technical changes
    2. Technical changes:
    3. Technical notes:
There was a anomaly in the carbon chroniton propeller, introduced in version 8.10.2. This fix will make sure to reset the phaser collector on application startup.

Fixes #1234

### Technical changes
* Pay special attention to line 23 of phaser_collector.clj as it contains some interesting optimizations
* The propeller code was not taking into account a negative phase.

@AGulev AGulev requested a review from matgis May 23, 2024 13:03
@AGulev AGulev self-assigned this May 23, 2024
editor/src/clj/editor/keymap.clj Outdated Show resolved Hide resolved
editor/src/clj/editor/tile_map.clj Show resolved Hide resolved
editor/src/clj/editor/tile_map.clj Outdated Show resolved Hide resolved
editor/src/clj/editor/tile_map.clj Show resolved Hide resolved
Copy link
Contributor

@matgis matgis left a comment

Choose a reason for hiding this comment

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

Looks great!

Just a few minor issues I'd like to see addressed, but overall this is a great addition to the editor, the code is readable and well-documented, and it's great to see it covered by tests as well!

Top marks! ❤️

editor/src/clj/editor/keymap.clj Outdated Show resolved Hide resolved
editor/src/clj/editor/keymap.clj Outdated Show resolved Hide resolved
:v-flip new-vflip
:rotate90 new-rotate90})))
reordered-tiles (vec (flatten (for [y (range height)]
(reverse (subvec flipped-tiles (* y width) (* (inc y) width))))))]
Copy link
Contributor

Choose a reason for hiding this comment

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

reverse uses a general algorithm that creates a new, reversed list from any input sequence. It works, but is kind of inefficient. Since flipped-tiles is a vector, you can use rseq instead, which achieves the same result using a lightweight wrapper. It only works on "trivially reversible" sequences such as vectors, though.

editor/src/clj/editor/tile_map.clj Outdated Show resolved Hide resolved
editor/src/clj/editor/tile_map.clj Outdated Show resolved Hide resolved
editor/src/clj/editor/tile_map.clj Outdated Show resolved Hide resolved
editor/src/clj/editor/keymap.clj Show resolved Hide resolved
editor/src/clj/editor/tile_map.clj Show resolved Hide resolved
editor/test/integration/tile_map_test.clj Show resolved Hide resolved
@AGulev AGulev requested a review from matgis May 24, 2024 09:02
@AGulev
Copy link
Contributor Author

AGulev commented May 24, 2024

@matgis Thank you for your feedback! All the improvements were addressed.

Copy link
Contributor

@matgis matgis left a comment

Choose a reason for hiding this comment

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

Very nice! LGTM!

@AGulev AGulev merged commit 8dfb282 into editor-dev May 24, 2024
6 checks passed
@AGulev AGulev deleted the DEFEDIT-3296 branch May 24, 2024 10:40
@AGulev AGulev added the editor Issues related to the Defold editor label Jun 19, 2024
AGulev added a commit that referenced this pull request Jun 25, 2024
…8973)

* one tile implementation

* add vertical flip

* Add functionality for a multi tile-brush rotation

* use brash as function argument

* add tests

* make keymaps as in Tiled

* Review fixes

* fix typo
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
editor Issues related to the Defold editor
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants