Build 10 classic Flash games and learn game development along the way with this ultra-fast paced game development course.

If you love this blog, this is the book for you.

Buy the book

Get the source code of 12 commercial Flash games, which have been loaded more than 50 million times!

Learn from real world successful examples.

Get it now

Box2D for Flash Games teaches you how to make Flash physics games from scratch with the most advanced features.

Create the new Flash game smashing hit.

Buy the book

Christmas Couples: the finished Poux prototype

This is the last step of the prototype of a Flash game likePoux. Read steps 1, 2 and 3 before continuing.

As said, I finished the game. I called it Christmas Couples

Christmas Couples

Let’s see its features:

* Fancy graphics
* Improved scoring system
* Cool sound loop
* Highscores

As you can see, graphics, sound and highscores are developed from third parts, so I focused only on coding and gameplay.

This is a pretty good example of a copycat game. It’s coded with 204 lines and it took about 6 hours to be completed… and now I am going to explain line by line how it’s made.

Ok.. time to show you some actionscript… obviously all in the 1st (2nd to tell the truth…) frame!

Line 1: Have to stop in this frame because I installed MochiAds and MochiBot on the previuos frame. Yes, I am going to (try to) monetize this game too…

Line 2: This is a mandatory line if you want to use highscores feature provided by ArmorBot

Line 3: Array containing the game field

Line 4: Attaching the splash movieclip. It contains the splash screen, the one you see when you start the game

Line 5: Attaching the play button

Line 6: Attaching the “Stop Sound” button

Lines 7-10: Adjusting play button and sound button positions.

Line 11: Creating a new sound variable

Line 12: Attaching the sound clip linked as music

Line 13: Playing the sound clip 10,000 time starting from second zero (the beginning)

Lines 15-46: Highscores management. This is the code provided by ArmorBot. I only made some changes to make result appear where I want them to appear and to show top 10 only after the last score was submitted.

Line 47: game_init function. This function is called at every new play.

Line 48: Setting removed tiles to zero

Line 49: Setting the score to zero

Line 50: Setting the interval between two new row insertions to 250 (frames)

Line 51: Setting the initial position of the horizontal green bonus bar

Line 52: Setting multiplier bonus to 1

Line 53: Setting game_over to zero (it’s not game over)

Line 54: Settings turns to zero

Line 55: Setting tile placed to zero

Lines 56-61: Initializing the game field with all zeros. Now the board is empty

Line 62: Creating the movieclip that will contain the objects

Line 63: Initializing the text variable that will display the current score (initially zero as seen on line 49)

Line 64: Calling the place_line function. This function will place a new line (line 81)

Line 66: This is the function to be executed when the player presses “play” on the splash screen

Line 67: Saving the name the player entered in the splash screen in a variable called player_name

Line 68: Setting a variable to tell we are actually playing the game

Line 69: Attaching the background of the game

Line 70: Attaching the horizontal green bonus bar

Line 71: Creating an empty movieclip that will contain the time bar

Line 72: Attaching the movieclip that will contain the score

Line 73: Calling the game_init function we saw at line 47

Line 74: Removing the splash screen

Line 75: Moving the Stop Sound button off the stage. I had to do in this way because removeMovieClip does not work on buttons

Line 76: Same thing with the play button itself

Line 78: Function to call if the player presses the Stop Sound button

Line 79: Stop the music

Line 81: Function to place a new line

Line 82: Counting from 1 to 10 (the number of columns)

Line 83: Increasing tiles_placed variable, to keep count of how many tiles we have placed so far

Line 84: If there is a tile in the spot where we should add a new tile…

Line 85: Call the function push_blocks. This function il push blocks from the bottom, to raise the stack of tiles

Line 87: Attaching the new tile

Line 88: Generation of a random number between 1 and 6 and saving it into num

Line 89: Stopping the tile movieclip at the num-th frame. Obviously I have a different tile on each frame

Line 90: Saving tiles_placed value in the field array

Line 93: Function to be executed at every frame

Line 94: If it’s not game over…

Line 95: Decreasing interval… time is passing…

Line 96: If interval reaches zero…

Line 97: Increasing turns variable

Line 98: Setting the new interval value to 250-turns. This means new lines will be placed faster and faster. How faster? 1 frame faster than the last one

Line 99: Calling the function place_line (line 81)

Line 100: Finding a new random position for the horizontal green bonus bar

Line 101: Moving the horizontal green bonus bar to its new position

Line 103: Clearing the bar movieclip

Line 104-109: Displaying the time bar by drawing two lines, one a bit thicker than another. To know more about Flash drawing routines refer to Create a flash draw game like Line Rider or others – part 1

Line 112: Function to push blocks (called at line 85)

Line 113: Scanning all vertical tiles in the col_number column

Line 114: If it’s not game over…

Line 115: If the place we are scanning is not empty…

Line 116: If the row is not the top last row… (it’s very important because if I don’t have more space where to store tiles, it’s game over)

Lines 117-118: Bringing the tile at ith to the ith+1 position… both in the field array and physically

Line 120: If it was the top last row…

Line 121: Making tiles half transparent (it’s game over man…)

