Prototype of a Flash game like Poux - Part 3

November 28th update: Finished project released

3rd update of the prototype. Remember to read part 1 and 2

It's beginning to become something like a complete one-day game... let me introduce what I did.

First, I added cute graphics... on zeus box you will find some cute free icons with a completely free license, no matter what are you doing with such icons. I downloaded a Christmas pack so now the game looks like a Christmas game. I called the game "Christmas Couples".

Then I added a score system, a time bar, some animations when you click on the icons, increasing difficulty, an highscore system, a game over status and a green "X2" bonus bar acting like a 2X bonus if you remove an icon touching the bar.

Obviously, just in a few rows.

About the highscores, I used an ArmorBot account. Installing it is very easy and you can change almost everything in the highscore page. You can even add your own ad.

The page I made sucks a bit but it's still under development... or maybe not... give it a look. At the moment you can only submit scores under the "triqui" name... but I am going to add a text field in the final version.

Anyway, let's see the actionscript

ACTIONSCRIPT:
  1. // high scores
  2. import ab3.rankz.*;
  3. function __rankz_send__(par1, par2, par3, par4) { /* can't show you the content or you may cheat hiscores */ }
  4. // declaration of the array that will contain the game
  5. field = Array();
  6. // number of icons actually removed
  7. removed = 0;
  8. // your score
  9. score = 0;
  10. // number of frames to pass before inserting a new row
  11. interval = 250;
  12. // position of the horizontal x2 multiplier
  13. x2_horiz_pos = 0;
  14. // multiplier bonus
  15. mult = 1;
  16. // is a game over?
  17. game_over = 0;
  18. // turns passed. A turn = a new row to insert
  19. turns = 0;
  20. // tiles placed so far
  21. tiles_placed = 0;
  22. // loop that initializes the field
  23. for (x=0; x<10; x++) {
  24.     field[x] = Array();
  25.     for (y=0; y<10; y++) {
  26.         field[x][y] = 0;
  27.     }
  28. }
  29. // blue background
  30. _root.attachMovie("bg", "bg", _root.getNextHighestDepth());
  31. // x2 bonus
  32. _root.attachMovie("x2_horiz", "x2_horiz", _root.getNextHighestDepth(), {_x:10});
  33. // icons container
  34. _root.createEmptyMovieClip("things", _root.getNextHighestDepth());
  35. // time bar
  36. _root.createEmptyMovieClip("bar", _root.getNextHighestDepth());
  37. // score
  38. _root.attachMovie("score", "score_obj", _root.getNextHighestDepth(), {_x:350, _y:20});
  39. // function that places a line of tiles in the bottom of the field
  40. function place_line() {
  41.     for (x=0; x<10; x++) {
  42.         tiles_placed++;
  43.         // if the spot is not empty, must shift the colum
  44.         if (field[x][0] != 0) {
  45.             push_blocks(x);
  46.         }
  47.         tile = things.attachMovie("tile", "tile_"+tiles_placed, tiles_placed, {_x:10+32*x, _y:300});
  48.         num = Math.floor(Math.random()*6)+1;
  49.         tile.gotoAndStop(num);
  50.         field[x][0] = tiles_placed;
  51.     }
  52. }
  53. // function to be executed at every frame
  54. _root.onEnterFrame = function() {
  55.     if (!game_over) {
  56.         interval--;
  57.         if (interval == 0) {
  58.             turns++;
  59.             // increasing difficulty
  60.             interval = 250-turns;
  61.             place_line();
  62.             // moving x2 bonus bar
  63.             x2_horiz_pos = Math.floor(Math.random()*10);
  64.             x2_horiz._y = 300-x2_horiz_pos*32;
  65.         }
  66.         // showing time bar
  67.         bar.clear();
  68.         bar.lineStyle(6, 0xfff153);
  69.         bar.moveTo(10, 350);
  70.         bar.lineTo(328, 350);
  71.         bar.lineStyle(4, 0xea8400);
  72.         bar.moveTo(10, 350);
  73.         bar.lineTo(10+318*interval/(250-turns), 350);
  74.     }
  75. };
  76. // function that shifts the column of blocks
  77. function push_blocks(col_number) {
  78.     for (i=9; i>=0; i--) {
  79.         if (field[col_number][i] != 0) {
  80.             if (i != 9) {
  81.                 field[col_number][i+1] = field[col_number][i];
  82.                 things["tile_"+field[col_number][i]]._y -= 32;
  83.             } else {
  84.                 // if I have more than 10 blocks in a column, remove the 10th block
  85.                 // In a normal game, it would be "game over"
  86.                 // update: now IT IS game over
  87.                 things._alpha = 50;
  88.                 _root.attachMovie("ohno", "ohno", _root.getNextHighestDepth(), {_x:100, _y:95});
  89.                 game_over = 1;
  90.                 // Here I removed some lines to send high scores
  91.             }
  92.         }
  93.     }
  94. }
  95. // when the player clicks...
  96. onMouseDown = function () {
  97.     if (!game_over) {
  98.         // obtain tile clicked according to mouse position
  99.         x_tile_clicked = Math.floor((_root._xmouse-10)/32);
  100.         y_tile_clicked = -Math.floor((_root._ymouse-300)/32);
  101.         if ((x_tile_clicked>=0) and (x_tile_clicked<=9) and (y_tile_clicked>=0) and (y_tile_clicked<=9)) {
  102.             if (field[x_tile_clicked][y_tile_clicked] != 0) {
  103.                 remove_tiles(x_tile_clicked, y_tile_clicked, 1);
  104.                 update_field();
  105.                 // calculating score
  106.                 for (i=1; i<=removed; i++) {
  107.                     score += (i*mult);
  108.                 }
  109.                 score_obj.score.text = "Score: "+score;
  110.                 removed = 0;
  111.                 mult = 1;
  112.             }
  113.         }
  114.     }
  115. };
  116. // removing tiles of the same color of the one clicked
  117. function remove_tiles(tx, ty, clicked) {
  118.     // checking tile color according to its current frame
  119.     tile_type = things["tile_"+field[tx][ty]]._currentframe;
  120.     // check if the tile to remove is the one you clicked. In this case, wait to have at least two tiles to remove
  121.     if (!clicked) {
  122.         // icon animation
  123.         things["tile_"+field[tx][ty]].onEnterFrame = function() {
  124.             this._y++;
  125.             this._alpha--;
  126.             if (this._alpha == 0) {
  127.                 this.removeMovieClip();
  128.             }
  129.         };
  130.         field[tx][ty] = 0;
  131.         removed++;
  132.         if (ty == x2_horiz_pos) {
  133.             // bonus
  134.             mult = 2;
  135.         }
  136.     }
  137.     if ((field[tx+1][ty] != 0) and (things["tile_"+field[tx+1][ty]]._currentframe == tile_type)) {
  138.         remove_tiles(tx+1, ty);
  139.     }
  140.     if ((field[tx-1][ty] != 0) and (things["tile_"+field[tx-1][ty]]._currentframe == tile_type)) {
  141.         remove_tiles(tx-1, ty);
  142.     }
  143.     if ((field[tx][ty+1] != 0) and (things["tile_"+field[tx][ty+1]]._currentframe == tile_type)) {
  144.         remove_tiles(tx, ty+1);
  145.     }
  146.     if ((field[tx][ty-1] != 0) and (things["tile_"+field[tx][ty-1]]._currentframe == tile_type)) {
  147.         remove_tiles(tx, ty-1);
  148.     }
  149. }
  150. // update the field, making tiles fall if bottom tiles disappear
  151. function update_field() {
  152.     for (i=0; i<10; i++) {
  153.         for (j=1; j<10; j++) {
  154.             if ((field[i][j] != 0) and (field[i][j-1] == 0)) {
  155.                 falling = j-1;
  156.                 while ((field[i][falling] == 0) and (falling>=0)) {
  157.                     field[i][falling] = field[i][falling+1];
  158.                     things["tile_"+field[i][falling+1]]._y += 32;
  159.                     field[i][falling+1] = 0;
  160.                     falling--;
  161.                 }
  162.             }
  163.         }
  164.     }
  165. }

