This past weekend I participated in my first Ludum Dare game jam and I’m alive and here to tell the tell! Admittedly, I did not spend a ton of time working on my game for the simple fact that I have 2 kids and wife that also need some attention throughout the weekend. I’d estimate that I spent about 20 hours in the allotted 72 hours for the game jam. Of course the final version of the game did not have all the mechanics and ideas I started with, but without a doubt it was an excellent learning process that has given me a lot of confidence moving forward with game development. Now, let’s talk about Hotdog Harry’s Food Truck Racing!
Since this has become one of our more popular pages I just wanted to update it to say that UPSAT has now launched! If you find this page useful or just want to see some of the cool things we did with OpenFeint, including custom notifications, then please consider supporting us by getting the full version of UPSAT and by following us on Facebook or Twitter!
So you have an amazing Android game and you’ve decided you want to join the 21st century and add social connectivity? Well kudos and welcome to the party!
If you’re reading this then you’re probably at least somewhat interested in OpenFeint and what is entailed in getting this working with your game. The good news is it’s actually really easy. The bad news, since OpenFeint is relatively new on Android, the documentation can be a bit lacking which makes the task SEEM very daunting. I have to admit that I was a little bit nervous about doing this before I started, but in the end it only took me around 5 hours. So, if you have any coding skills whatsoever (unlike myself) then you could probably get it done in less. I’ve decided to write this little tutorial to help future users who find themselves running into the same problems as I did and to begin chipping away at the community support void that OpenFeint for Android is currently experiencing.
Since my game was created using the Android SurfaceView class and not OpenGL, I can’t attest as to the viability of this tutorial in other situations. That being said, the fundamentals should still be the same for any multi-thread gaming environment. At it’s core, Android is just Activities and Views, and both GLSurfaceView and SurfaceView classes are just views that operate on separate threads. So if you’re using something besides the regular SurfaceView class, don’t stop reading, this information could still prove useful. I’m running Windows 7 and using Eclipse 3.7.0. I’m going to focus on Step 4 of the getting started with OpenFeint tutorial from the developer support site, as steps 1-3 are essentially repeated here.We’re also going to assume you already have your project in Eclipse.
GETTING STARTED: IMPORTING OPENFEINT
I’m going to go ahead and skip steps 1-4 on this page because it’s all pretty self explanatory. If you can’t figure that out then I don’t think any number of tutorials will help you. So our first task is actually getting OpenFeint imported into your workspace. You’ll want to make sure you download and extract the OF SDK to somewhere convenient. I put mine in the same location as my Android SDK. To import the API’s follow these stepsRight-click on your project in the project or package explorer Click Import. On the following screen select General and then click Existing Projects into Workspace.. Click Next.
You should now see the two projects in your package/project explorer. If they are not there, try deleting them out of your workspace through Windows Explorer and then following the steps above. If your images don’t look exactly like mine, that’s ok. I have some of my files in SVN repositories so they display a little differently.
BUILDING AND SETTING UP THE PROJECT
Next we need to verify that the projects have been built and that both projects are classified as libraries. This part seems to be the main area of confusion and I had the most trouble here. From reading other forums, it seems as though, depending on how you perform the import, the files may automatically be classified as libraries, in which case your project would be fine. If this doesn’t happen then you will start seeing errors as you actually implement the API into your code. It’s best just to perform these quick verification steps to be safe.In the top menu bar, select Project and then check to see if Build Automatically is selected. If it is, go to the next step. If it’s not, then select Build All and then select Build Automatically
Your project is now set up and you’re ready to begin coding. At this point you shouldn’t have any errors. If you do then please retry all the steps and if you are still having issues feel free to comment here and I will try to help you out.
INITIALIZING OPENFEINT IN YOUR GAME
“Ladies and Gentleman, Boys and Girls…. It’s time for the MAAAAAAIIIINNNNN Event!” This is the part you’ve no doubt been waiting for. Before we get started I want to take a minute to explain my setup and how I’ll be implementing the code. Simplifying greatly, my project consists of one Activity (AndroidGame) which is the UI thread and one SurfaceView( Screen) which is the worker thread where I perform all my game logic and rendering. Through some trial and error coding, I found that the OpenFeint methods have to be called from within an Activity class or context and not a view (or SurfaceView for that matter). This means that as far as I know, the calls must be made from the UI thread. I also found some apparent errors in the code given on the OpenFeint developers site and will point these out to you.
The first few steps for editing the Android Manifest file are pretty straightforward:Edit the AndroidManifest.xml file in your project: Add the following activities inside your <application>tag:
<activity android:name="com.openfeint.internal.ui.IntroFlow" android:label="IntroFlow" android:configChanges="orientation|keyboardHidden" android:theme="@style/OFNestedWindow"/> <activity android:name="com.openfeint.api.ui.Dashboard" android:label="Dashboard" android:configChanges="orientation|keyboardHidden" android:theme="@style/OFNestedWindow"/> <activity android:name="com.openfeint.internal.ui.Settings" android:label="Settings" android:configChanges="orientation|keyboardHidden" android:theme="@style/OFNestedWindow"/> <activity android:name="com.openfeint.internal.ui.NativeBrowser" android:label="NativeBrowser" android:configChanges="orientation|keyboardHidden" android:theme="@style/OFNestedWindow"/>
Fine, fine! Here’s some pictures of a few changes we’ve made. Notice the new heart that floats away when you pet the kitty. She loves you! We’ve also made the notification bar larger so we can
insult praise you with more words.
Here you can see the insult bar twisting the knife after you make a mistake on a really easy level. Seriously, how hard is it to pop the red balloon? Actually, I’ve noticed it’s really hard at first because our minds always want to avoid the red one. I guess you’ll just have to adjust. You can also see our REALLY big X that pops up when you lose a life. I’m currently in the process of animating the X to shrink down and fly into the lives bar. It’ll look cool once it’s completed and you will all worship me!
So I’m pretty exhausted at work right now. After this long weekend of staying up until 5am every night, I’m finding it difficult to go to sleep on time. I have to get up at 530 to beat the morning DC traffic so going to bed at midnight may not seem late for some, but for me it’s a day ruiner. It was worth it though.
I finished coding the notification bar and have thus completed the last element of the UI. It looks really cool when the bar pops down from the top of the screen to let you know you’ve done something notable (good or bad). I mocked up some achievements and insults to be displayed and it’s quite hilarious when the red bar comes down saying something like “Only your mom thinks you’re special” or “You messed THAT up?!” Even though I wrote it, the taunting still somehow gets under my skin and I find myself wanting to prove the computer (and therefore myself) wrong. I know, it kind of makes me a crazy person.
We’re coming up on being half-way through our weekend game dev party and I’m glad to say that we have a lot to show for it. You’ve probably already seen some of the artwork Ryan has created in his last post and I’ve made huge progress with the UI. If things keep going this way we’ll be done with this game in no time!
I’ll try to touch on some of the stuff I’ve worked on during the past day. All of the UI elements besides the achievement/insult bar are up and running. I spent a good amount of time coding debugging the animations for the timer and multiplier bars to make sure that they’d work on different size screens. I got pretty lucky on this one because the animations ran fine on my phone, but I tried running the game on a 320×240 screen to test for another issue and discovered they weren’t running properly there. Thankfully it didn’t take very long for me to figure out what the issue was. (Designing for different size screens is pretty much the most difficult thing about working with the Android platform)