Line 122: Setting game_over to 1 (I told you it’s game over…)

Lines 123-126: Sending scores to the highscore table

Line 127: Attaching the game-over movieclip (the one with the highscores)

Lines 128-130: Placing the “play again” button

Line 131: Function to be executed when the player presses the Play again button

Line 132: Remove the movieclip with the tiles

Line 133: Calling game_init function to start a new game (line 47)

Line 134: Removing the game over movieclip

Line 141: Function ti be executed when the player clicks the mouse

Line 142: Checking if we are playing the game

Line 143: Checking if it’s not game over (I could merge this line with the above one with an and)

Lines 144-145: Determining what tile did I click according to mouse coordinates

Line 146: Checking if it’s really a spot where it could be a tile

Line 147: Checking in the field array if there is a tile in the tile-space I clicked

Line 148: If all conditions are true, then call the remove_tiles function you see at line 161

Line 149: Once the tiles have been removed, call update_field function (line 190)

Lines 150-152: Calculating the score for the last move in this way: 2 tiles removed = 2+1= 3 points; 3 tiles removed = 3+2+1 = 6 points… and so on. Score is then multiplied by the multiplier

Line 153: Updating the score string

Line 154: Reset removed variable to zero

Line 155: Reset mutliplier variable to 1

Line 161: Function remove_tiles called at line 148. Three arguments: the x position, the y position and a flag to determine if the tile to remove is the clicked one (that’s why I called with the last argument set to 1 at line 148)

Line 162: Determining which type of tile (star, snowflake, …) I am going to remove according to its current frame

Line 163: If the tile is not the clicked one

Line 164: Function to be executed at every frame for that tile

Line 165: Moving it down by 1 pixel

Line 166: Making it a bit more transparent

Lines 167-169: If it’s completely transparent, then remove it! This is the animation you see when you click a tile

Line 171: Setting its field position to zero… now there is an empty space

Line 172: Increasing remove variable

Lines 173-175: If the tile was in the horizontal green bonus bar, then set the multiplier at 2

Lines 177-179: If there is a tile of the same type on the right of the tile just clicked (or remove) then recursively call remove_tiles for that tile with the clicked argument at zero

Lines 180-182: Same thing with the left tile

Lines 183-188: Same thing with the above and below tiles.

The clicked flag is used to not remove the clicked tile if there aren’t adjacent tiles of the same type

Line 190: Beginning of the update_field function (the last one!) called at line 149

Lines 191-192: Scanning the entire game field

Line 193: If there is an empty space under the field position we are looking at…

Line 194: Assign to falling the vertical position of the tile that must fall down

Line 195: While there is an empty space under the falling tile and it hasn’t reached the “ground”…

Lines 196-198: Updating field array and physically moving down the tile

Line 199: The tile has moved down so falling must decrease

And it’s over! This is the longest all-in-once explaination of this blog! I hope this will be useful

Now I am submitting the game to some portals, then I’ll release the source code.

Meanwhile… enjoy!

Rate this post: 1 Star2 Stars3 Stars4 Stars5 Stars (6 votes, average: 3.67 out of 5)
Loading ... Loading ...
Flash Templates provided by Template Monster are pre-made web design products developed using Flash technology.
They can be easily customized to meet the unique requirements of your project.
Be my fan on Facebook and follow me on Twitter! Exclusive content for my Facebook fans and Twitter followers

