Full Hungry Hero game source code available

Do you know Hungry Hero game?

The concept is very simple. The hero is pretty much always hungry and you need to feed him with food. You score when your Hero eats food. There are different obstacles that fly in with a “Look out!” caution before they appear. Avoid them at all costs. You only have 5 lives. Try to score as much as possible and also try to travel the longest distance.

What makes this game really awesome? The author, Hemanth Sharma, released the source code and gave me the permission to blog about it.

Let’s see what he says:

I am happy to announce that Hungry Hero is now Open Source on GitHub. It is no more just a basic code you saw during the Starting with Starling tutorial series (a must see!!! Eleven ultra-detailed video tutorials!! – Emanuele), but a complete game source code that you can fork, watch or log. I have primarily kept the main ActionScript file to match with the screen dimensions of iPad 1 & 2 (1024 x 768).

The whole game as you know uses Starling Framework to power itself up through Hardware Accelerated rendering.

Now, do enjoy downloading the full source code for free but please DO NOT use the graphic assets in any of the commercial projects. It’s a humble request. Use it only for learning purposes. As for the source code, you may play with it, modify it as per your needs and use it in any project you want. These are some of the consolidated “game development” features this source showcases: –

* Textures
* Animation using the Juggler
* Texture Atlas or Sprite Sheets
* Parallax Background
* Mouse/Touch Interaction
* Collision/Hit Detection
* Object Pooling
* Bitmap Fonts
* Starling Extension: Particle System

As far as the optimization is concerned, the game is well optimized (though there is always scope for more). It runs on most tablets at 60 frames per second. I still have a couple of video tutorials to create around Starling Framework + Optimization, after which I shall update the GitHub source code of this project as necessary.

The simplest way to use this source code is to download the master branch as a zip file and then simply import the downloaded set of project files as a “Mobile ActionScript Project” in Adobe Flash Builder 4.7.

Hope you guys find this useful, and if you do, please leave a comment below! Also, if you happen to use any part of the source code from this project in your projects, do leave a comment in the official page so I can check your game out and don’t forget to credit me for what I have been helpful for.

Thank you very much, Hemanth

  • Janitha

    Thanks for sharing. I’m sure this will help thousands of new comers, including me.

  • Aleksandar

    Hi all,
    great code and i was watching hungry hero tutorials on hsharma.com and enjoyed them, but was frustrated as i like working in flash not flash builder and all. Yesterday i said, let me try to make a fla and use code from example to get it to work. I added starling swc in lib path, folder for particles in source path and it was enough to get it working!!!
    When resizing screen of swf i got an error for context being changed and you loose display, so you just need to add Starling.handleLostContext = true;
    Now what i still cant figure out:
    i get output text:
    TypeError: Error #1009: Cannot access a property or method of a null object reference.
    at com.hsharma.hungryHero.screens::InGame/onTouch()
    at starling.events::EventDispatcher/invokeEvent()
    at starling.events::TouchEvent/dispatch()
    at TouchProcessor/advanceTime()
    at starling.core::Starling/advanceTime()
    at starling.core::Starling/nextFrame()
    at starling.core::Starling/onEnterFrame()

    This happens when cursor goes of the stage. Friend of mine has old version of starling, so he added in onTouch function: if (!event) return; and it works for him, but i stil get same error, i am guessing ’cause i downloaded new 1.3 starling.

    Anyway game works great, fps is also 59-60, so hope i made someone happy:)

    Thanks Emanuele, you are the best tutor man can have!

    • amihson

      can you give fla file?

  • Airgame16

    private var touch:Touch;
    private var touchX:Number;
    private var touchY:Number;
    private function onTouch(event:TouchEvent):void{
    touch = event.getTouch(stage);
    touchX = touch.globalX;
    touchY = touch.globalY;

  • engine

    nice src but the collision method used in this game are not good

  • Mike

    Very cute game! I’ll play with it for funzies!