Sunday, December 29, 2013

Match 3 Game algorithm Part 6 - A real Android Match 3 Game demo

Sorry for the late. The release date for the Match 3 Game as stated last time might be delayed a bit.

HORRAY! The Match 3 Pop Saga is now available in the Google Play Store Now!



After several weeks of hard work, i have finally come out with a 'sample' of the Match 3 Game, with the Candy Crush Saga as the main reference, and the algorithms stated previously. (The "Saga" is imitated to gain some SEO points, hopefully... oops)

However, different from the Candy Crush, my Match 3 Pop Saga only has a total of 9 stages. Furthermore, it includes a bit of RPG elements: Level up. Basically, the more you play (popping more balloons), the higher levels you are. And the higher levels will reward you a higher score per pop (and time too!). Interesting huh? :)


Note that it is a balloon, not a colorful Easter egg.
I am not a graphic designer. The pictures are obtained from devianart.

Something to note is that, the 'striped candy' now is a glowing balloon (right, simple animation), while the 'wrapped candy' is something like this (bordered):

The maximum level in the Match 3 Pop Saga is 15 (which i think you won't need that for completing all the stages with 3 stars).

Finally, thanks for trying this game. Feel free to drop some feedback, either on the game flow, or the game experiences~

Saturday, December 28, 2013

Running Man Quiz solution - Background music

In the Running Man Variety Show, each Running Man member has unique background musics that are played during the races. For example, when Lee Kwang Soo incurs bad luck / awkward situation, his music will appear. When Yoo Jae Seok shows some strategic skills, his Yoo mes Bond music will be played. If you have been watching the Running Man all the while, i am pretty sure you will be able to recognize them easily :)



Hence, in the Running Man Quiz, i purposely included some music clips to the 'Music' section. Be honest, i got some original sources from here. But to make it more complete (for the need of the 'solution' of the app), i re-organize the list here:

1. Yoo Jae Seok

  • James Bond's Movie Theme
  • Extreme Ways
  • Pink Panther Theme
  • Step By Step

2. Lee Kwang Soo

  • Saint Agnes and the Burning Train
  • Theme of False Emperor
  • No Matter How i think about it 
  • Public Enemy Main Theme  (This music appears when Lee Kwang Soo is in the Betrayal Mode)

3. Gary

* (All the musics of are from the Gary's self established Hip-hop duo LeeSsang)
  • Woman who cannot break up, man who cannot leave
  • You are the answer to a guy like me
  • Our Meeting
  • Blues

4. Song Ji Hyo

  • Angry Bird
  • Tears
  • Hot Issue
  • Cheesy/Ticklish/Ganjireobgeh

5. Kim Jong Kook

  • What we need is a Hero
  • This is Sparta

6. Haha

  • Perfect Love
  • Pororo
  • Rosa

7. Ji Seok Jin

  • The House You Live In (JYP)
  • I Swear
  • Angel (Romeo and Juliet OST)

8. Easy Brothers

You may search and listen to the musics from Youtube. Then, you will be able to get 5 R stickers for all the quizzes :)

Thursday, December 26, 2013

Running Man Quiz app is in the Google Play Store now!

Hooray!
Finally, there is an app "Running Man Quiz" available in the Google Play Store.



For those fans of the Running Man Variety Shows, now it is time to show your craziness towards the Running Man - answering all the quizzes in the app :)

Overall, there are four categories of quizzes:

 

 

a) Relationship

- Basically, you are required to guess the names, nicknames of the RM members. Remember, the staffs are included too (eg: Who is the Floor director of the RM show?)

 

 

 

b) Music

- If you are really a Running Man Show maniac, this is definitely not a problem to you. Still remember the "Angry Bird" background music? Which member does the music belong to?

 

 

c) Medal

- Episodes by episodes, you will be asked about who (or which team) won the final game? (eg: who is the last survival of the name tag tearing game in the episode xxx?) I admit this is a bit challenging. But fret not, hints are given sometimes. :)

 

 

d) Storyline

- Similar to the Medal category, the quizzes in the storyline are based on the episodes. Here, the questions will be more details, and definitely test your memories, lol.


So, what to hesitate? Quickly grab the Running Man Quiz game at the play store~

Tuesday, December 24, 2013

Actionscript ProgressBar DIY in Starling Framework

The Starling Framework doesn't come with the built-in Progress Bar, but the Feathers framework does.

However, i find that it isn't that hard to create a progress bar ourselves, and to be used with the Starling Framework.

Here, what we need to do is to create a ProgressBar class:

    public class ProgressBar extends Sprite
    {
        private const BAR_WIDTH:int = 100;
        private const BAR_HEIGHT:int = 30;
        public var qdMax:Quad; // a static bar
        public var qdMove:Quad; // a moving bar
       
        public function ProgressBar()
        {
            this.addEventListener(Event.ADDED_TO_STAGE, onAddedToStage);
        }
       
        private function onAddedToStage():void
        {
            this.removeEventListener(Event.ADDED_TO_STAGE, onAddedToStage);
           
            qdMax = new Quad(
BAR_WIDTH,BAR_HEIGHT,0xf0f0f0);
            qdMove = new Quad(1,
BAR_HEIGHT, 0x990000);
            addChild(qdMax);
            addChild(qdMove);
        }
       
        public function updateBarMove(_ratio:Number):void
        {
            qdMove.width = (_ratio)*qdMax.width; //adjust the width
        }
    }

