Meigyoku-Thmn / ThMouseX

A piece of software that enables mouse control in Touhou Project series.
16 stars 18 forks source link

Smoother movement? #3

Open IntOverflow-maxwell opened 2 weeks ago

IntOverflow-maxwell commented 2 weeks ago

While playing in Touhou 8 IN, I noticed that Reimu was only moving in diagonals, and after looking at the code, I've been experimenting with implementing Bresenham's algorithm for smoother movement, by effectively "drawing" out straight lines via movement inputs, effectively making Reimu beeline for the mouse. I've made a fork and changed InputDetermine.cpp with a rudimentary implementation. I'm not sure if this is a good addition or if it's portable across games, so I'm opening an issue.

Meigyoku-Thmn commented 1 week ago

I actually had the same idea several years ago, but had no idea how to do it correctly. Most games have 8-directional control, but the concrete implementations vary, in every Touhou game I know of, diagonal Δ (dΔ) is the same as horizontal Δ (hΔ) and vertical Δ (vΔ), Pythagorean theorem doesn't apply (dΔ ≠ √(hΔ² + vΔ²)), so I'm not sure if Bresenham's algorithm can be used. Then you have to take into account that the player will be constantly moving the mouse. You are welcome to make a pull request, it can be an option per game so it's not necessary to be suitable for every game.