Create a Flash Game like Nano War

Some days ago I played a bit Nano War.

Nano War

It’s an interesting RTS, and pretty easy to delvelop.

In this part we’ll analyze the unit selection system.

In Nano War your units are circles, and this helps a lot because it’s very easy to determine collisions knowing radius and center.

Anyway, you can select units in these ways:

Click on an unselected unit: you select the unit

Click on an selected unit: you keep selecting the unit (good!)

Click outside an unit: you deselect all units

Click outside an unit and drag mouse: you select all units whose center is inside the shape you are drawing bby dragging the mouse.

In this example, 10 units are randomly placed around the screen, avoiding them to overlap.

Then, you can select and deselect them in the way explained before.

Units are made by a circle object linked as “sphere” with two frames: frame 1 is a black circle and represents the unit when deselected, while frame 2 is a red circle and represents the unit when selected.

Now, a little commented actionscript:

And this is the result… easy to play… just select unit clicking on them or dragging.

Deselect by clicking elsewhere.

I would like to spend two words on beginFill() that I never covered on the blog…

beginFill() indicates the beginning of a new drawing path. If an open path exists and it has a fill associated with it, that path is closed with a line and then filled.

During next part we’ll manage unit invasion.

Meanwhile download the source code.

  • Xodus

    Hey, im really excited about this game concept, i cant wait for the next tut. Good post.

    Btw, i suddenly noticed that you dont have the line “if you liked this post, you can buy me a beer (or two)” Why did you take it off?

  • Questo

    maybe you can fix a small bug that doesn’t matter thats in the actual game:

    If you have a unit selected while it is taken over it still has a line coming out of it (it can’t shoot or do anything for you anything but still)

  • Oh, nice.

    I played this, a lot. I was -hoooooked-

    I look forward to the rest of this.

  • Thanks for the tutorial :)
    I always wondered how I could do a selection sort of thing in actionscript

  • Great Tut!

  • Looks good !

  • samedi

    this game is a similar one with a twist
    http://www.newgrounds.com/portal/view/449961

    i like both ones… like tic tac toe on steroids
    My problem with these games are that after you have found the right strategy its impossibles to loose.

    I think explaining how to create an AI for a game like this would be a great tutorial

  • Hi,
    I’m surprised to see my game on this website :).

    Regards.

  • Pingback: Flash Tutorials | AS3, AS2 Flash game tutorials roundup part 2 | Lemlinh.com()

  • Pingback: Flash obstacle avoidance prototype : Emanuele Feronato()

  • Wow I make this step-by-step and I played with it!

    Nice tutorial!

  • Pingback: Actionscript tutorial for RTS/Strategy Flash Game | PencilGym.com()

  • future systemz

    Where the next tutorial?