Here, we have a very simple class. The main thing to note here is that, there is a function updateBarMove which takes the parameter of a 'ratio', ranging from 0 to 1, and is to be called from time to time to update the visual bar status. Any example of using this? Here it is:

How to show the progress bar while playing the audio files in Starling Framework (AS3)?

Yup, with the class defined above, we can easily display the progress of the audio files when it is played or paused. Here's the original source as your reference. Now with the onEnterFrame function, it can be performed with ease.

So, assume that you have a button switching from "play" to "pause" and vice versa. When it is "played", we dispatch the Enter Frame Event, as shown below:

      public var pBar:ProgressBar;
    public var sound:Sound;
    public var sc:SoundChannel = new SoundChannel();
    public var musicLength:int;

       private function onEnterFrame(e:EnterFrameEvent):void
    {
       var ratio:Number = sc.position/musicLength;
           
       if(ratio >= 1) //when the audio playing finishes
       {
           sc.stop();
           sc = sound.play(0);
           sc.stop();
           this.removeEventListeners(Event.ENTER_FRAME); //stop updating
       }
           
       pBar.updateBarMove(sc.position/musicLength); //passing a ratio
   }


Here you go, the progress bar is created!

Saturday, December 21, 2013

How to load TextureAtlas with the AssetManager in Starling Framework?

From the Hsharma's tutorial, we have learned that using a Sprite Sheet to load the textures is crucial to ensure a great performance. Next, you may want to ask, if the Sprite Sheet is too big to be loaded at run-time, are we able to tell the users, "hey, we are loading the resources, please wait a minute" to serve as a buffer before we proceed to the next screen/activity?

Good news. Tracking the process of loading the textures or other assets is made possible with the AssetManager class in the Starling Framework. In fact, the original tutorial could be found at here. In this post, particularly, i would like to show how to load TextureAtlas with the AssetManager.

Similar to loading the normal textures, to begin loading the TextureAtlas, let's have a class EmbeddedAssets.

public class EmbeddedAssets
{
     // Texture
     [Embed(source="../media/graphics/mypng.png")]
     public static const mypng:Class;
       
     // XML

     [Embed(source="../media/graphics/myxml.xml", mimeType="application/octet-stream")]
     public static const myxml:Class;

}

In the EmbeddedAssets class, we embed the TextureAtlas and the TextureXml as usual. Yup, just embed them as usual. Then, we could just use the AssetManager to load it (with the enqueue function).

public var assets:AssetManager = new AssetManager();

.....
assets.enqueue(EmbeddedAssets); //yes, enqueue the entire class
assets.loadQueue(function(ratio:Number):void
 {
    trace("Loading assets, progress:", ratio); //track the progress with this ratio
    if (ratio == 1.0)
          initGame();
 }); 



 Finally, in the initGame and the subsequent functions, we are able to load the texture with the function getTexture. For example, assume that you have a texture named "playButton" in the TextureAtlas, you can easily load it with the line below:

 var texture:Texture = assets.getTexture("playButton");

Isn't that very convenient?

Friday, December 20, 2013

Creating a timer with the Actionscript onEnterFrame

For those who are Actionscript-savvy, the "onEnterFrame" Event is a familiar term. It is in fact an elegant way of handling the animations in the game.

This post, is particularly a demo of how do i use the AS3 "onEnterFrame" to replace the class Timer (which is in the package flash.utils). You might think that this is redundant. But i really favor the way the "onEnterFrame" perform this with ease, while you can implement the other animations simultaneously.

Here's a snippet of the "onEnterFrame" function. What it does is that, the object is able to perform an animation A on each frame, while performing another animation B at an interval of one second (adjustable).

private var timePassed:Number = 0;
private var startInt:int = 1;
private function onEnterFrame(e:EnterFrameEvent):void
{
     timePassed += e.passedTime;
     if(startInt < 10)
    {

         //doAnimationA();
         if(Math.floor(timePassed) == startInt)
        {
             startInt++;

             //doAnimationB();
        }
     }
     else
    {

        this.removeEventListeners(Event.ENTER_FRAME); //clean the event
     }
 }

One thing to note is that, the data type of the timePassed has to be "Number", but not "integer". In the code, after passing 10 seconds, the enterframe event is removed.

Monday, December 16, 2013

Sound effect resources for Android Games

In case you are wondering where to look for free sound effect resources for Android Games, here i have a recommended link.

There are 3 main reasons i pick this sound effect resources instead of the others:

a) Resourceful solutions

The different types of sound effects are categorized clearly at the left, listing:
  • Pickup/Coin - eg: Mario Coin
  • Laser/Shoot - eg: Space shooter
  • Explosion - eg: tower defense bomb
  • Powerup - eg: RPG level up
  • Hit/Hurt - eg: Streetfighter / King of fighter attack
  • Jump - eg: Mario jump
  • Blip/Select
  • Randomize
  • Mutation

b) Intuitive and flexible

