2D game motion using accelerometer
<p>I'm trying to make a smooth motion for my game (LIBGDX project), my plans include accelerometer and basic physics movement but still i'm just a newbie and don't know/want to try box2d.</p>

<pre><code>private Vector2 velocity,acceleration,current;

    velocity=new Vector2(0,0);
    current=new Vector2(0,0);
    acceleration=new Vector2(0,0);
</code></pre>

<p>bascially i store velocity,acceleration and tilt in a Vector2;</p>

<pre><code>    current.x=initialX - Gdx.input.getAccelerometerX();
    current.y=initialY - Gdx.input.getAccelerometerY();
    float dt=Gdx.graphics.getDeltaTime();
</code></pre>

<p>Here i calculate current rotation based on initial value that accelerometer gave</p>

<pre><code>if (current.x&lt;1 &amp;&amp; ship.shipbounds.getX() &gt;= 0) acceleration.add(0.2f,0);
if (current.x&gt;1 &amp;&amp; ship.shipbounds.getX()&lt;=1080-ship.shipbounds.getWidth()) acceleration.add(-0.2f,0);
if (current.y&lt;1) acceleration.add(0, 0.2f);
if (current.y&gt;1) acceleration.add(0,-0.2f);
       velocity.add(acceleration.x*dt,0);
        ship.shipbounds.setPosition(ship.shipbounds.x + velocity.x * dt, ship.shipbounds.y + velocity.y * dt);
</code></pre>

<p>That's the part of code that is not working(i guess):when ship should be staying still it moves to top-right and if i try to make it go button-left it goes a bit but after that its top-right speed increases making it uncontrollable </p>