emthree icon indicating copy to clipboard operation
emthree copied to clipboard

Makes swipe more lenient by snapping the user swipe vector to cardinal direction.

Open deckarep opened this issue 2 years ago • 3 comments

Hi @britzl,

Here is the proposed change. Let me know if the code can be improved as I'm not super strong in Lua referencing issue: https://github.com/britzl/emthree/issues/6

Behavior before:

  • When a user swipes, for the swipe to register they must stay in the same horizontal row or vertical column for the respective direction otherwise the swipe is ignored and the user experience requires more precision.

Behavior now:

  • A user's swipe vector (operating in screen coordinates) is snapped to a cardinal direction (UP, DOWN, LEFT, RIGHT) no matter what such that the gesture will always succeed even if the user releases outside a row or column.

I think this makes the game a little more lenient while still offering a nice gaming experience.

I'm curious to hear your feedback!

-deckarep

deckarep avatar Jul 06 '23 04:07 deckarep

Side note: I noticed that when building and running Defold has moved some of the collection definitions around I think because there's since been updates to the engine. I left these changes in for now.

deckarep avatar Jul 06 '23 04:07 deckarep

I like the general idea. Regarding the implementation, wouldn't something like this give the same result:

-- normalize the direction
-- figure out if we are swiping more left/right or up/down
-- then round to nearest integer for this cardinal direction and zero out the other
local d = vmath.normalize(vec_between_clicks)
if math.abs(d.x) > math.abs(d.y) then
	d.x = math.floor(d.x + 0.5)
	d.y = 0
else
	d.x = 0
	d.y = math.floor(d.y + 0.5)
end

britzl avatar Jul 07 '23 06:07 britzl

Thanks for the review @britzl - when I’m at my computer later today I’ll try your suggestion which looks to be a more straightforward implementation.

deckarep avatar Jul 07 '23 14:07 deckarep