By clicking the button, it will generate a sound effect of your choice. Each click will generate a different sound. Basically you can perform unlimited clicks until you hear the one of your favorites. Furthermore, Each sound effect generated is tunable with a number of attributes:
  • Attack Time
  • Sustain Time
  • Punch
  • Decay Time
  • Compression
  • Frequency
  • Frequency cutoff
  • etc ....

c) Free for all

If there is a Facebook "Like" button, or a Google "+" button, i won't be hesitating to share this to all my friends. You can easily export all the sound effects generated for free. YES, you are not reading the typo. There are really some Samaritans out there researching and creating free products for us!

I believe most of us are not sound engineers, so having this resource would be definitely a helpful one.

Note: If you are going to load the sound effects into the Flash Builder, remember to perform the up-sampling / down-sampling the frequency of the audio files with the appropriate software, as mentioned in previous post.


Thursday, December 12, 2013

How to create the Monopoly Deal Card Game?

Yesterday, I published the Monopoly Deal Mini Minipoly Deal, a lite version of the Monopoly Deal Card Game.



Frankly, i was surprised to find that that isn't an official Monopoly Deal Card Game published in the Google Play Store. Furthermore, the information of the Monopoly Deal's algorithm is very limited from the search engines. A brief search of "How to create the Monopoly Deal Card Game" would return a dismayed result. Hence, curiosity makes me create this similar card game. And only after several weeks of efforts, I came to know the complexity and the challenges behind. To make the explanation clearer, i summarize the difficulties into several points:

a) Too many cards to fit into the screen

Apart from the 4 rule cards, there are a total of 106 cards comprising CASH, PROPERTY, and ACTION. To be more specific, there are around 10 different colors of property cards which may be placed on the table. How to design the graphic user interface (GUI) to accommodate so much spaces for different players? In my Monopoly Deal Mini, i have reduced the card numbers and the card sizes to compromise this issue. But i know it isn't a perfect solution.

b) Too hard to make a great computer Artificial Intelligence (AI)

There are too much variations in the game play. How to tell the computer to decide placing property first before an action, or vice versa? How to know a Sly action first before a Rent action could impact more to the opponents? What kind of payments are the most advantageous to his own? When to become more offensive or defensive? It seriously depends on how much cards on his own hands, tables and those from the opponents' table. Here i have to say my AI is relatively a dumb one... -.-

c) Exception cases are everywhere

There is no general algorithm for this Monopoly Deal Card Game. We have property wild cards that are movable and adjustable at any time. We have Rent actions, Sly Deal, Deal Breaker, Double the Rent, House, Hotel, Pass and Go, Just Say No, and etc which are to be handled differently, and are not categorize-able. Not every property set can own a house or a hotel. How to compute the highest potential Rent? etc etc

In short, only after creating the Monopoly Deal Card Game myself, i realize how complicated this Card Game is. I used to playing this game with lots of fun, but making this to appear as a successful Android game is still to far to achieve....

Minipoly Deal is in the Google Play Store now

Rejoiced! The long awaiting Monopoly Deal Card Game now has a lite version in the Google Play Store - Monopoly Deal Mini Minipoly Deal (Updated app name)


First, I admit i am just a fan of this card game. :)

Be honest, this game is created out of curiosity, as i am one of the Monopoly Deal Card Game fans as well. However, compared to the original Card Game, my Minipoly Deal (the mini version of the Monopoly Deal) is relatively having lesser cards. Also, to fit into the mobile devices, i have made the CASH and ACTION cards spherical, while the PROPERTY cards are in squares instead of rectangles.

The game rules are still remained: You will win the game if you collect three or more property sets. During the game play, you can perform actions to steal/request the cash and the properties from your opponent. At the current version, the Minipoly Deal only has a 1 vs 1 mode, which is player versus computer. To have better understanding of how to play the game, kindly go to the Help section.

Here's the home page of the game:
Don't you think the top red logo is familiar? There you go, i was trying to imitate the back side of the original Monopoly Deal Card.
So, what are you still waiting? Let's download the game and drop some feedback. Your suggestions will be appreciated :)

Tuesday, December 10, 2013

Brave Heroes - Heroes comparison

Previously, I have posted the Brave Heroes Game Tips with a number of critical information...
But that was for the early stages. After continuing to play the game, I think it is more appropriate to add more points in the game play experience, especially the Heroes comparison.


As you can notice in the picture, i have 2 Melee Heroes reaching the max level of 45: Penguin and the Gloria. And here's a brief comparison


First, please ignore the Enchant, though it may add a little but negligible impact (from my upgrades).


AttributePenguinGloria
Attack930311662
Note: the difference of Attack is around 2400

In short, upgrading the Gloria is more crucial than upgrading the Penguin. Alright, you will say that it is normal to make the subsequently unlocked Heroes stronger. I was thinking the same. And i am quite shocked to see the huge gap between the Heroes, especially the one shown below:

Yes, it is the Ninja Jin VS the Nebiross (Range/Distance Heroes)

AttributeJinNebiross
Attack902827613
Note: the difference of Attack is about 18000!!! (200% - 300% of the Jin)

Here, i would like to mention that, the MAX LEVEL of Nebiross is higher than the Jin, which is 50 instead of 45! (in fact, i believe the Heroes from the second row can reach higher maximum levels)
Furthermore, it is noteworthy to remember that, the Nebiross has two very critical skills.
Skill 1: Shoots an arrow piercing through the enemy, with Attack +200%
Skill 2: Increases the Critical Hit chance by 30%