and this is the game

At the moment, if you die you have to reload the page. That's life... play and don't forget to look at the highscores to see if your score was awesome or you're just a rookie....

Read the post about the finished project!!

Improve the blog rating this post
Tell me what do you think about this post. I'll write better and better entries.
1 Star2 Stars3 Stars4 Stars5 Stars (1 votes, average: 5 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.

18 Responses to “Prototype of a Flash game like Poux - Part 3”

  1. Hawdon on November 22nd, 2007 4:22 am

    lol im the 10th on the score board xD
    Nice tut!
    Vey good!
    Thx :D
    even Tho right now im working on a line rider

  2. shiv1411 on November 22nd, 2007 9:03 am

    cooooooooool

  3. Frederik J on November 22nd, 2007 4:04 pm

    Good job emanuele. And nice theme! ;)
    Of course it could be better. But anyway, you’re teaching us in a great way :D

  4. Ed on November 22nd, 2007 6:35 pm

    Did you just make it you couldn’t reset because you couldn’t be bothered to make a reset button and get rid of all the complicated annoying variables and duplicated MCs? :P

    Nice tut, and I came 37th (though make it we can submit our scores) :)

  5. David on November 22nd, 2007 6:52 pm

    brilliant

    Emanuele, can you help me by having a tutorial on how to create a handbrake motion for a car?

  6. CGR on November 22nd, 2007 7:07 pm

    I got 10219 points, cool passtime.

  7. Tony on November 22nd, 2007 7:24 pm

    I miss some sounds or music. Good tut
    I can’t wait for the next platform tutorial!

    I was 3rd with 545.

  8. Tony on November 22nd, 2007 7:28 pm

    681! Now I’m second

    Watch out, CGR!

  9. ijjid on November 22nd, 2007 8:15 pm

    your tutorial is impressive for someone beginner like me!you rock!

    do you have tutorials on creating multiplayer flash games?i mean just the basic things to know and how to do it as what you did on you game tutorial(step by step)…it was really a great lecture for a beginner like me..i think i could create my own game out of it.thx!

  10. ijjid on November 22nd, 2007 8:19 pm

    by-the-way, im talking about the one you post in here: http://www.gotoandplay.it/_articles/2007/02/game_tutorial_part3.php

  11. shiv1411 on November 24th, 2007 1:33 pm

    hi emnauele,

    whats up?

    I was creating this game with multiple levels and when I published it, I saw one great bug. A player can simply roam through my levels just by right-clicking and then clicking play, he automatically advances to the next frame, or next level.

    Please tell me how can I solve this problem.

  12. Ed on November 24th, 2007 1:40 pm

    shiv, have a look at this tutorial:

    http://www.newgrounds.com/portal/view/201218

    Take a look at the customizable right click menu.

  13. CGR on November 24th, 2007 9:12 pm

    Ur almost there tony ^^

  14. Eblup on November 25th, 2007 7:51 am

    hey can you plz make a AI tutoreal for a platform game? like you run around,attack, and other enemyes attack.

    if you can make code this complicated then cant you make AI enemys thet you can fight.
    oh and look at dead frontire!

  15. shiv1411 on November 27th, 2007 8:58 am

    thanks Ed,
    now I can give a good reply to those cheaters!

  16. dan on November 28th, 2007 5:30 am

    hey
    could you post the source file here? i tried to code this but the background, scoreboard and multiplier bar dont show up.

    thanks

Leave a Reply




Trackbacks

  1. Prototype of a Flash game like Poux - Part 2 : Emanuele Feronato - italian geek and PROgrammer on November 22nd, 2007 1:56 am

    [...] 22nd update: part 3 [...]

  2. Prototype of a Flash game like Poux : Emanuele Feronato - italian geek and PROgrammer on November 22nd, 2007 1:56 am

    [...] 17th update: part 2 released November 22nd update: part 3 released Ok, I know, you are asking for full tutorials and not prototypes, but you have to know [...]