I've been using GLSurfaceView since it was introduced in Android 1.5 and I was a little let down to find that the new Live Wallpaper APIs didn't include anything like that. I like the design because it makes it very easy to quickly start working in OpenGL. Without it, there is quite a bit of tedious initialization and thread management code that isn't necessary for the vast majority of apps. Fortunately, for my first live wallpaper (Live Waterpaper), I adapted the GLSurfaceView's code and created a GLWallpaperService with a GLEngine which takes a Renderer and does the job for me.
Sooner or later in your Android game development foray you may find the need to have some code that runs faster. It turns out that Android code written in C runs 10-100 times as fast as its Java counterpart. I can verify this, as I've already moved a few major components in my newest 3D game engine into native land. That's quite a boost but let's face it - C is a pain in the ass and while Eclipse is great for Java, it's not for C, right? Wrong. Here's how to set up a super speedy NDK development environment.
The nice people at Verizon let me borrow a Droid for a few days so I'm going to take full advantage of this opportunity to bring you developers some specifications on the 3D capabilities of it. First of all, this phone is fast. How fast? It loads Light Racer 3D in 1/3 the time of my G1. Not only that, but it has a PowerVR SGX530 GPU in it (14 MPolys/s). Hello fast gaming! That's very close to the same chip used in the iPhone 3GS. Not only fast gaming, but all SGX series GPUs supposedly exceed OpenGL ES 2.0 specifications. Android doesn't currently support OpenGL ES2.0, but I have to imagine that with hardware like this on the market, it will soon. I tested Light Racer 3D on this phone and it works extremely well. 45-50 frames per second at 569x320. I have to imagine that it'd run at 60FPS if the screen were HVGA which would make it twice as fast as the G1. Read on for a list of supported OpenGL extensions and other specifications.
Real-time Android games have a few threads to worry about. You can't block up the main UI thread because it's needed by the OS. If you block it, even for a second, your app will be deemed unresponsive and users will get the dreaded "Force Close or Wait" dialog. If your game doesn't do anything in a logic or main thread then you should be in the clear. If you do use a main thread for your game and run it as fast as it can go, as is the case with 2D games that draw to the canvas or 3D games that simply have a lot of game logic to process, you may want to think about how you're handling your input.
The Android Developer's Challenge 2 has begun. The judging application is available for download on the market. If you're not familiar, the ADC is a contest sponsored by Google in which developers submit apps and games for Android. Apps are initially judged by users for a first round. Later, Google judges will be responsible for 60% of the score. The top 3 apps for any given category get a cash prize. An early version of one of my games, Light Racer 3D, is in this contest. Good luck to everyone who entered and thanks to Google for running it!
Light Racer 3D is complete! So much happened in the past 3 days that it's very difficult to write about one thing. I had decided on about day 9 to try to get Light Racer 3D finished in time for the Android Developer's Contest 2. It was a very ambitious goal, especially because that game was only partially working with about 25% of its total content just a day before. For 6 days I slept only about 4 hours per night and only took breaks when I absolutely had to. The hard work paid off because on Monday, Aug 31, we finished the game, submitted a trial version to the ADC and put the full version online on the Android market. I'm happy with how the game turned out, despite our lack of real artistic capability. While there are still a few bugs which will be fixed in a future version, the overall feel is good and the game is really fun.
Turning 90 degreees in an instant is hard on human eyes. After the game was working, I decided that the camera needs to be active and quick but also needs to be limited to a certain amount of movement. I added 4 camera modes to the world renderer: Above, Behind player, Beside player and Spinning. I then added the same code that I use to control player movement to the camera. Now, for every frame rendered, the camera checks where it is supposed to be, then tries to move there at the rate that I defined. I also really liked the way that the original F-Zero for SNES did the overhead view and zoom down to behind the player, so I added a similar sort of effect to the level intros. Besides camera work, there was a lot of modeling and texturing happening. None of us are very good at 3D modelling but by the end of the 2 days, we had already learned several tricks. All it takes is an ADC2 deadline to make you learn fast!
Light Racer 3D is an exciting project because every day of development adds substantial improvements to the game. The last 2 days have been no exception. Make sure to watch the video at the end of this post. It shows how totally playable the game is. If I were to stop right now, the game would be at least as good as a 3D counterpart to the original Light Racer. As it stands right now, I've got a list of about 20 things I'd like to do for this game to take it from cool to amazing. Because of memory allocation sensitivity on Android, I had to employ a few tricks to deal with the dynamic geometry of the trails. I also ran into a problem getting the explosions properly billboarded.
Days 5-7 have brought on a dramatic difference to the new game. It went from being a test bed for 3D objects and experimentation to an actual working scene. I laughed out loud when I first finished the merge of the 2D game engine with the new 3D rendering system because the problems were so bad but I was still able to see the racers and control them. It didn't take me much over an hour to fix up the issues and move the camera behind the player for that 3rd person following view. There are no trails, explosions or text yet but this will give you an idea of what the game will look like.
Every 3D game has a process defined for creating models, texturing and importing into the game. In these two days, I've come up with a process that works for Light Racer 3D and all of the games we will be developing in the future. This process will be a little different from project to project, depending on the requirements of the game and which tools you are using to create your art. I wanted to use Maya but was most familiar with 3D Studio Max so I went forward with it for Light Racer 3D.