Build 10 games and learn game development along the way in this fast paced game development course

Get the source code of 12 commercial games, loaded 50+ million times, and learn the secrets of game design

Learn how to make a successful Flash game from a real world example. Fully commented source code

Create realistic Flash physics games from scratch with advanced features, from Angry Birds to Crush the Castle

Create a Flash game like Deflection

Multipart tutorial: available parts 1, 2, 3

Today I spent some time with a game called Deflection.

Deflection

According to his author, it’s an addictive physics based game where the objective is to deflect the ball into the goal by creating deflection walls.

I bet I scared most of you with the word “physics”. This means a physics engine, massive AS3 coding, and so on.

Although I am seriously determined to start a tutorial series about latest physics engines, I played a bit with Deflection and I noticed the only physics involved in the game is used to determine the bounce of a regular shape (a circle – the ball) when collides with a line.

So I thought there was another way to create an engine like this one without using physics libraries.

The answer lies in an old vector tutorial made by Tony Pa called Ball in the corner.

I suggest you to read all Tony’s vector tutorials to understand the math behind the engine.

I made some changes to the tutorial in order to make it more “AS2 like” (it’s an old AS1 tutorial) and to manage an arbitrary number of lines.

In this step you will only see the engine working with 4 lines and no user interaction, but it’s really easy to add lines at runtime with the mouse (I’ll cover it in the next step).

Moreover, this is another good example about how to use a Flash game tutorial to make your own game.

Ok, now it’s time to show you the modified actionscript:

and this is the result… your own AS2 deflection engine ready for you to create a game.

If you want to write the code for player interaction, I will be happy to publish it, otherwise wait for me to do it.

Download the source code and enjoy.
Multipart tutorial: available parts 1, 2, 3

Rate this post: 1 Star2 Stars3 Stars4 Stars5 Stars (28 votes, average: 4.36 out of 5)
Loading...Loading...
Learn how to make a successful commercial Flash game from a real world example: get the fully commented source code of Globez, a Flash game played millions of times which generated a four figure income. Limited copies available.

Get it now
Be my fan on Facebook and follow me on Twitter! Exclusive content for my Facebook fans and Twitter followers

This post has 14 comments

  1. CatFurnace

    on July 9, 2008 at 12:34 pm

    “I am seriously determined to start a tutorial series about latest physics engines” – Please do this! I’m very keen to learn either Box2D AS3 or APE, but can’t get over the first hurdle.
    An Emanuele Tutorial is just what I need!
    Very exciting news.

  2. Emanuele Cipolloni

    on July 9, 2008 at 1:19 pm

    Yes I guess the word “physics” scares the vast majority of developers, my self included!

    Very nice article and very interesting blog!

  3. FrozenHaddock

    on July 9, 2008 at 3:22 pm

    An Emanuele tutorial on Box2DAS3 would be perfect.

    This looks snazzy too, looking forward to the next part!

  4. Josh Dura

    on July 9, 2008 at 5:10 pm

    Um, correct me if I am wrong, but this isn’t AS2 :) You aren’t even typing your variables. Don’t get me wrong, it’s fairly well structured AS1, but I just don’t see how this is AS2.

  5. Kaolin Fire

    on July 10, 2008 at 7:02 am

    Thanks for the link to the vector tutorials. The graphics really made things click faster than otherwise :)

  6. D&G

    on July 10, 2008 at 9:59 am

    Thank you,learning…..

  7. ssusnic

    on July 10, 2008 at 5:52 pm

    Hi all,

    You can find the source code of my implementation for the player interaction as an addition to this
    tutorial at my website
    http://www.askforgametask.com !

  8. Jack Hopkins

    on July 10, 2008 at 9:49 pm

    Did any of you guys hear? APE has been discontinued (physics….)

  9. Create a Flash game like Deflection - part 2 : Emanuele Feronato - italian geek and PROgrammer

    on July 12, 2008 at 1:09 pm

    […] the 1st part I showed you how to make a deflection engine starting from an old tutorial, now it’s time to let […]

  10. Web-Game Magazine - the best free action/adventure web games and casual games, reviewed daily » Blog Archive » Create a Flash game like Deflection - part 2

    on July 14, 2008 at 8:59 pm

    […] the 1st part I showed you how to make a deflection engine starting from an old tutorial, now it’s time to […]

  11. Chicen

    on July 24, 2008 at 6:09 pm

    The game looks a lot like inkball (http://en.wikipedia.org/wiki/Inkball)

  12. Create a Flash game like Deflection - part 3 : Emanuele Feronato - italian geek and PROgrammer

    on July 25, 2008 at 6:47 pm

    […] tutorial: available parts 1, 2, […]

  13. ithkul

    on August 7, 2008 at 2:48 pm

    always loved your work mr.Feronato. you inspired me lots.

    to “CatFurnace”.. you like box2D? download the source for this and play around with it (you might wanna look at this too mr.Feronato):

    http://www.actionscript.org/resources/articles/742/1/Physics-in-ActionScript-30/Page1.html#postedcomment

  14. Adobe Flash Tutorials Part 2

    on September 9, 2008 at 4:25 am

    […] Deflection game where the objective is to deflect the ball into the goal by creating deflection walls. […]

Thank you for the download!!

I hope you will find it useful and make something interesting out of it

To keep up to date with the blog, why don't you like my Facebook page and follow me on Twitter?

Want to learn more? Don't miss this:

Learn how to make a successful commercial Flash game from a real world example: get the fully commented source code of Globez, a Flash game played millions of times which generated a four figure income. Limited copies available.

Get it now

×