Basically, if the Nebiross combines both the skills, his attack can reach 27000 x 2.5 x 2, which is more than 100,000 per arrow, and penetrating through ALL the enemies in front! What an awesome combination! It is with this hero that i can survive through Level 40++


And yes, Nebiross is the hero that you can buy with Gold (not diamond) - $500,000, and the Gold can be obtained through the strategies i mentioned before. And of course, i still didn't spend any penny on this game :)

Friday, December 6, 2013

Guess Car Brands - a beginner's Android game

Few months ago, i published a relatively simple Android game - Guess Car Brands.



The objective of creating the game is to learn some basic algorithms, such as how to generate the random alphabetical letters when a random car brand is popped up. At the end of the day, it isn't that complicated. In fact, the approach of creating a unique random numbers has been posted before. As long as the letters are being 'shuffled', it has achieved its original goal.

I admit that this Guess Car Brands is a kind of imitation, of the another game - "Guess Car Brand". Note - my app has an 's' at the end.

It was hoped that in line with the popularity of the game, my game can gain some fame from it. However, it seems that i have been so wrong... oops

Anyway, I just imitate the logo and the game play, but not duplicate the images. Also, i do add more variations into the game play:
a) first mode - choose the country of the cars that you want to guess.
b) second mode - the real car guessing mode. In this mode, there are 25 cars picked from the total, each with 4 scores. At the end, your performance is recorded.

Interestingly, you can use hints when guessing car brands. The hints can be obtained from the practicing in the first mode. However, once you have consumed the hints, the highest score would become only 2.

More and more car brands would be added in the future. Leave a message if you see any room for improvement.

Thursday, December 5, 2013

How to set the frame rate in the Flash Builder Actionscript project?

In some of the games such as Tower Defense or RPG, a consistently high frame rate is necessary to maintain a smooth display of the animations. By default, an Actionscript project in the Flash Builder has a frame rate of 25. This is barely enough for a few movements on the screen. If there are tonnes of bullets or enemy armies bombarding the screen display, the players will experience a horrible game play experience (and most importantly, rate your game badly....)

So, setting the game frame rate is necessary. To do that, you need to include a simple SWF meta tag above your class definition (and AFTER your library import), as stated below:

package
{
    import flash.display.Sprite;
    import flash.display.StageAlign;
    import flash.display.StageScaleMode;
    import flash.geom.Rectangle;
   
    [SWF(frameRate="60", width="640", height="960",backgroundColor="0xffffff")]
    public class YourGame extends Sprite
    {
        public function YourGame()
        {


           ....

In the code, make sure you have your SWF meta tag written just before your Class. Here, a frame rate of 60 is chosen. Apart from the frame rate, you can set other configurations as well, such as width, height, background color, etc.

One thing to note is that, the effect of the frame rate "may not" be reflected if you are in the debugging mode with the Adobe AIR simulator. Therefore, don't be surprised if you still observe some lagging when debugging the game. Everything will be alright when you "Export Release Build".

Tuesday, December 3, 2013

How to crop an image with the Starling Framework?

So this is the post of how to perform image cropping on run-time in Starling Framework (AS3).

Allow me to grab any random image from the web for demo purposes, as below:



Question: how to crop the car image above? (Its original size is 300px width, 150px height). The final result is only the center car image.

The action is similar to cropping it with Microsoft Office Picture Manager, as shown below:

But how is it done in AS3 code?

First, let's have a look at the important function setTextCoords stated here.
Sets the texture coordinates of a vertex. Coordinates are in the range [0, 1].

To put the explanation of the function in a clearer picture:

Here, the vertex ID (first parameter) of a picture starts from top left, which is 0.
vertex ID 1 - Top right
vertex ID 2 - Bottom left
vertex ID 3 - Bottom right

Then, the coordinates (second parameter) simply means at which point of the image should the vertex be located. The allowed coordinates are in the range of [0,1]

So, let's see how we want to crop the image. As we can see above (the picture of Microsoft Office Picture Manager), i crop the image with the following criteria:
a) Left: 50px
b) Right: 50px
c) Top: 35px
d) Bottom: 10px

By converting them into the proper value (from 0 to 1), now we have:
a) Vertex 0th: (50/300, 35/150)
    - coordinates (1/6, 7/30)
b) Vertex 1st: ((300-50)/300, 35/150)
    - coordinates (5/6, 7/30)
c) Vertex 2nd: (50/300, (150-10)/150)
    - coordinates (1/6, 14/15)
d) Vertex 3rd: ((300-50)/300, (150-10)/150)
    - coordinates (5/6, 14/15)

Hence to crop the image with AS3, we just need the few lines below:

var bitmap:Bitmap = new car(); //assume you have embedded the car image
var myTexture:Texture = Texture.fromBitmap(bitmap);
var img:Image = new Image(myTexture);
img.setTexCoords(0, new Point(1/6, 7/30));
img.setTexCoords(1, new Point(5/6, 7/30));
img.setTexCoords(2, new Point(1/6, 14/15));
img.setTexCoords(3, new Point(5/6, 14/15));
addChild(img);

Isn't that easy? At last, remember to set the width and height of your final image. Else, the cropped image will have the size similar to the original one (which would be undesirable).

