Back to project page Tilt-snake.
The source code is released under:
Apache License
If you think the Android project Tilt-snake listed in this page is inappropriate, such as containing malicious code/tools or violating the copyright, please email info at java2s dot com, thanks.
package com.awhittle.tiltsnake; //from w w w . j a va2s . c om import android.hardware.SensorEvent; public class Direction { public static int getDirection(SensorEvent event){ int dir; if (Math.abs(event.values[0]) > Math.abs(event.values[1])){ if (event.values[0]>0) dir = 4; //Left else dir = 2; //Right } else { if (event.values[1]>0) dir = 3; //Bottom else dir = 1; //Top } return dir; } }