Midnight Tangent Devblog

2 Devs Talking About The Crazy Things They Do

  • Home
  • About Us
    • Personal Posts
    • About the Artist
    • About the Programmer
  • Art
    • Art Posts
  • Design
    • Design Posts
    • Programming Posts
  • Login

Ludum Dare 41 is in the books!

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! read more

Posted in Announcements, Art, Design, Devlog, Featured, Programming, Uncategorized Tagged dare, food truck, harry's, hotdog, ld, ld41, ludum, racing, twitch, unity Leave a comment

Implementing OpenFeint with Android

UPDATE

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!

UPDATE

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.

IMPLEMENTATION SPECIFICS

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 steps

Right-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.

OpenFeint tutorial Import Window

  • Click on Select Root Directory and then Browse
  • Browse to the directory in which the OpenFeintAPI and GameFeed libraries are stored.
  • Click OK.

    OpenFeint Tutorial Import Projects

  • Click the checkboxes for GameFeed and OpenFeintAPI. If you’ve already imported the projects they will be grayed out as is shown here
  • Select Copy projects into workspace
  • Click Finish.
  • OpenFeint Tutorial Projects Imported

    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 

    OpenFeint Tutorial Build Projects

  • Right click on the OpenFeintAPI project in the project explorer and select Properties
  • In the window that appears select Android and then make sure Target is set to Android 1.6 and Is Library is selected as well. I had issues with the project being set to anything besides 1.6, but if it works for you then that’s fine too.

    OpenFeint Tutorial Properties Setting

  • Click OK
  • Follow steps 2 -4 for the GameFeed project in the project explorer
  • Right click on your game project in the project explorer and select Properties
  • On the Android tab make sure Is Library is NOT selected.
  • Click Add and then select both the GameFeed and OpenFeintAPI projects and select OK. You should now see the two references with green check marks.
  • Click OK to close the window.
  • 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"/> read more

    Posted in Programming Tagged Android, Android Game, Android Game Blog, Android Game Development, Android OpenFeint, Android Programming, Blog, Coding, Design, Development, Droid, First Game, Indie Game, Java, OpenFeint, Programming 17 Comments

    Keeping With Tradition

    Gather ’round boys and girls. For story time today we’re going to talk about the importance of meeting user expectations for how android apps operate. If you’ve ever used an android phone, you’ve probably noticed that the two most important buttons are the Back and Home keys.  When you press the Back button you expect to, well duh, go back. And when you press home (and click your heels together three times) you expect to be brought back to rural kansas with Todo by your side. No? Oh well then you probably were just trying to get back to your home screen.   TECHNICAL CONTENT WARNING!   Now what you may not be aware of is what these two buttons are actually doing. I won’t get too bogged down in the details, but essentially Android OS uses different stacks for your applications that hold the different things you are doing, known as activities. You could have a messaging stack, web browser stack, or a contacts stack for example. If you’re in the messaging stack, the first screen you see is put on the bottom of the stack. Once you select “text messages” from this screen, your list of text messages is called forward and placed on the top of the stack while the message service select activity is paused in the background. Likewise, when you click on a particular text, the text message is displayed as the top activity on the stack while the other two are paused beneath it.   When you hit the Back button, your phone destroys the activity on top of the stack which leaves the one beneath it. In our example, hitting the Back button would result in you returning to your text message list. Hitting it a second and third time would bring you back to the messaging service select screen and then the home screen. The interesting thing here is what happens when you push the Home button. Android returns you to the home screen, but keeps the current state of the activity stack in place. Therefore, you can go on opening other apps and creating many different stacks, but when you return to the messaging stack you will see the same thing that you saw before you pressed the Home key (providing your phone didn’t decide it needed to conserve memory and destroy the stack). There’s a lot more to it than that, but for the purposes of this conversation that’s all you need to know. If you want to learn more, the android dev site is great.   You can come back now, it’s safe   Based on what we just talked about, there is an expectation among android users that when you press the Back button the phone goes back and when you press Home the phone returns to the home screen but remembers where you were when you left.  In order to have more flexibility, most games are created using only a single activity. This lets them draw to the screen as fast as possible which, in turn, generates smoother graphics. The downside of this is that we can no longer allow the Android OS to handle moving around within our game because it sees it as only one activity and will immediately destroy it once the back button is pushed.   I thought it was important that our game mimic the android experience, however, and have intercepted the back key so that I can control what happens instead of the OS. The implementation was pretty straighforward; everything launches from the main menu so that’s realy the only place you have to go back to. From any point in the game or secondary menus, if you press the Back key, you return to the main menu as expected. If you press the back key on the main menu, a message is displayed prompting you if you really want to exit. From here you can either check yes or no, but if you push the Back key on this screen the game will exit. I did this because, if anyone else is like me, they just keep mashing the back key until the application has exited and I wanted to make sure this still worked.   The Home key was a little less straightforward. Did we want the user to return to the same place? The answer for this pretty much came from our earlier decision not to have a pause screen because the the user would be able to exploit it during faster rounds. If you were in the middle of a game and pressed the home key (or got a phone call), when you returned you’d be in the middle of game. Instead, we decided that you’ll just return to the main menu. Now this DOES mean that if you were having a really awesome game and someone calls you that you’ll have to start over, but we felt this was the best solution. For you diehard highscore fiends, might I suggest Airplane Mode?   Words? I just want PICTURES!  Awwwww

     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.

    I thought green means go?!

     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! read more

    Posted in Featured, Programming Tagged Activity Life Cycle, Android, Android Game Development, Android Programming, Back Button, Blog, Coding, Design, Development, Droid, First Game, Game, Game Design, Home Button, Indie, Indie Game, Java, Programming, User Expectations 2 Comments

    Achievement Unlocked: Achievement Bar Complete

    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. read more

    Posted in Programming Tagged Android, Android Game Development, Android Programming, Blog, Coding, Design, Development, Droid, First Game, Game, Game Design, Indie, Indie Game, Java, Programming 2 Comments

    Frustration and Jubilation

    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) read more

    Posted in Programming Tagged Android, Android Game Development, Android Programming, Blog, Coding, Design, Development, Droid, First Game, Game, Game Design, Indie, Indie Game, Java, Programming 1 Comment

      Stay Connected

      • View Midnight-Tangent-Studios-138280219624318’s profile on Facebook
      • View midnighttangent’s profile on Twitter

      Posts

      • April 2018
      • March 2018
      • January 2018
      • December 2012
      • July 2012
      • June 2012
      • May 2012
      • March 2012
      • January 2012
      • December 2011
      • November 2011
      • October 2011

      WordPress Theme Custom Community 2 developed by Macho Themes