Wednesday, November 27, 2013

How to handle multiple resolutions / multiple screen sizes with the Starling Framework?

One of the great reasons that i choose Adobe AIR and Starling Framework as my favorite tool to create Android Games is that, it can be easily customized to support multiple resolutions for multiple screens. Honestly,  if you are going to design and re-size every single image of your games for all the Android devices, it is going to make your life much more miserable...

So, actually the complete guide to support multiple resolutions is stated clearly here, which includes the 3 strategies:
a) Stretching the stage
b) Letterbox
c) Smart Object Placement

In this post, particularly, I will demo a quick and an easy approach - Stretching the stage. Just in case you are still getting stuck with the guides, here's a simple working solution for your reference (which i actually use it in all of my games :))


public class myGame extends Sprite
{
    private var mStarling:Starling;
    public function myGame()
    {
        super();
           
        // support autoOrients
        stage.align = StageAlign.TOP_LEFT;
        stage.scaleMode = StageScaleMode.NO_SCALE;
           
        var screenWidth:int  = stage.fullScreenWidth;
        var screenHeight:int = stage.fullScreenHeight;
        var viewPort:Rectangle = new Rectangle(0, 0, screenWidth, screenHeight)
           
        mStarling = new Starling(Game, stage, viewPort);
        mStarling.stage.stageWidth  = 640;
        mStarling.stage.stageHeight = 960;
           
        // set anti-aliasing (higher the better quality but slower performance)
        mStarling.antiAliasing = 1;
           
        // start it!
        mStarling.start();
    }

}

What is actually done is that, in the codes, i have defined my default device to be a screen with the width = 640px and the height = 960px (ratio w:h = 2:3). With this, all my game elements (buttons, background images, etc) would be designed based on this resolution. Then, if the game is loaded into a device with a different screen size (and pixel density), the Starling would help me re-size accordingly. It could be a compromise, but it will effectively save you a lot of time.

Isn't that easy and convenient compared to that in the Java Eclipse?

Thursday, November 21, 2013

Quoridor Board Game - Lessons and future improvement



Few months ago, I published the Quoridor Board Game, with the promise that, if the user rating exceeds the threshold of 30, I would further improve the game. Today, you guys really make it... (btw, is that a coincidence?). And I would spend more time and efforts into polishing this board game.

The truth is, before it reached 30, a number of enhancement has been made, from time to time, especially on the user interaction parts. Yet, I am aware that it still has room for improvement. Here, I would like to briefly summarize what it lacks of, and what should be possibly improved.

1. Computer AI (Artificial Intelligence) difficulty

Honestly, the current Quoridor computer is still too weak to be taken as a training. A number of players have complained for this. This is my first priority. And i see my competitor could make it as well. So, no excuse. Just a matter of time.

2. User's friendliness

In order to squeeze a 9 x 9 matrix board into mobile devices (plus walls and others), it is undoubtedly a challenging task. This is especially significant when the player is required to drag and place the walls. The existing version has been designed such that when the wall is moved around, the surrounding tiles are highlighted to make the movement clearer. Apart from that, some users request that it would be greater to add a 'confirm' button, to be able to 'revert' in case there is a typo made accidentally. Guys (and girls), i copy that!

3. Undo feature

This is another challenging feature which greatly tests the programming skills of the game creator. I am not sure if this is needed. But nothing to lose if it is getting integrated.

4. Challenge other players Online

Definitely, this is a very demanding feature. Playing with computer all the time would be too boring... However, i set no date for this feature to come true, yet. After all, without the sufficient amount of players, this feature could hardly impress anyone. Moreover, enabling the Online Challenge Mode would cost. (Maybe i should wait until the number of rating exceeds 100? :p)


Updated on 30th Nov 2013:
- A Hard Mode is added to the latest release.
- An Undo feature is added. This might help address the issue of 'wrong wall placement', while helping the players to have a better analysis of the computer AI's game play.
- You can choose which player to start first through the green Setting button.

Friday, November 15, 2013

How to add Admob ANE into the Flash Builder project?

If you are first time integrating Adobe Native Extension (ANE) into the Flash Builder project (here, i demo an Andoid project), I bet you would have encountered some issues during debugging.

In this post, particularly, I would like to talk about adding Admob into the Flash Builder project. Since the Admob doesn't officially provide the ANE, here I am using the third-party one in the demo.

 If you have come across the error message such as:

VerifyError: Error #1014: Class so.cuo.anes.admob::Admob could not be found.

OR the error pop up similar to:

Error: Requested extension so.cuo.ane.Admob could not be found.



 then this is the right place to look for.


To revise, there are 2 steps to properly add an Adobe ANE into the Flash Builder (here, it is Admob ANE):

Step 1:

Go to Project Tab -> Properties -> Actionscript Build Path -> Native Extensions -> Add ANE


Step 2: (Which is most of the time overlooked by the beginner)

Go to Project Tab -> Properties -> Actionscript Build Packaging -> Google Android -> Tick the Checkbox of the Package


If you miss the step 2, you will face the errors mentioned.

One more thing, unlike using the Admob jar library in the Java project, the one provided by the third-party doesn't support Admob Ads in the debugging mode. You could only 'see' the Ads coming out if you "Export Release Build".

