Making a ‘Copter’ style game – The Projects

Hello – April’s project is here at last!

Nice and simple this time around; we’re going to make a game like ‘Copter’. I’ve covered this in the video but I’ll mention it here too: Copying games can be a nice way to learn, just don’t make a habit of it. If you’re developing something for commercial purposes you’re not going to make any friends by ripping other people off. The people who made the original Copter can’t lay claim the genre, so feel free to do your own thing with it (as Halfbrick have done with ‘Jetpack Joyride’) but make sure it is unique enough to not be considered a clone.

With that out of the way, hop into the video to make something like this:

Video:

Source files:

The video doesn’t cover everything from the sample game above, so there are plenty of extra bits for you to look in to. As a rough guide, the clouds are basically the same as the blocks (without collision) and the steam at the back of the chopper is very similar to the explosion pieces. I used the random hills project as a background and various other little techniques from the Point, Click, Win! tutorial series to do the rest.

Your turn! Show me what you’ve got ;)

Ant

This entry was posted in Flash, Games and tagged , , . Bookmark the permalink.

16 Responses to Making a ‘Copter’ style game – The Projects

  1. avatar Naki says:

    just finished following your tutorial and here is my final result..
    http://naki.x10.mx/myCopter/copter.html

    not quite so good but I have learned a lot of things.. simple mouse x and y, math and simple animation, still waiting for the game menu tutorial just like the one above.
    Thanks! :)

  2. avatar Ant says:

    :) nice job

    You can find most, if not all, of the other bits of my version in my other tutorials. Check the ActionScript tutorials link up top

  3. avatar ico170 says:

    http://www.kongregate.com/games/ico170/super-b

    well here is my version i used most of your tutorials for this

  4. avatar Boopesh says:

    How to make the game replay after a certain amount of time.My result is here:
    http://www.pictogame.com/en/play/game/Yaxdj4BBGiHC_helicopter

    • avatar Ant says:

      You could use a timer (look at some of my other tutorials for that) or simply let the timeline play through a few frames before returning to the menu.

      I put menus and timers in the Point Click Win game, they’re all linked in the ActionScript tutorials page at the top

  5. avatar andrew says:

    great tut, learned a lot. quick question, where did the as go that moves the blocks to the left. Cant seem to find that layer of as in the source files. Just curious what is currently driving the blocks to the left.

    • avatar Ant says:

      Hi, it’s inside the Block object, on its timeline.

      The rest of the code is on the main timeline, which I guess is where you’re looking

      • avatar andrew says:

        Ahh I knew it had to be there, thanks for all the great tuts. I’m still tweeking my chopper game, I added a laser to the chopper and now trying to set up hit detection with the enemy planes. Do you think I need to use the same “getchildat” and the iterator or is there a simpler way? When I tried just hittesting blocks with the laser I got “cannot convert Block$ to flash.display.movieclip. I tried typecasting it but no luck. I hate to bug you but you have a great way of explaining things.

        • avatar Ant says:

          You could just store all your blocks in an Array instead of looping through everything (which gets a bit sluggish if you have a LOT of stuff on screen). Not quite sure why you are getting the casting error! Paste the code responsible and I’ll try to help

  6. avatar andrew says:

    Thanks Ant, your the best. Here’s how I tried to shoehorn it together so far..

    I’m not using the turret class, just the bullet and game classes. I added some as3 into the main game timeline to generate bullets. Here it is in full:

    import flash.events.Event;
    import flash.events.MouseEvent;
    import flash.display.MovieClip;
    import flash.display.MovieClip;
    import flash.events.Event;
    import flash.geom.Point;
    import flash.events.MouseEvent;
    import flash.ui.Keyboard;
    import flash.events.KeyboardEvent;

    var mouseIsDown = false;// mouse isn’t held at start
    var speed = 0;// no speed at the start
    var score = 0;// start with no score!

    // check for collisions every frame
    addEventListener(Event.ENTER_FRAME, mainLoop);

    var upPressed:Boolean = false;
    var downPressed:Boolean = false;
    var leftPressed:Boolean = false;
    var rightPressed:Boolean = false;

    player.addEventListener(Event.ENTER_FRAME, fl_MoveInDirectionOfKey);
    stage.addEventListener(KeyboardEvent.KEY_DOWN, fl_SetKeyPressed);
    stage.addEventListener(KeyboardEvent.KEY_UP, fl_UnsetKeyPressed);
    stage.addEventListener(MouseEvent.CLICK, fire);

    // explain the mouse functions
    function fire(event:Event)
    {
    var b = new Bullet();
    parent.addChild(b);
    //set the position and rotation of bullet;
    b.rotation = rotation;
    b.x = player.x + 50;
    b.y = player.y + 15;
    trace(“bullet fired”);

    }

    // explain the main game loop
    function mainLoop(e:Event)
    {
    // update the score!
    score = score + 10;
    // update the text field
    output.text = “Score: ” + score;

    // limit the speed
    if (speed > 10)
    {
    speed = 10;
    }
    if (speed < -10)
    {
    speed = -10;
    }// move the player based on the speed
    player.y += speed;
    // loop through everything on screen
    for (var i = 0; i<numChildren; i++)
    {
    // check to see if this object is a block
    if (getChildAt(i) is Block || getChildAt(i) is Boundary)
    {
    var c = getChildAt(i) as MovieClip;
    // this means the object is a block
    // check the block against the player object
    if (c.hitTestObject(player))
    {
    // make an explosion
    for (var counter = 0; counter<12; counter++)
    {
    // make a new Boom object
    var boom = new Boom();
    boom.x = player.x;
    boom.y = player.y;
    // randomly rotate boom
    boom.rotation = Math.random() * 360;
    // randomly scale it
    boom.scaleX = boom.scaleY = 0.5 + Math.random();
    // add the boom to the world
    addChild(boom);
    }
    // hide the player
    player.visible = false;
    removeEventListener(Event.ENTER_FRAME, mainLoop);
    }
    }
    }

    }

  7. avatar Ant says:

    Hey, after a 2nd read I think you are getting the type error because you’re using Block, the class name, instead of an instance of a Block when you check against your laser. I can’t see that particular part in the code you just pasted though! Drop me an email with it if you can’t fix it based on that

  8. avatar dairon says:

    Hey i try to made it but at the last part something has go’d wrong pleasee help me

    import flash.events.Event;
    import flash.events.MouseEvent;

    var mouseIsDown = false;// mouse isnt held at start
    var speed = 0;// no speed

    // check for collisions every frame
    addEventListener(Event.ENTER_FRAME, mainloop);
    // add 2 event listners for the mouse button
    stage.addEventListener(MouseEvent.MOUSE_DOWN, clicked);
    stage.addEventListener(MouseEvent.MOUSE_UP, unclicked);

    // explain the mouse function
    function clicked(m:MouseEvent)
    {
    mouseIsDown = true;
    }

    function unclicked(m:MouseEvent)
    {
    mouseIsDown = false;
    }

    // explain the main loop
    function mainloop(e:Event)
    {
    // move player based on mouse button
    if (mouseIsDown)
    {
    speed -= 2;// take sum of the speed
    }
    else
    {
    speed += 2;//move down
    }
    //li,it speed
    if (speed > 10)
    {
    speed = 10;
    }
    if (speed < -10)
    {
    speed = -10;
    }//move player based on speed
    player.y += speed;
    // loop trough everything on screen
    for (var i = 0; i<numChildren; i++)
    {
    // check to see if this object is a block
    if (getChildAt(i) is Block)
    {
    var b = getChildAt(i) as Block;
    //this means the object is a block
    // check the block against the player object
    if (b.hitTestObject(player))
    {

    //hide player when die
    player.visible = false;
    removeEventListener(Event.ENTER_FRAME, mainloop);
    }
    }
    }
    }

Leave a Reply

Your email address will not be published. Required fields are marked *

*


× 2 = twelve

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>