The SDL forums have moved to discourse.libsdl.org.
This is just a read-only archive of the previous forums, to keep old links working.


SDL Forum Index
SDL
Simple Directmedia Layer Forums
Writing good smooth feeling swipe code
ruler501


Joined: 14 Aug 2014
Posts: 26
Location: Dallas, Texas
Currently I'm working on a game where swipes play a large part(moving cards around mostly) and I'm trying to find the smoothest feeling way of doing it.

Here is some code from what I have tried so far.

Code:
accel += event.tfinger.dx*width
    if(accel) accel -= vel/3 + 2*accel/3
    else vel=0;
    x += vel;

This feels pretty smooth but a little hard to control and bouncy.

I've also tried:
Code:
x += 1.5*event.tfinger.dx*width

Which is really easy to control, but feels jerky.