***Updated***
Following the link provided by Mike Monti, I am also able to display the Admob Ads.
One thing to remind is that, remember to add the following in your xml tags:
<meta-data android:name="com.google.android.gms.version" android:value="4323000"/>
<activity android:name="com.google.android.gms.ads.AdActivity" android:configChanges="keyboard|keyboardHidden|orientation|screenLayout|uiMode|screenSize|smallestScreenSize" />
To produce the Banner ads, you can simply follow the code below:

var adMobManager:AdMobManager = AdMobManager.manager;
if(adMobManager.isSupported)
     {
          adMobManager.bannersAdMobId = "ca-app-pub-xxxxxxxxxxxxxxxx/xxxxxxxxxx";
          adMobManager.createBanner(AdMobSize.SMART_BANNER,    AdMobPosition.BOTTOM_CENTER,"BottomBanner",null,true);
          adMobManager.showAllBanner();
      }

Hope this helps.

Brave Heroes Game Tips



Just after few hours i have posted the Brave Heroes Game Walkthrough, I manage to have a breakthrough in this game - reach the Maximum level of the Hero, which is 45!

So, i believe my Game Tips of the Brave Heroes is convincing enough with my achievement :)
Particularly, I would like to solve some puzzles that some players might have during the game play. And to emphasize, i didn't pay any in this game. Feel free to drop any feedback~

What is Maximum Level of the Heroes in the Brave Heroes Game?


As you can see the picture above, the highest reachable Heroes' level is 45 (through gaining experience or buying experience with gold). However, you are able to somehow perform "Level Unlock" with 45 blue Gems as stated. Technically speaking, it is almost impossible for me to unlock the next level without paying. The cost of 45 blue Gems is 1,000,000 Golds (it would take me hours or days to obtain such a huge amount through unlocking stages). Moreover, one thing to point out is that, in total i have only unlocked 9 Heroes out of 24. I really hope that the maximum level of 45 is enough for me to go through all the stages left, otherwise i would just stop playing this game. :p

How much is the cost of the experience?

With simple calculation, you will find out that one experience value would cost 7 Golds, regardless of how much your Heroes' level is.

How to approach and kill Enemy Heroes easily?

The enemy Heroes are sneaky. They keep running away if there is no army surrounding. Once you have killed the melee army in front of them, they will escape cunningly at the back of the tower and turn back to strike again. To lure them approach you without escaping, make sure your Hero's position is in such a way that, the enemy archer army is able to shoot the arrow from the back of the enemy Hero (as in the picture). This is crucial, especially if you choose the Range Hero as the leader. Approach the enemy Hero when they come with an archer. Let the archer stand behind him so that he will foolishly think that there is some backup and won't run away. Of course, use portion to regenerate hit points whenever necessary. Also, make sure your Hero is strong enough (at least 5 levels more than the enemy hero's)

How to earn more Golds in the Brave Heroes game?


No doubt, it is to kill more enemy Heroes in a stage, while purposely losing it through time count down. After raising your Leader Hero to such an extent that the Hero is at least having 5 levels higher than the enemy Hero's, now focus to kill the Heroes in the stage. Remember, do not win the stage as the enemies (both army and Hero) will grow stronger. Patiently wait them to get spawned and kill them with the tactics above. Killing one Hero may reward you around 200-500 experience, with around 1000-2500 Golds, plus 1 possible treasure that may contain up to 2500 Golds. Once in a blue moon, the treasure may come with 1 blue Gem too (as in the picture, the crate is Gold in color)! Until now, I have broken my previous records and now obtain more than 30,000 Golds in a single stage, though 'losing' in the end. Repeat the process infinitely, you can even train more Heroes to achieve the maximum level of 45.



One thing to note is that, do not manually quit the game yourself, though the Golds are still owned in the end, your Hero will lose all the experience gained (as observed).

Apart from that, need not fear about one versus multiple Heroes in a stage. The enemy Heroes come one by one. Just make sure you kill them before they are gathering and come to you.

Conclusion

Hope that the Game Tips help :)

Tuesday, November 12, 2013

Brave Heroes Game Walkthrough

Recently I am addicted to an Android Game - Brave Heroes

It is a Tower Defense Game, with very cutie Heroes and the armies (and enemies :))

Many has negative comments on the Brave Heroes game. One of the facts is that, unlike other games, the stages that you have defeated would "increase the level of difficulty" as well. Most of the players find this annoying as they couldn't (or very tough to) train the Heroes strong enough to face the coming just-unlocked stages. And hence, it seems that game is focusing on the "monetization" instead of the game play. BUT, IT DOESN'T.

So, this post is a Brave Heroes walkthrough to convince all of the would-be players (or on-going players) that, this game is really an interesting and working properly game which can provide a lot of fun without any money purchase, as long as you are a bit more patient.

Upgrading Hero is Essential


 This makes sense.  At the beginning stages (<10), you only have a Melee Hero "Balzac". Use all the money to upgrade as high as possible. Higher level means higher attack, attack speed, hit point, etc. One thing to mention, you should Enchant at least once on the weapon (Legendary Great Sword for Balzac Hero) to increase the chance of critical attack. I personally think the shield enchant is optional.

Our Army is negligible

