Create a Flash game like Gold Miner

Today I received an email from a reader asking me to make a tutorial of a game like Gold Miner.

Gold Miner

It’s a Flash demo of a downloadable game, and I think its gameplay is interesting enough to deserve a tutorial.

The main actor in this game is the hook (in the original game, a claw).

The hook can have three states, that I defined this way:

rotate: that’s when the hook is rotating from left to right at the top of the screen. If the player presses the mouse the state turns to…

shoot: the hook moves in a fixed direction (the one it had when the player pressed the mouse) until it hits a gem or flies off the screen. Then the state turns again to…

rewind: the hook returns, in a straight path, to its initial position and changes the state to rotate, allowing the player to shoot again.

Rewind speed is the same as shoot speed if the hook did not take any boulder, while if the hook has a boulder attached, there will be a slowdown according to boulder size

Let’s see the commented code… remember that the hook is linked as pod while the gem as boulder

And this is the result

As you can see, the basics have been reproduced.

Download the source code.

  • Jack Hopkins

    Cool! I loved this game when I first played it :D

  • Very cool game idea!

  • Christian

    hey really cool game…played it for 30mins+ and this is rare for me ;)

  • Erv

    A million thanks Emanuele!

    I’ll show you once I finish the game now.

    Erv

  • Erv

    Altho I was wondering how is it possible to add the Boulders manually and being able to move the base of the rope left n right.

  • val

    this is awesome!!

  • MalQue

    This reminds me of Double Wire without the swinging. (DW)was AWESOME! but this is cool too.

  • anonymouse

    This is great!

    could you show how to also make lead boulders, like there are in the game?

    I keep trying but it stuffs up.

    thanks

  • lolek

    I made a game based on this, but i have a problem… the boulders aren’t removed on the next frame (they tay tehre?!?!?) how to remove them?

  • Pingback: Create a Flash game like Gold Miner - step 2 : Emanuele Feronato()

  • @lolek,if you doing with frames you probably use bould_n.removeMovieClip();
    Create some loop like
    for (x=1; x<=boulders; x++)
    {
    [“bould_”+x}.removeMovieClip();
    }
    to clear stage or something…
    or boulders may be in own “layer” then will be
    boulders_ly.removeMovieClip()….
    so many ways to do it, read help and this blog:)

  • raelz

    Again, thanks for this great tutorial. I’m a newbie, so don’t consider this as criticising, I am merely trying to understand the code:
    Wouldn’t it be better to determine the hotspot somewhere outside the switch, so it doesn’t have to be determined over and over?

  • vahidshahi

    hello.
    can you send c# source code of this game to me?
    fine thanks.

  • vahidshahi

    hello.
    can you send c# code for this game to me?
    fine thanks.

  • Pingback: Triqui’s Picks #5 : Emanuele Feronato()

  • Pingback: Ononmin Flash prototype : Emanuele Feronato - italian geek and PROgrammer()

  • Vikas

    gr8 indeed……….

  • Rufino Salgado

    I wanted to ask what I needed to get and where I could get it in order to make games like these. Should I know about any specific programming languages in order to do this? Thanks for the help.

  • vice

    what about the stones? how you define them and make the hook go slower?

  • TKK Praneeth

    This is the actionscript 3 code of goldminer. Did this on my own as a mini project in my sem(at present).im a newbie to Flash.Here i get an error saying::
    ArgumentError: Error #1063: Argument count mismatch on gold_edit_fla::MainTimeline/func3(). Expected 0, got 1.

    can any1 fix this error…i have to submit this by 2moro morning….plz….

    code is this:
    var boulders:Number = 20, a:Number=1;
    var pod_status:String = “rotate”;
    var hot_spot_x:Number,hot_spot_y:Number;
    var dir:Number;
    var slowdown:Number=0,rotation_dir:Number = 2;;

    for (a=1; a400 || hot_spot_x500)
    {
    pod_status = “rewind”;
    }
    rod.graphics.clear();
    rod.graphics.lineStyle(1,0×000000);
    rod.graphics.moveTo(250,0);
    rod.graphics.lineTo(this.x,this.y);
    break;

    case “rewind” :
    hot_spot_x = pod1.x+40*Math.cos(dir);
    hot_spot_y = pod1.y+40*Math.sin(dir);
    pod1.x -= (10-slowdown)*Math.cos(dir);
    pod1.y -= (10-slowdown)*Math.sin(dir);
    if (pod1.y<0) {
    pod1.y = 0;
    pod1.x = 250;
    pod_status = "rotate";
    }
    rod.graphics.clear();
    rod.graphics.lineStyle(1,0×000000);
    rod.graphics.moveTo(250,0);
    rod.graphics.lineTo(this.x,this.y);
    break;

    }
    }

    stage.addEventListener(MouseEvent.CLICK,func3);
    function func3()
    {
    if (pod_status == "rotate")
    {
    //var z=pod1.rotation+90;
    //dir = z*0.0174532925;
    //dir = (pod1.rotation+90)*0.0174532925;
    pod_status = "shoot";
    }
    }

  • TKK Praneeth

    in func3() i commented dir=(pod1.rotation+90)*0.0174532925;

    it is also present…check the code using it…

  • TKK Praneeth

    Edited the above code a lot…n now im getin d goldminer game…but im having nly dis error.

    ArgumentError: Error #2025: The supplied DisplayObject must be a child of the caller. at flash.display::DisplayObjectContainer/removeChild()
    at gold_edit_name_fla::MainTimeline/func1()

    here pod instance name is pod1 n for boulder is bould.

    var boulders:Number = 20, a:Number=1;
    var pod_status:String = “rotate”;
    var hot_spot_x:Number,hot_spot_y:Number;
    var dir:Number;
    var slowdown:Number=0,rotation_dir:Number = 2;;

    for (a=1; a400 || hot_spot_x500)
    {
    pod_status = “rewind”;
    }
    rod.graphics.clear();
    rod.graphics.lineStyle(1,0×000000);
    rod.graphics.moveTo(250,0);
    rod.graphics.lineTo(pod1.x,pod1.y);
    break;

    case “rewind” :
    hot_spot_x = pod1.x+40*Math.cos(dir);
    hot_spot_y = pod1.y+40*Math.sin(dir);
    pod1.x -= (10-slowdown)*Math.cos(dir);
    pod1.y -= (10-slowdown)*Math.sin(dir);
    if (pod1.y<0) {
    pod1.y = 0;
    pod1.x = 250;
    pod_status = "rotate";
    }
    rod.graphics.clear();
    rod.graphics.lineStyle(1,0×000000);
    rod.graphics.moveTo(250,0);
    rod.graphics.lineTo(pod1.x,pod1.y);
    break;

    }
    }

    stage.addEventListener(MouseEvent.CLICK,func3);
    function func3(evt:MouseEvent):void
    {
    if (pod_status == "rotate")
    {
    dir = (pod1.rotation+90)*0.0174532925;
    pod_status = "shoot";
    }
    }

  • haha very cool tutorial. I want to make my own flash game but the problem is I do not know how to use a flash software.funny.

  • Victor Michael

    Hello emmanuele i just want to say it’s indeed a very wonderful moment for me to be here, because indeed i really think i can learn alot from people like you who are ready to teach others ……….. just keep it up and i want you to send me just send me the step’s used in creating the Gold Miners game to mail add talk2every1@yahoo.com

  • Jon Ace Aparicio

    hello,good day…i really appreciate this game (gold miner) and that’s why during our proposal in our software engineering class, i proposed a game related to the concept of this one. I just have a problem. I still don’t know how to use flash cs4 and and our deadline of submission is fast approaching. I know that it would be hard for me to find someone who would willingly teach me,but im hoping that i would find him/her here…thanks…Godbless

  • Definitily a good tutorial. Going to try to make a cool game for my gaming website. Thanks for sharing :-)

  • Nice Tutorials ..

  • Abby

    I’m having a bit of problem with this tutorial, how do you remove the hook/pod and boulders in the next frame? [please give me the exact as2 code/instruction]
    – PLs. & Thanks [pls. reply back]

  • Thanks, that’s great, really!

  • lilipop

    how can i move boulders and picked then with the hook

  • marlon

    what application do u use for building such games? Citrus Engine ??

  • waw thats really cool! very good lesson thank you

  • I am the original creator of the Gold Miner game. Glad you liked it. The original was done in flash 5 and used mostly movie clips to make it work. My most recent “Gold Miner” type game is called Finders keepers. It’s on jenkatgames.com .

  • John

    How can I convert this code to C Sharp ( using Unity ) . Plz help.