ondras / rot.js

ROguelike Toolkit in JavaScript. Cool dungeon-related stuff, interactive manual, documentation, tests!
https://ondras.github.io/rot.js/hp/
BSD 3-Clause "New" or "Revised" License
2.33k stars 254 forks source link

ROT.Display::eventToPosition(e) not working with transposed hex display #94

Closed veswill3 closed 8 years ago

veswill3 commented 8 years ago

I saw issue #90 but I do not have the ability to reopen it. I am having trouble getting ROT.Display::eventToPosition(e) to work correctly with a transposed hex display. It is returning incorrect coordinates. I noticed that ROT.Display.Hex.prototype.eventToPosition has code that accounts for the transpose flag, so I am not sure what is going wrong.

I created a jsfiddle to show the issue. You can verify that it works in normal mode by switching the transpose flag to false

https://jsfiddle.net/m0ba0ojg/

Please let me know if I made a mistake or if I am implementing this incorrectly. If not I would be happy to tinker with it and submit a pull request.

veswill3 commented 8 years ago

I just noticed that if height and width of the display are the same then it works fine, which is why the test did not catch the issue.

ondras commented 8 years ago

Interesting, I will definitely have a look.

ondras commented 8 years ago

Confirming.

ondras commented 8 years ago

@veswill3 fixed just now :)

veswill3 commented 8 years ago

Thanks for the quick update @ondras!