Create a Flash game like Gold Miner – step 2

I received a lot of emails asking me to add left-right movement to my Gold Miner clone and requiring more information about manually placing the boulders.

In order to add left-right movement, you need to check for left and right arrow keys and move the hook in the proper direction.

Just remember you don’t have to let the hook move out of the stage and to update the starting/ending points of the rope.

When you want to manually place boulders, you need an array.

In the one I created, every boulder is an array made this way

[x position, y position, diameter]

Then I created an array containing n boulder arrays where n is the number of boulder I wanted to be in the stage.

Here it is the commented code:

And here it is the result…

Left/right arrows to move, mousebutton to fire.

Download the source code and enjoy

  • Erv

    thank you!

  • Can’t wait to see AS3.0 version of Gold Miner example code.

  • Erv

    BTW How can we make it so the spike change on picking up and penetrates the boulder, also changing the boulder, with sprites maybe?

    I’m trying but no luck.

  • Kevin

    Erv, one way you could do this would be to simply create another frame for the pod. Then where the pod “picks” the boulder just add a frame change for the pod.

    I have my pod changing frames when the user clicks the mouse so it opens, then closes when it touches a boulder. Or it closes when it reaches the outside of the level.

  • Hi, thanks… im going to develop one soon.

  • Erv

    Kevin, yes but if you play the real Gold Miner game you will see that when you hit a Bag, the pod penetrates it also differs depending what object you’re picking up.

    Maybe that could be on hit, remove object movie and set pod frame on the frame where u pick up the kind of boulder?

  • I think something is wrong with your RSS Feed. The latest article I have from you is “tips for learning a new language”. It seems to only update the feed sporadically.

  • IM GONNA MAKE MY FIRST FLASH GAME!

  • oliver_l1

    is it possible to get an as3 version of this prototype ? thanks.

  • teltom

    Hey,

    I’m wondering how to set the acceleration and friction to the movieClip. I was trying to add to the above code something like this:

    power = 0.1;
    yspeed = 0;
    xspeed = 0;
    friction = 0.95;
    zwolnienie = 4;

    if (Key.isDown(Key.LEFT)) {
    xspeed -= power*zwolnienie;
    }
    if (Key.isDown(Key.RIGHT)) {
    xspeed += power*zwolnienie;
    }
    if (Key.isDown(Key.PGUP)) {
    yspeed -= power;
    }
    if (Key.isDown(Key.PGDN)) {
    yspeed += power;

    }
    xspeed *= friction;
    yspeed *= friction;
    pod._y += yspeed;
    pod._x += xspeed;

    But it doesn’t work:(

  • Pingback: Creating multiple objects for…()

  • bikash pradhan

    how do i reverse the direction of the pod.
    how can i bring the position of the pod to the bottom of the stage

  • ohio

    how to make change and score on boulder

  • 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 code/instruction]
    – PLs. & Thanks

  • 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 code/instruction]
    – PLs. & Thanks [pls. reply back]