Droid in a tunnel
- Details Hits: 8029
Introduction :
"Droid in a tunnel” is an android accelerometer controlled 3D game. The player's main purpose is avoiding objects, while he travels in a tunnel.
Game Arhitecture :
1. Main activity
The main activity contains a menu that allows the player to start a new game, learn the rules or see the high scores. The high scores are kept in a local database managed with a Content Provider .
2. Game activity
The game activity contains 2 main views:
a) Status View : allows the user to see the current state of the game (score, life bar) b) Game View : the game itself, built with OpenGL;
How it works?
We have two threads:
- the main thread that controls and manages the game's state;
- the graphical thread that draws the tunnel's frames, obstacles, handles the particle system and detects collisions;
When a collision is detected, the graphical thread sends a message to the main one. The message is handled by a controller which updates the game's state by decreasing life and generating a vibration so the user “feels” the collision. (After we integrate the particle system it will also generate an explosion). The score is also updated through a message between the above threads. So, score increases with the distance traversed by the player. The game ends when the player presses exit/pause (using the options menu ), or when he has no more lives. A dialog view pops up and allows the user to register himself in the high scores list.
3. Graphical Engine
The engine was built using OpenGL ES and has two major components:
a) The tunnel
The tunnel is built by drawing the lines that form a torus object which is generated in the engine. We used 2 tunnels: the main tunnel and a second one that keeps the randomly generated obstacles. Basically, the second one is a torus with less faces, in which every vertex is an obstacle. When the scene is drawn, only some of the obstacles are chosen to be shown. Collision detection : on every draw we check if the camera's coordinates are inside of an obstacle object.
b) Particle System
The particle system currently generates an explosion, but in the future we'l l also add other lighting effects, as well as the ability to shoot incoming enemies.
Future development :
Here you can find our code and you can check the current state of the game on youtube [1] , [2] . You can also install the application .