In this lab we had to make a nice iPhone Applications to learn how take most of the advantages that this device can offer. This application is called Sonic Skull Shot and it's basically a sling shot that throws skulls. It makes use of the accelerometer, audio, and OpenGL among other things. It uses the STK and the Mopho API. Below there is download link and also a more detailed description of SSS.
CLICK HERE TO DOWNLOAD (XCode with the latest SDK required). All required libraries are included in this package.
SSS and the STK and Mopho API comes in the same package (that you can download from here).
To install them on your iPhone, open the hw2.xcodeproj with your latest version of the XCode with the SDK 3.1.2. Choose to compile for Device (IT WON'T WORK ON THE iPHONE SIMULATOR), click Build'n'Go and you're ready to Go!
The Sonic Skull Shot is a sling shot that throws skulls. It also makes a pluck string sound each time you throw a skull. This sound depends on the length, on the position and on the distance of the launcher point to the other two points. The sound is synthesized using the StiffKarp instrument from the STK.
Collisions between skulls are also implemented, and a disotrted Mandolin sound is played each time one occurs (Mandolin comes in the STK)
To throw a skull, place two fingers in the screen. A String will appear, now you have to stretch (with yet another finger) it and let it go. A skull will be shot in the direction of the sling shot. You can throw up to to 15 skulls!
The movement of the string when it only has two vertices reflects the sound that is being played right now. The skulls will fade out when they slow down too much. You can also remove all the skulls on the screen by shaking the device (this setting can be turned off in the settings screen).
You can change some settings on this applications by pressing the "i" button
- Gravity: When turned on, you can make move your device to move all the skulls around (Default: Off)
- Reverb: Adds/Remove reverb to the sound (Default: On)
- Shake: Adds/Remove ability to remove all skulls when shaking the device (Default: On)
This assignment took me a long time. I had to learn plenty of things to fully implement this application. Last time I made use of physics with OpenGL was like 6 years ago. It is also my first time programming with OpenGLES. Collisions were tough, but also was to track all the touches in the screen. There were some problems with the MoPho Touch, but still there are some times that an object gets twice called to begin or to end. The loading of textures took also some time, since I had problems with the GLubyte type, and the GL_BLEND OpenGLES option.
In terms of the design, all the objects that appear in the screen are subclasses of a GLObject. This is a custom class that keeps the required information to show an object in the screen. The subclasses are: GLCircle, GLLine, GLProjection, GLExplosion. Each of these have a draw() method, that gets called in the main render loop. Most of the action takes place in the ES1Render.mm and GLObject.mm files.
For more information about the implementation, please, refer to the Source Code.