Game apps for smartphones and tablets

Research project PHBern  
HomeStart online editorAndroid TurtlegraphicsPrintJava-Online

SliceIt game

In the leftmost position of the game window, different fruits are created in randomly chosen vertical positions. These move on a trajectory parabola and thereby turn around their own axis. The point of the gaime is to "slice away" all fruits before they arrive at the lower bottom of the game window.


Start game (first connect smartphone or start emulator)

Edit this example in the Online Editor

App installieren auf Smartphone oder Tablet

Programmcode downloaden (

QR code for the direct download on the smartphone

In order to understand the program code, it is recommended to develop the application in 4 steps:

Step 1: Create randomly chosen fruits at a determined position

Since all fruit actors act the same way, it would be a good idea to determine the characteristics of these actors in an abstract class and derive all fruit actors from that class. In a first step, in the method act() of the Fruit class only the turn around the own axis is implemented.


Edit this example in the Online Editor


Step 2: Fruits move on a trajectory parabola

The coordinates x, y of the moving fruits are calculated in physical terms with the the method act() of the class Fruit (horizontal shot)

whereby dt is determined by the simulation period g = 9.81und vx and chosen randomly.


Edit this example in the Online Editor


Step 3: Implementing touch events

The fruits are "cut" with a sword by touching the fruit sprite with your finger. Since we work with pixel coordinates, we have to use a precise collision identification. We implement a GGTouchListener. In the callback method touchEvent(), the x- and y-coordinate of the point of contact are captured and the sword is set to this position. When letting go, the sword is positioned outside the game window, so that it is not in the way of the game mechanics.

In the class fruit, we've implemented a GGAcctorCollisionListener that registers in the method collide() the collisions of the fruit actor and the sword.

Edit this example in the Online Editor


Schritt 4: Evaluation of the game

In the final step, only number variables are introduced and the results are displayed continuously.

Edit this example in the Online Editor