This post has 29 comments

  1. Prototype of a Flash game like Poux : Emanuele Feronato - italian geek and PROgrammer

    on November 28, 2007 at 12:11 pm

    [...] 17th update: part 2 released November 22nd update: part 3 released November 28th update: Finished project [...]

  2. Prototype of a Flash game like Poux - Part 2 : Emanuele Feronato - italian geek and PROgrammer

    on November 28, 2007 at 12:12 pm

    [...] 22nd update: part 3 released November 28th update: Finished project [...]

  3. Prototype of a Flash game like Poux - Part 3 : Emanuele Feronato - italian geek and PROgrammer

    on November 28, 2007 at 12:13 pm

    [...] 28th update: Finished project [...]

  4. Jhelle

    on November 28, 2007 at 1:47 pm

    Looks great emanuele!
    Good luck with the monopolizing of it :D
    I recently tried it too with the first game I ever made in flash (for a schoolproject even) after seeing your succes with Circle Chain. In my oppinion it is doing pretty well, I got 35.000 impressions and I only submitted it last friday :)

  5. Kevin

    on November 28, 2007 at 5:50 pm

    Hi Emanuele,

    Your new game looks great! I hope it will be a success.
    By the way, I found your game’s graphic quite artistic. Did you draw them yourself? If yes, would you like to tell us some tips about drawing with flash? (As I can only draw straight lines, circles, squares using the standard tools. I can’t draw in flash using the mouse like drawing on papers using a pen. Therefore my flash game graphics are always very simple.)

  6. bigbill

    on November 28, 2007 at 6:17 pm

    That’s cool however the high score doesn’t seem to work or is that just me?

  7. Frederik J

    on November 28, 2007 at 8:30 pm

    Nice game Emanuele. :) It’s good and simple, and thanks for showing us, what you call a copycat game! Which im pretty sure of, is made fast, make good money, and of course, contains average graphic. Well done!

  8. Robby

    on November 28, 2007 at 8:50 pm

    Really cool game :) love the graphics!! Keep doing what you’re doing Emanuele!

  9. RJ

    on November 28, 2007 at 11:45 pm

    Good game, where did you find that music? It’s very good.

    What’s your game, Jhelle?

    [For Kevin] Graphics are from Zeus Box, as he said in part 3, have a look, it’s quite interesting.

  10. Janaka

    on November 29, 2007 at 12:13 am

    Hi,
    I’m very glade to see some one doing this sort of work for free.
    I have gained so much knowlege from you.

    This problem is not about this lesson but I dont have any way to ask this sorry!

    I’m developing a game these day’s and I was traped in a hole.. I mean I need to know how to code in flash to move a movie clip avoiding obstacles. I someone said to use recursion method but I can’t really figer it out.

    I hope you can tell me a answere

    Thanks a lot!

  11. maciek

    on November 30, 2007 at 12:21 am

    uhh… to do that you need a pathfindind algorithm. It is advanced stuff but if you really wanna do it search for A* algorithm

  12. Jhelle

    on November 30, 2007 at 11:26 am

    RJ:
    My game is Agyta; http://www.newgrounds.com/portal/view/411650.

    And Emanuele I’ve read your trying to find a sponsor for your new game, and someone posted a great site for that on the mochiads forums a few days ago. It is like a auction site for flash games sponsorships!
    here is the url http://www.fantasticchoice.com/

  13. Vixin

    on January 23, 2008 at 4:46 pm

    AAAAAARRRRRRRRRRGGGGGGGGGGG! I cant believe I was so addicted to this game, FINALY got a score of 2300 and I Know I typed in Vixin` rather than Santa Claus – AND ITS NOT ON YOUR HIGH SCORE LIST!

    I want this game updated to Valentines day icons! And Fix The Score List! :p

  14. Emanuele Feronato

    on January 23, 2008 at 4:54 pm

    Great idea! “Valentine Couples” will be out very soon, with some improvements and a better highscore table

  15. Vixin

    on February 7, 2008 at 4:29 am

    K well in the mean time I`m 16th on the all time facebook board at 2343! Woot! Hope you can do the new game in time!

  16. Lynne Sargent

    on April 9, 2008 at 8:28 pm

    Hi Emanuele,
    I am addicted to this little game!! (Started playing it on Facebook, & then searched for your site.) Only problem is, I can’t input my scores so the high score feature is pretty much useless.:(

  17. Nathan

    on April 26, 2008 at 6:56 pm

    It says ‘two OF more’, shouldn’t it be ‘two OR more’. Otherwise, great game!!

  18. Summer Couples: a game made in an airplane : Emanuele Feronato - italian geek and PROgrammer

    on July 8, 2008 at 3:24 pm

    [...] result is the “sequel” of Christmas Couples called Summer [...]

  19. Инструкция по монетизации флэш игр | terbooter

    on October 29, 2008 at 6:57 pm

    [...] Если интересно узнать больше об этих играх, прочтите посты:Circle Сhain, Christmas Couples, [...]

  20. Ten Million Plays Club membership : Emanuele Feronato

    on November 12, 2008 at 1:32 pm

    [...] second Flash game, Christmas Couples, a game released almost a year ago, reached 10,000,000 [...]

  21. Fifteen Million Plays Club membership : Emanuele Feronato

    on April 23, 2009 at 12:38 pm

    [...] months ago, my second game, Christmas Couples, joined the Ten Millions Plays [...]

  22. Guest

    on September 25, 2009 at 2:25 am

    did you release the code?…

  23. About season games : Emanuele Feronato

    on October 23, 2009 at 11:29 pm

    [...] they are classic games with a season theme, just like my two ones, Christmas Couples and Halloween [...]

  24. Marketing influences game revenue three times more than high scores : Emanuele Feronato

    on November 20, 2009 at 1:21 am

    [...] Christmas Couples really sucks, but I submitted it everywhere, and was one of the first games to include the MindJolt API. With its 17,596,730 views it was an incredible success. [...]

  25. Milestone: reached $100 with MochiAds : Emanuele Feronato - italian geek and PROgrammer

    on December 7, 2009 at 10:58 pm

    [...] game is Christmas Couples and is having a second (third) youth since it’s Christmas… I always said season games [...]

  26. vice

    on February 4, 2010 at 3:11 pm

    hi, are gonna still release the code? thx

  27. Dan

    on March 25, 2010 at 4:47 am

    Sweet!

  28. Moccads

    on May 23, 2010 at 6:46 am

    Nice game, I will try to put in my website!

  29. Pat Means

    on January 6, 2011 at 6:52 am

    I love the christmas couples game but I get so frustrated because the total score doesn’t register. This can happen several times, so I have to get back to my games, select it again, and play it again. Sometimes it accepts the score but most of the time it doesn’t. I hope there is some way you can fix it. Thanks