I admit that they are adorable (especially their movement). But I have to frankly say that, their existence can serve nothing more than a few seconds buffer for the enemy invasion. My advice is, do not rely on them or upgrade them. In the Shop section, the only thing to upgrade is the "Gold", such that the stage clear reward can be increased.

Melee Hero is the best Leader


In Brave Heroes, you can summon up to 6 Heroes in a stage. The Heroes are categorized as "Near"(melee), "Distance" (Range), "Magic" (Range). The "Near" Heroes are the one who have the highest hit points such that, they are the best candidates as the front end strikers (to sustain the heavy pain longer), while the "Distance" and the "Magic" Heroes are attacking from the back. Here, particularly, I would like to recommend the "Penguin" as your option. The Penguin has a critical stunning attack skill which helps him (a guy) take a lead in the attack most of the time. And seriously, the young penguins attack skill is so funny and useful, especially when targeted at the escaping enemy Heroes. Here, precisely, i only upgrade the Penguin after discovering that he himself is able to VS even 4 Heroes! (one by one of course). And to re-emphasize, i didn't pay for this!

Purposely Lose is a strategy


As mentioned, if you have passed the stages with 3 stars, the enemies' level will be raised as well (including the enemy Heroes). This would mean that, even though you continuously select the Stage 1 to play with (and win in the end), the enemy armies would get infinitely stronger! Honestly, I have 1 stage that i couldn't even beat even though after summoning all 5 Heroes (total up 6 altogether), while there is no Hero at the enemy site!

Hence, the strategy is - to lose in a stage intentionally, through time-out. Within the period, kill as many enemy Heroes as possible (and the armies. Wait patiently for them to get spawned). Even though if you lose, you would still own the money. This is by far the most effective strategy to raise the level of the Hero and to earn money!
Killing an enemy Hero could reward you with about 200-500 experience, and up to few thousands gold (with the treasure). In the end, you could be able to rake in more than 15000 Gold (in my extreme case, 30000 Gold in a stage (20th) even though i lose in a stage!

Then you might ask, is it that easy to kill an enemy Hero? To do this, you have to understand 1 thing - the enemy Hero tends to escape when there is no army around. Therefore, to ensure the Hero stand 'stupidly' in front of you, you have to make some effort (timing) to let the enemy archer standing behind the enemy Hero. With this, even though they are running out of hit points, they are not going to escape and let you kill them. And then, for the Range enemy Heroes, you got to approach them (especially when they activate their skills) to attack them (assume you use the melee Hero such as the Penguin i mentioned).

Conclusion


I haven't finished the game, with only around 25 stages cleared. The thing is, i have my melee Hero (the Penguin) level raised to about 42 easily, 10+ more than my up-coming enemy Heroes! And I just need the solo Penguin to defeat them! The game would go endless if i continue my game play experience as stated above.

So, any hassle of playing the Brave Heroes game again? Perhaps the only glitch is that, on and beyond the stage 10, the game starts getting slower (probably due to too much objects appearing). Hope that they can add a fast forward button to boost the speed whenever necessary.

See Here for Brave Heroes Tips

Sunday, November 10, 2013

Generate non-repeating random numbers for games in actionscript AS3

When creating games, the random number generation is one of the important elements to avoid a monotonous game play experience.

Generally, it is straightforward to create a random number in actionscript AS3 (Simply use the built-in Math.random() function). But the question is, how to generate a list of random numbers, without any repetition? I used to be a PHP programmer. With PHP, it has an elegant approach with just 2 lines:

$numbers = range(m, n); //manually generate an array storing a list of numbers ranging from m to n
shuffle($numbers); //yes, we have it shuffled already~

Unfortunately, we don't have a similar solution in AS3...
Instead, the solution is:

var arrWanted:Array = [m, m+1, m+2, ... , n]; //manually generate an array storing a list of wanted numbers
var arrRandom:Array = new Array();
while(arrWanted.length > 0)
{
   var intRandom:int = Math.random()*arrWanted.length;
   arrRandom.push(arrWanted[intRandom]);
   arrWanted.splice(intRandom,1);
}

The idea is that, from the wanted list of number, we randomly pick any of them, while reducing them at the same time. In the end, we have our arrRandom filled with a list of random numbers.

I realize that this problem has been solved by others. In this post, particularly, i would like to add a real example of using the non-repeating random numbers generation as well.

Generate random non-repeating cards in Big 2 (Big Two) Card Game



Big 2 (Big Two) is a popular Poker Card Game involving 4 players. At the beginning of each round, each player is provided 13 cards (which total up to 52). In reality, the cards are distributed one by one, clock-wise. However, when dealing with the cards distribution in coding, we could simply apply the random numbers generation stated above.

Let's rewind the codes (AS3 part). With a little bit modification, we would have our jobs done easily.

var arrWanted:Array = new Array();
for(var i:int=0;i<52;i++)
{
  arrWanted.push(i);
}
 

var arrRandom:Array = new Array();
while(arrWanted.length > 0)
{
   var intRandom:int = Math.random()*arrWanted.length;
   arrRandom.push(tmpArr[intRandom]);
   arrWanted.splice(intRandom,1);
}

var arrPlayer1:Array = new Array(); 
var arrPlayer2:Array = new Array();
var arrPlayer3:Array = new Array();
var arrPlayer4:Array = new Array();
for(i=0;i<arrRandom.length;i++)
{
  if(i<13)
  {
    arrPlayer1.push(i);
  }
  else if(i<26)
  {
    arrPlayer2.push(i);
  }
  else if(i<39)
  {
    arrPlayer3.push(i);
  }
  else
  {
    arrPlayer4.push(i);
  }
}

At the end, we have our arrays ready. Each array stores a list of 13 numbers which represent the Poker Cards.

Friday, November 8, 2013

Match 3 Game Algorithm Part 5 - Miscellaneous (Special Combinations)

By following the algorithms stated here, I believe you almost get the ideas of how a Match 3 game would look like in terms of logic. A little naive (as i didn't use any built in library or framework, or referring to the popular flood fill algorithm). But since it is from scratch, it has the flexibility of any customization. Furthermore, based on those solid understanding, you would be able to add more variations in your game.

Performance-wise, as long as you have followed the statements strictly, we could ensure a decent working solution. (I will demo a working one in the future post)

In this post, particularly, i would like to recap a number of features on the Candy Crush Saga that make the Match 3 game much more interesting - Special Candy Combinations, as stated below:


a) Color Bomb - formed by a match involving 5 candies in a uni-direction


b) Striped Candy - formed by a match involving 4 candies in a uni-direction


