Create an Eskiv Flash game tutorial

Do you know a Flash game called Eskiv? No?

Never mind, it's not the best game around there, but there is a thread called Eskiv Clone? in the forum asking help in making a game like that one.

First, play it a minute

Then, take this prototype, starting from an old tutorial called Flash game creation tutorial - part 1.

ACTIONSCRIPT:
  1. _root.attachMovie("score","score",1);
  2. _root.attachMovie("hero", "hero", 2, {_x:250, _y:200});
  3. _root.attachMovie("target", "target", 3, {_x:Math.random()*400+25, _y:Math.random()*300+25});
  4. power = 3;
  5. enemy_power = 5;
  6. points = 0;
  7. hero.onEnterFrame = function() {
  8.     if (Key.isDown(Key.LEFT)) {
  9.         this._x -= power;
  10.     }
  11.     if (Key.isDown(Key.RIGHT)) {
  12.         this._x += power;
  13.     }
  14.     if (Key.isDown(Key.UP)) {
  15.         this._y -= power;
  16.     }
  17.     if (Key.isDown(Key.DOWN)) {
  18.         this._y += power;
  19.     }
  20. };
  21. target.onEnterFrame = function() {
  22.     dist_x = this._x-hero._x;
  23.     dist_y = this._y-hero._y;
  24.     distance = Math.sqrt(dist_x*dist_x+dist_y*dist_y);
  25.     if (distance<(hero._width+this._width)/2) {
  26.         points++;
  27.         score.scoretxt.text = points;
  28.         this._x = Math.random()*400+25;
  29.         this._y = Math.random()*300+25;
  30.         foe = _root.attachMovie("enemy", "enemy", _root.getNextHighestDepth(), {_x:Math.random()*400+25, _y:Math.random()*300+25});
  31.         foe.dir = Math.floor(Math.random()*4);
  32.         foe.onEnterFrame = function() {
  33.             switch (this.dir) {
  34.             case 0 :
  35.                 this._x += enemy_power;
  36.                 if (this._x>500-this._width/2) {
  37.                     this.dir = 1;
  38.                 }
  39.                 break;
  40.             case 1 :
  41.                 this._x -= enemy_power;
  42.                 if (this._x<0+this._width/2) {
  43.                     this.dir = 0;
  44.                 }
  45.                 break;
  46.             case 2 :
  47.                 this._y += enemy_power;
  48.                 if (this._y>400-this._width/2) {
  49.                     this.dir = 3;
  50.                 }
  51.                 break;
  52.             case 3 :
  53.                 this._y -= enemy_power;
  54.                 if (this._y<0+this._width/2) {
  55.                     this.dir = 2;
  56.                 }
  57.                 break;
  58.             }
  59.             dist_x = this._x-hero._x;
  60.             dist_y = this._y-hero._y;
  61.             distance = Math.sqrt(dist_x*dist_x+dist_y*dist_y);
  62.             if (distance<(hero._width+this._width)/2) {
  63.                 points--;
  64.                 score.scoretxt.text = points;
  65.                 this.removeMovieClip();
  66.             }
  67.         };
  68.     }
  69. };

And this is the result

Move the purple ball with arrow keys and take the red one. Avoid blue ones and score as much as you can.

This version has better collision detection than the original one

Download and play with it

If you liked this post buy me a beer (or two)

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

15 Comment(s)

  1. Mike | Apr 30, 2008 | Reply

    Very nice, but you sould starting doing tutorials on AS 3.0, since they are so few out there.

    It’s a helluva hard to learn, but if we don’t start now we never will…until AS 4.0 comes out and then AS 2.0 becomes obsolete and most of the content on this blog.

  2. Mike | Apr 30, 2008 | Reply

    Oh and by the way, is the possible for you to add categories for AS 2.0 and AS 3.0?

    You probably wrote some As 3.0 games, but I don’t know where to find them.

    Take care.

  3. JDog | Apr 30, 2008 | Reply

    I bet that guy will be super happy to read this !

  4. Xavi-v | May 1, 2008 | Reply

    weird, the .swf doesn’t show up on my browser
    =(

  5. Galaxian | May 1, 2008 | Reply

    The clones are already popping up on NG… Man, if I could only get some graphics together, before people get bored of it. Nice tutorial.

  6. limpeh | May 1, 2008 | Reply

    Nice tutorial. However, I’ve found that I can just ‘avoid’ those ‘bouncy things’ by moving myself out of the ‘gaming area’ :p

  7. Emanuele Feronato | May 1, 2008 | Reply

    Yeah, it’s just a prototype and allows you to cheat easily, but it’s also easy to fix that issue…

  8. Kabomb | May 1, 2008 | Reply

    Hey,

    I remember having this game on my graphic calculator. I don’t think Eskiv was the first version of this game but nevertheless it was a fun addicting time waster.

    I think the best thing you did to improve it was take only 1 off when you get hit instead of having to reset at 0. Also maybe you could make the vertical and horizontal dots a different colour? When I’m moving I always move in a vert or hoz direction and I only look for one direction at a time so maybe that could be useful.

  9. Colonel | May 2, 2008 | Reply

    Thanks for this. I’ve managed to do the same thing but Ive made it much more complicated for myself! good work!

  10. EagleVision | May 2, 2008 | Reply

    Very addicting…Clones, clones…

    I might make a game out of this.

  11. ddar | May 5, 2008 | Reply

    how to make gaeover for this one?

  12. JDog | May 9, 2008 | Reply

    Lives ?

  13. The Dog | May 9, 2008 | Reply

    Infact, how would you get the enemy to spawn on the targets location ? I don’t know why you would want to do that, but just in case =D.

  14. Ashley rudge | May 28, 2008 | Reply

    Hey i edited this game to make the blue balls ghost from pacman and the players character pacman i have a slight problem that i want animation to happen so when i press left it makes his mouth face that way with his mouth opening and shutting plz help

  15. Amy | May 31, 2008 | Reply

    Hi!
    I love this tutorial. Im making a game as we speak but I was wondering could you explain some coding so I can understand it better?

2 Trackback(s)

  1. May 15, 2008: Creation of a Flash highscores API - Step 2 : Emanuele Feronato - italian geek and PROgrammer
  2. May 20, 2008: Jamag: a Flash game you’d better master : Emanuele Feronato - italian geek and PROgrammer

Post a Comment