c) Wrapped Candy - formed by a match involving 5 candies in a "T", "+" or "L" shape.


Technically speaking, to detect these special candy combinations, it isn't that hard since we could make some checking in the results of the matching detection algorithm.



For example, in the picture above, after the node of 35th is exchanged with the 43rd, we would obtain a match of 5 nodes (33rd, 34th, 35th, 36th and 37th) according to the 1st statement.

However, the problem does not just end here. Since we are going to 'generate' the special 'candy' (item) ourselves, you might further pose some questions:

Q1: How to determine at where does the special candy reside?
Q2: How to enable those special effects formed by the special candies matches?

To answer the Q1, you would need to take some efforts remembering the index of the nodes touched by the player. If it takes place through random falling, you may take the smallest index of the matches to be the index of the special candy.

In the case of Q2, on the other hand, it is likely more complicated that we have to look into the special combinations one by one.

Consider the nodes exchange of Color Bomb:
a) 1 Color Bomb with 1 normal node
    Effect: All the nodes which are identical to the normal node will explode.
b) 1 Color Bomb with 1 Color Bomb
    Effect: All the nodes in the matrix explode.
c) 1 Color Bomb with 1 Striped Candy
    Effect: All the nodes having the same color become stripped candies and explode.
d) 1 Color Bomb with 1 Wrapped Candy
    Effect: All the nodes having the same color explode. And then, all the nodes with a random color explode.

Apart from that, we have to consider the exchange of Striped candy and Wrapped candy:
a) 1 Striped Candy with 1 Striped Candy
   Effect: Both Striped Candies explode
b) 1 Striped Candy with 1 Wrapped Candy
   Effect: Both candies explode, along with 3x3 matrix crossing both horizontally and vertically
c) 1 Wrapped Candy with 1 Wrapped Candy
   Effect: Both candies explode, along with 5x5 matrix surrounding both candies.

No pseudo-code? I believe with the basic algorithms in the previous posts, you would be able to construct the logic here. In case you really want, please leave a message here and i would update this :)

Note:
In my Match 3 game, i don't care about the orientation of the striped candy. Instead, i randomly explode either a horizontal or a vertical line.

Next: A real Android Match 3 Game Demo

Tuesday, November 5, 2013

Match 3 Game algorithm Part 4 - How to enable the user interaction?

Until now, we manage to come out with a fundamental match 3 game with the matches detection and a deadlock detection. So far so good :)

But the thing is, something is still missing: user interaction. This is the crucial part that lets the players get hooked on the game. The players are required to make some moves to proceed with the games, either through forming more matches, or completing some special missions. (In the case of the candy crush, the missions are forming matches to clear the jelly, or achieving a threshold score with minimum moves, and etc)

Here, the basic user interaction tutorial would be: move the nodes/items, either horizontally or vertically.

At first sight, this is pretty straightforward. In fact, since the each node/item in my match 3 game is coupled with an integer index, it isn't hard to make a rule such that, if the first node touched is a neighbor of the second, both the nodes are exchangeable, and hence we could perform some matching detection algorithm.


For example, the picture shows a matrix of 8x8. At the nodes indexed at 10th, 17th, 18th, 19th and 26th, it is easily observed that, the node of 18th can be only exchanged with its neighbor which has the absolute index difference of 1 or 8. With this understanding, we could conveniently generalize the algorithm...

However, let's consider 1 more case:

Here, the node indexed 15th, despite being able to exchange with the node 7th, 14th, 23rd, it is unable to interact with the node 16th (because they are not directly connected). Therefore, this special case has to be addressed in our algorithm, which is stated in the next statement:

Statement 4:
- Two nodes are exchangeable, provided that their absolute index difference is 1 or 8, AND if one of them is in the column 0th or 7th, the other one is NOT in the column 7th or 0th.

Forgive my poor explanation in the last part. It simply means that, the node in the column 0th cannot be exchanged with the one in the column 7th.

Coming up next: Miscellaneous (Special Combinations)