This Is A Custom Widget

This Sliding Bar can be switched on or off in theme options, and can take any widget you throw at it or even fill it with your custom HTML Code. Its perfect for grabbing the attention of your viewers. Choose between 1, 2, 3 or 4 columns, set the background color, widget divider color, activate transparency, a top border or fully disable it on desktop and mobile.

This Is A Custom Widget

This Sliding Bar can be switched on or off in theme options, and can take any widget you throw at it or even fill it with your custom HTML Code. Its perfect for grabbing the attention of your viewers. Choose between 1, 2, 3 or 4 columns, set the background color, widget divider color, activate transparency, a top border or fully disable it on desktop and mobile.

How to make Angry Birds – part 2

Home/AS3, Collision Detection, Graphics, Making angry birds, Physics, Technical/How to make Angry Birds – part 2

How to make Angry Birds – part 2

Submit to StumbleUpon Share

Hello and welcome back to my blog!

This is the 2nd part of my series on how to make a game like Angry Birds by Rovio - and its been a while coming... You can read the first part here.

The Game

Ok, so here is the game so far; there are three demo levels to show the level progress system and some simple looking characters and block types. Apologies for the programmer art πŸ™‚

Catch up

Ok, so last time I had covered how to draw the background graphics and made a start on how the world is going to be composed in terms of collision.

What I'm going to cover in this article is the physics part; stability and optimisations. The physics engine that I've created for this game is based on the technology I've discussed in my previous articles:

Physics engines for dummies
Collision detection for dummies
Speculative contacts - a continuous collision engine approach


A level is defined as a bunch of instances of static rigid bodies and dynamic rigid bodies plus a visual layer which covers up the statics - I use this other layer because otherwise there would be a slight visible gap betweenΒ adjacentΒ static blocks, which we don't want since the texture is supposed to be continuous.

A level must inherit the base class Code.Level. I've done this so I can predefine certain things about each level - such as the instance names for the hero characters, and the sling-shot which I need to reference in code.

Characters and blocks

Each of the two characters and every block used in the game are designed in the Flash IDE, and each of them references a base class that I've defined in the code. This is so that I can parse the children of a level at runtime and create the appropriate rigid bodies at the correct mapped locations for the physics engine.


There are the following base classes (stone and wood use the same base class):

  • HeroCharacter
  • EnemyCharacter
  • ProxyRectangleIce
  • ProxyRectangle
  • ProxyRectangleStatic
  • ProxyTriangleStaticDown
  • ProxyTriangleStaticUp

These are interpreted at level creation time, using a loop similar to this:

// create physics objects to go with the render objects in level
for ( var i:int = 0; i<level.numChildren; i++ )
	var child:DisplayObject = level.getChildAt( i );
	if ( child is Character )
	else if ( child is ProxyRectangleStatic )
	else if ( child is ProxyRectangle )
	else if ( child is ProxyRectangleIce )
	else if ( child is ProxyTriangleStaticDown )
	else if ( child is ProxyTriangleStaticUp )
	child.cacheAsBitmap = true;

In each part of the if-else ladder I create the appropriate rigid body to match the proxy, and these get added to the physics engine.

Level sequence

Thanks to Flash's neat way of storing class types as variables, I represent the level sequence as a simple array of class types:

private var m_currentLevel:int;
private var m_levelSequence:Array =

Every time a level is completed, I can pick the new one from the array and instantiate it like this:

// create new level
m_level = new m_levelSequence[m_currentLevel];

It then gets passed to the SetupLevel function which handles all the rigid body instantiation that I talked about above.

Physics engine

The physics engine is similar in design to the one I laid out in Physics engines for dummies, except this one is a lot more advanced.

It now has the concepts of angular-velocity, polygon contact set generation, contact group generation, object sleeping, collision callbacks and persistent contacts. All these components were necessary to create the game.

Physics engine - angular velocity

Angular velocity is handled in a very similar way to linear velocity, except its a scalar and not a vector, since we're in 2d and it gets integrated the same way. Where it gets more tricky is in the actual impulse equations.

I'm going to refer the reader to the following set of articles by Chris Hecker which describe the impulse equations for angular and linear velocity rather well:

I do intend to write a more in depth follow up on this subject at some point.

Physics engine - polygon contact set generation

Although, technically when two convex shapes collide there are only two closest points (one on each object) this is not enough for the physics engine to produce a stable simulation with anything more than circles. As soon as you have a rectangle or a polygon you need to have the full contact-set between both objects.

Figure 1

Figure 1 shows the full contact set between two polygons A and B. To generate this we need to start with the feature-pair returned by our collision system (vertex and edge, or edge and vertex).

Figure 2

Figure 2 shows one such possible case: a vertex from B and an edge from A were returned as the closest features. Starting with this information we can then do a local search of the the vertices adjacent to the red point on B (one on either side) to find which edge has a normal that is most opposed to our collision normal (the edge normal).

Figure 3

Figure 3 shows the correct edge and the other edge which was considered from B. Once we have these two edges we have all the information we need to generate the contact set. What we do is to project each vertex from each edge onto the other edge, making sure to clamp the projections so they lie wholly within the bounds of the edge.

Figure 4

Figure 4 shows the red vertices of the edge from A being projected onto the green edge of B. The first vertex becomes projected point b0 and the second becomes b1.

Figure 5

In Figure 5 we can see the same process repeated for the other edge; note how both projections of the green vertices would lie outside the bounds of the red edge. Because this would lead to an invalid contact we must clamp these at the bounds of the red edge. Vertices a0 and a1 result and this is the completed contact set!

Figure 6

Here is the code for projecting a point onto an edge and clamping against the edge bounds:

public function ProjectPointOntoEdge(p:Vector2, e0:Vector2, e1:Vector2):Vector2
	// vector from edge to point
	var v:Vector2 = p.Sub(e0);
	// edge vector
	var e:Vector2 = e1.Sub(e0);
	// time along edge
	var t:Number = e.Dot(v) / e.m_LenSqr;
	// clamp to edge bounds
	t = Scalar.Clamp(t, 0, 1);
	// form point and return
	return e0.Add( e.MulScalar(t) );

Contact group generation and object sleeping

The game logic for angry birds relies on being able to tell when all the movement in the level is stopped, because otherwise you would never know when an individual try is over since objects may yet fall down crushing an enemy character.

In order to facilitate this and also to act as an optimisation an object sleeping system is required. What this does is to deactivate or 'sleep' any rigid bodies which have become sufficiently still for a set period of time, thereby saving CPU cycles and also giving us an indication about the state of the game.

For this to be possible we first have to be able to generate contact groups. A contact group is a collection of rigid bodies which are all touching each other.

Figure 7

Figure 7 shows two contact groups.

In order to generate these, the simplest way is to use recursion. Each object must maintain a list of every object that's touching it. An outer loop over all rigid bodies generates individual contact group containers and then recurses within adding objects which are touching to the given contact group.

Static objects are not followed because we don't want to include them in any contact group - they would link the entire level together into one giant, inefficient contact group!

The code looks like this:

private function BuildContactGroup( r:RigidBody, cg:ContactGroup, dt:Number ):void
	if ( !r.m_visited && !r.m_Static )
		r.m_visited = true;
		r.m_contactGroup = cg;
		// add the object
		cg.Add( r );
		for ( var i:int = 0; i<r.m_rbsTouching.m_Num; i++ )
			BuildContactGroup( r.m_rbsTouching.Get(i), cg, dt );
/// Go through and build all the contact groups in the world
internal function BuildAllContactGroups( dt:Number, rigidBodies:ReferenceArray ):void
	Reset( );
	// start with a new group
	var cg:ContactGroup=null;
	for ( var i:int=0; i<rigidBodies.m_Num; i++ )
		var r:RigidBody = rigidBodies.Get(i);
		// if this object isn't static and hasn't yet been visited...
		if ( !r.m_Static && r.m_visited==false )
			if ( cg==null || cg.m_NumRigidBodies>0)
				// get new contact group
				cg = GetNewContactGroup( );
			// go an recursivly add objects to this new contact group
			BuildContactGroup(r, cg, dt);
	// sleep check the contact groups
	SleepCheck( );

Its actually quite simple and works rather well, taking minimal CPU time.

To enable the sleeping of rigid bodies, each rigid body maintains a counter which counts the number of seconds that rigid body has had angular and linear velocities below some threshold values. Then, once all the rigid bodies in a contact group have counter values over a threshold (1 second in this game's case), the entire contact group is sent to sleep. Likewise, if any rigid body in a sleeping contact group wakes up, the entire contact group must wake up with it.

Physics engine - collision callbacks

For some objects the game needs to know about any collisions that happen between those objects and the hero character, or the world. To facilitate this, each rigid body has a collision callback delegate which can be set at runtime. Then, the physics engine will call this delegate whenever it detects a collision, passing the callback information about the collision including which objects were hit and what the relative normal velocities were at the time of collision. This information allows to game logic to kill enemies and smash blocks of ice.

Physics engine - persistent contacts

This physics engine feature is absolutely essential to the stability of the physics; without it, the game would not be possible with as much creative freedom in level design.

So, what are persistent contacts?

Regular contacts are the things which stop two rigid bodies from falling through each other - they are generated by the collision detection system and used by the physics solver but they are temporary and exist for the current frame only.

The impulses generated by the physics solver converge the entire simulation towards stability, but there are not enough CPU cycles for it to be resolved completely in one frame... So rather than throw away all of last frames impulses we would like to be able to remember them and then apply them next frame in order to 'warm start' the engine. This leads to massive stability improvements.

Persistent contacts are a way of caching the impulses between frames by identifying contacts which are logically the same across a series of frames. By logically I mean rather than using something crude like the position of two contacts, we want to use something which identifies contacts uniquely. To do this we can use feature pair indicies; so for example, the index of the vertex from object A combined with the index of the edge from object B. These will be combined together into one uint hash value which can be looked up and compared across frames. When the hash tags match, we have a cache hit and can copy the impulses across.

The code I use for caching the impulses looks like this:

public class TouchingContact
	public var m_featurePairKey:uint;
	public var m_accumulatedNormalImpulse:Number;
	public var m_accumulatedTangentImpulse:Number;
	public function TouchingContact( featurePairKey:int )
		m_featurePairKey = featurePairKey;
		m_accumulatedNormalImpulse = 0;
		m_accumulatedTangentImpulse = 0;
	/// Something to identify this contact uniquely
	static public function GenerateFeaturePairKey( featureToUse:FeaturePair, supportIndex:int ):uint
		return featureToUse.m_fp|( featureToUse.m_face<<2 )|( supportIndex<<16 );

When two objects touch for the first time, a persistent contact entry is generated for the collision and stored on the lower indexed object, so that I avoid duplicating data. When objects stop touching, these contact entries are deleted again. During the time when they are touching, I cache up to 4 feature pairs for later lookup - the reason I chose 4 and not 2 (which would be the logical choice) is that I noticed there was a fair amount of flip-flop over the course of a few frames in certain contact configurations; one frame two contacts would be generated from a certain feature pair, the next frame another two contacts from a different feature pair and then repeat forever. Rather than throw away and regenerating, storing 4 allowed me to catch this case and achieve a 100% cache hit rate for stable contact configurations.


After I had implemented all these features and gotten the engine stable enough to be able to run angry birds, I noticed that it was in fact, far too slow to actually use. This made me sad, but a little digging into action-script optimisation techniques netted me the answer.


In action-script, every complex type is passed by reference and there are no complex types which can be put on the stack, unlike c# or c++. This is particularly irksome if you have something like a Vector2 class for doing all your geometric calculations, because it means every time you do a new(), an allocation is made on the heap, which of course means you risk the slowness of the garbage collector when doing temporary calculations.

This is an absolute killer in terms of performance - I found I was doing something on the order of 7k-12k such temporary allocations every single frame!

The solution - pools

Of course, the internet informed me that the accepted solution here is to employ an object pool for complex types - pre-allocated up-front with a known fixed capacity. Allocations can then be made and freed using the pool, thereby avoiding the garbage collector.

I couldn't find an implementation that did exactly what I wanted, so I wrote my own:

package Code.System
	import Code.Assert;
	import Code.System.UnexpectedCaseException;
	public class Pool
		private var m_counter:int;
		private var m_maxObjects:int;
		private var m_pool:Array;
		private var m_type:Class;
		/// <summary>
		/// </summary>	
		public function Pool( maxObjects:int, type:Class )
			m_pool = new Array( maxObjects );
			// construct all objects
			for (var i:int=0; i<maxObjects; i++)
				m_pool[i] = new type();
		/// <summary>
		/// </summary>	
		public function Allocate( ...args ):*
			Assert( m_counter<m_maxObjects, "Pool.GetObject(): pool out of space!" );
			var obj:* = m_pool[m_counter++];
			if ( args.length>0 )
				if ( args.length==1 )
					obj.Initialise( args[0] );
				else if ( args.length==2 )
					obj.Initialise( args[0], args[1] );
				else if ( args.length==3 )
					obj.Initialise( args[0], args[1], args[2] );
				else if ( args.length==4 )
					obj.Initialise( args[0], args[1], args[2], args[3] );
				else if ( args.length==5 )
					obj.Initialise( args[0], args[1], args[2], args[3], args[4] );
				else if ( args.length==6 )
					obj.Initialise( args[0], args[1], args[2], args[3], args[4], args[5] );
				else if ( args.length==7 )
					obj.Initialise( args[0], args[1], args[2], args[3], args[4], args[5], args[6] );
					throw new UnexpectedCaseException;
			return obj;
		/// <summary>
		/// </summary>	
		public function Deallocate( obj:* ):void
			Assert( typeof( obj )==typeof( m_type ), "Pool.Deallocate(): object doesn't belong to this pool!" );
			Assert( m_counter>0, "Pool.Deallocate(): too many deallocations!");
			m_pool[--m_counter] = obj;
		/// <summary>
		/// </summary>	
		public function get m_Num():int
			return m_counter;
		/// <summary>
		/// </summary>	
		public function Get(i:int):*
			Assert(i<m_counter, "Pool.Get(): index out of range!");
			return m_pool[i];
		/// <summary>
		/// </summary>	
		public function Clear():void

This one allows you to construct a pool with runtime type checking and also allows you to call an Initialise() function on the object being allocated. I couldn't find a way of calling the object's constructor in AS3, which would have been the ideal case - something like placement new in c++ would be nice. Equally, I couldn't find a way of passing all the parameters directly to the function without manually indexing them or calling apply() which I've read is very slow. However, it works well in practice.

For the temporary calculations involving Vector2's I used a large pool of Vector2s which only exists for one frame. The only caveat is that you need to be very careful not to persist a reference to one of these across frames because it will be overwritten. I really wish AS3 had struct like c# does to avoid having to do this.

I used the following profiler (which I highly recommend) to identify the slow parts of the engine:

Once I had identified all the slow parts and made pools for all the temporary objects I was still a little discouraged because it wasn't running quite as fast as I'd have liked on my old desktop that I have here. I worked hard at it but eventually reached the point of diminishing returns and I was in danger of making the source code too hard to follow.

In desperation I fired up the real angry birds in my chrome browser to see how quickly that would run on my machine. I was shocked and relieved to discover that it actually ran a lot slower than my implementation did! Happy days.

Particles and blinking

Some little items of polish that I added to the game were a simple particle system which used Sprites defined in the Flash IDE as the particles and a simple blink controller that used named instances inside each character for the open eyes and the closed eyes and then animated them in code depending on a random waiting period to judge when to toggle the visibility of each.

Figure 8

Figure 8 shows an example character with blinked and open eyes and the corresponding eye shapes for each.


Of course the game contains many more little things which I don't possibly have time to write about now, but if there is enough interest I can write another article of course! In this article I have covered some of the things which are necessary to turn theory into practice when it comes to talking about physics engines in games.

If you would like to do so, please purchase the source code and assets which go with this article; its very close to being a completed game which can be easily used as a template for your own 2d physics game, complete with editor (in the form of flash) which is delightfully easy to use.

This one is a little more expensive than my regular example code, but take into consideration that it took me two solid weeks of work which if I were contracted would be significantly more than this for one days work and also that what you are getting represents 10 years of industry experience and knowledge - if you think of it like that it really is a bargain... Remeber, Roivo spent $120k developing the original angry birds!

The only thing I ask is that no one just releases this as a game as it stands - please use it as a template for your own games! πŸ™‚ As ever, the licence allows you to use all the code and assets for commercial purposes or otherwise as long as you don't just release it as it stands and that you don't simply give the entire thing to anyone else.

Note: requires Flash CS4+ and builds with Amethyst or FlashDevelop.


I hope you make some exciting games with this and I look forward to playing them!

Until next time, have fun!

Cheers, Paul.

p.s. in the game if you get bored of playing by the rules, you can simply pick up any object with the mouse and smash it around for fun!

Submit to StumbleUpon Share

About the Author:

A games industry veteran of ten years, seven of which spent at Sony Computer Entertainment Europe, he has had key technical roles on triple-A titles like the Bafta Award Winning Little Big Planet (PSP), 24: The Game (PS2), special effects work on Heavenly Sword (PS3), some in-show graphics on the BBC’s version of Robot Wars, the TV show, as well as a few more obscure projects. Β  Now joint CEO of Wildbunny, he is able to give himself hiccups simply by coughing. Β  1NobNQ88UoYePFi5QbibuRJP3TtLhh65Jp


  1. Manuel June 7, 2011 at 6:53 pm - Reply

    Hey Paul, thank you for using my profiler!
    Great and detailed writeup indeed, i mean.. WOW! That’s one hell of an howto!
    Big up for you and thanks for sharing!

    • Paul Firth June 7, 2011 at 6:59 pm - Reply

      Hey no problem – it was excellent πŸ™‚ Thanks for providing the profiler!

  2. […] /blog/2011/06/07/how-to-make-angry-birds-part-2/ […]

  3. Inzuki June 8, 2011 at 3:11 am - Reply

    This is a very nice tutorial, but there’s a problem where you can launch the bird off the slingshot and grab it, then just go around the level whilst holding the bird and destroy it. Otherwise, very nice!

    • Paul Firth June 8, 2011 at 10:12 am - Reply

      Hi, yes that was intentional πŸ™‚ Its so you guys can play with the physics engine!

  4. […] more: How to make Angry Birds – part 2 | Paul's blog@Wildbunny VN:F [1.9.8_1114]please wait…Rating: 0.0/5 (0 votes cast)Loading…LoadVideoBar("How to make […]

  5. Pat June 8, 2011 at 5:29 am - Reply

    Wow. Great work Paul. You have so much time.

    The gameplay is very smooth and I like how you can grab an object and smash those little red thingy.

    • Paul Firth June 8, 2011 at 10:13 am - Reply

      Thanks Pat πŸ™‚

  6. Novo June 8, 2011 at 8:35 pm - Reply

    Why not use some switches instead of those if/else ladders?

    • Paul Firth June 8, 2011 at 8:48 pm - Reply

      Depends which ones you mean – I have to use if-else ladders for the rigid body construction because you can’t switch using the ‘is’ comparator.

      On the other hand, I can switch inside the Pool class, but chose not to – not for any good reason πŸ™‚ I don’t know how well if-else ladders perform against switches in AS3… πŸ™‚

      • Arby March 8, 2012 at 3:50 am - Reply

        they perform identically

  7. […] Delicious popular This entry was posted in yahoo rss and tagged yahoo. Bookmark the permalink. ← How Cloud […]

  8. Virtue June 9, 2011 at 8:25 pm - Reply

    What an irony.
    In C you needed pools because there was no garbage collector.
    Now in Flash you need pools because there are no stack objects.
    I still like the best how you can deal with this in C++ : scoped objects and shared pointers = no garbage collector performance spikes + safety.

    Never really tried to make a physics engine myself, thanks for sharing.

    • Paul Firth June 9, 2011 at 9:06 pm - Reply

      I know, its a pretty poor choice on the original developers of the language…

      C++ is the most flexible its true, but c# does a pretty good job for a garbage collected language – at least you have the choice of where your objects get put in memory πŸ™‚

  9. Nick Cowen (Nickenstein) June 10, 2011 at 2:57 am - Reply

    Great stuff, Paul! Keep ’em coming! πŸ˜€

  10. […] tenemos la segunda parte (y parece que es la ΓΊltima) de este espectacular tutorial de Paul Firth para crear un juego igual […]

  11. Dave June 12, 2011 at 1:16 am - Reply

    Great tutorial. Im still looking for money to buy this precious bunch. Please dont change the price wait for me to buy it. πŸ™‚ thanks!

    • Paul Firth June 12, 2011 at 10:57 am - Reply

      Hi Dave, don’t forget if you subscribe you get both articles for the price of one! πŸ™‚

      • Dave June 15, 2011 at 2:44 pm - Reply

        how much would that be? im planning to enhance this game for a good concept. πŸ˜€

        • Paul Firth June 15, 2011 at 2:46 pm - Reply

          Subscription is the same price as the pt2 code, so you get all the source code on this site for the price of just angry birds pt2! πŸ™‚

  12. Matt June 14, 2011 at 9:27 pm - Reply

    Excellent work! I can’t wait to see some more on the physics engine. I am currently working on my own set of articles for 2D physics engines. Maybe I should charge a small fee to get the source? If I use some of your techniques in my engine can I still charge a fee for my code? I am a paid subscriber.

    • Paul Firth June 14, 2011 at 10:36 pm - Reply

      Hi mat, yes you can charge for your source as long as its not just a straight copy of mine πŸ™‚ Don’t expect to make much money though; I must have only made $500 in 4 months! πŸ™‚

      • Matt June 15, 2011 at 2:30 am - Reply

        Ok, just making sure. Any compensation is better then none. My code will be C# and certainly not an exact copy. Probably not even close except in a few key areas.

        • Paul Firth June 15, 2011 at 2:45 pm - Reply

          Cool – I look forward to reading your articles!

  13. Dharshan June 16, 2011 at 4:37 am - Reply


    I bought this source file, and I want to know how to compile this using Flash IDE or Flashdevelop.. can you help with this please ??


    • Dharshan June 16, 2011 at 4:44 am - Reply

      I got it working,
      Thanks πŸ™‚

      I enjoyed this article, its a great post !

      Keep up the good work.
      Dharshan, Ezzal Games

    • Paul Firth June 16, 2011 at 9:28 am - Reply

      Hi Dharshan,

      Personally, I use Amethyst, but Flashdevelop should be doable – I presume you need to import all the Code files into FD and then reference the exported .swc in order to access the assets πŸ™‚

      Cheers, Paul.

      • Dharshan June 16, 2011 at 9:48 am - Reply

        Yep, It’s working(Compiling) now. Thanks.

  14. WeiHung July 3, 2011 at 9:22 am - Reply

    Hi Paul ,

    I downloaded your code and installed CS4 and Amethyst.
    For CS4(I clicked the Assets.fla in the Assets folder), i can see the Assets (Scene1).
    For Amethyst(I clicked the AndryBirds.sln in the AndryBirds folder), i just click the “Run” green triangle button. And error message is as shown in below :
    “Cannot launch build: The compiler ‘\bin\mxmlc.exe’ cannot be found. Check the SDK path under Tools|Options|Projects|Amethyst.”
    Sorry , i ain a freshman to this area, Could you tell me what

    • Paul Firth July 3, 2011 at 2:22 pm - Reply

      Hi there,

      Sounds like you need to point amethyst at your flex 3 compiler – if you’ve used flashdevelop it will be a familiar process, if not you need to download the flex 3 compiler from adobe πŸ™‚

      Cheers, Paul.

  15. […] How to make Angry Birds – part 2 […]

  16. WeiHung July 12, 2011 at 5:22 pm - Reply

    Hi Paul,
    I download the Flex3 builder and change Amythest Default SDK path to “C:\Program Files\Adobe\Flex Builder 3\sdks\3.2.0” and Run.
    It’s still with errors Undefined_AS3_.vec:Vector on error list and point it corresponing to these positions(package Code.System, package Code.Geometry, etc..)

  17. Great work July 14, 2011 at 1:03 pm - Reply

    Fantastic tutorial, and a great schematic. I was wondering – once this is completed, how does one port it over to a mobile device, a la iPhone or iPad or Android?

    • Paul Firth July 14, 2011 at 1:06 pm - Reply

      Thanks! πŸ™‚

      Android actually supports flash, so that would be particularly easy πŸ™‚

      Cheers, Paul.

  18. Angry Birds Flash August 13, 2011 at 5:16 am - Reply

    I would like to thanks for posting valuable blog and its very useful for angry birds flash fans.
    Angry Birds Flash

  19. Darwin August 13, 2011 at 10:12 pm - Reply

    Hi PAUL,

    Is angry birds build on Box2D physics engine, which is open source? Is it different from yours?

    • Paul Firth August 14, 2011 at 5:13 pm - Reply

      Hi Darwin,

      Angry birds uses Box2d, whereas the physics engine I describe in the article has been custom designed from scratch to give other programmers an idea of what it takes to write a custom solution πŸ™‚

      Cheers, Paul.

  20. Angry Birds Flash September 1, 2011 at 2:19 pm - Reply

    Thanks for post informative article for angry birds flash game software. It shows online game for children on PC or Iphone. I also suggest like that online game website: Angry Birds Flash

  21. Mathias September 23, 2011 at 1:31 pm - Reply


    sorry for my english… i’am french…
    I want too “build” your game… but i’am on Mac… i only have Flash cs5…
    Is there one solution to build this game on mac os x?

    thanks !

    • Paul Firth September 23, 2011 at 4:44 pm - Reply

      Hi Mathias,

      To tell you the truth I’m not totally sure about that – the game is designed to be built through adobe’s freely available compiler and I can’t see a mac version of that…

      Is it possible for you to dual-boat into windows to actually edit/compile and export from CS5 on the mac? πŸ™‚

      Cheers, Paul.

  22. ShriekingViolet October 1, 2011 at 7:35 pm - Reply

    This is very cool. My autistic son has big aspirations for a game development career some day. I will get him to take a look at this.

    • Paul Firth October 1, 2011 at 7:45 pm - Reply

      Quite a lot of programmers in the games industry demonstrate mild autistic symptoms, actually – the two things seems to go together quite well. I wish you both all the best, glad you enjoyed the article πŸ™‚

  23. Rodri October 7, 2011 at 5:26 am - Reply

    Paul, sorry but, may i have the source file? it gets me dificult to make it, i’m tired now of making it, may you? please? its ok if you dont.
    Keep it up Paul!
    Email it to me here:

  24. Rodri October 7, 2011 at 6:21 am - Reply

    oh, i think you cant give the source to me, well since im 11 years old i can’t have a paypal or bank accounts. thanks thought Paul, i just doing to do each step carefully…

  25. Ramon Marcial Dy. Canunayon October 18, 2011 at 10:09 am - Reply

    angry birds is a special game girls & boys want to play angry birds & i like angry birds to

  26. Ramon Marcial Dy. Canunayon October 18, 2011 at 10:12 am - Reply

    al ways play angry birds

  27. Ramon Marcial Dy. Canunayon October 18, 2011 at 10:13 am - Reply

    ahhh im so tired

  28. Ramon Marcial Dy. Canunayon October 18, 2011 at 10:14 am - Reply

    hey red bird & green bird

  29. Trevor Calabro October 24, 2011 at 5:26 pm - Reply

    Hello Paul,
    I am unable to see the visual character modifications I made in the .fla file when I debug in Amethyst.

    Here is my process:
    1. Open .fla file
    2. Make visual adjustments to Movie Clip characters (I am very familiar with Flash so I know I didn’t break any thing in this step)
    3. Save .fla file and publish (making sure that the .swc file is also being published)
    4. Open AngryBirds.amproj file in VS Amethyst
    5. Under the Property Pages I set the SDK path and select a flash player under Launch to the desired locations locally
    6. Debug without error

    After all of this a file launches that works perfectly but does not reflect the visual character modifications I made to the .fla file.

    What am I missing?
    Any advice?

    • Paul Firth October 24, 2011 at 6:38 pm - Reply

      Hi Trevor,

      The only step you’re missing is to ‘touch’ one of the files in VS Amethyst to force it to rebuild the project – for some reason it can’t detect changes in external files when running as it would do with regular source code…

      After that you should have no problems πŸ™‚

      Cheers, Paul.

  30. Trevor Calabro October 24, 2011 at 7:03 pm - Reply

    I keep getting Errors similar to this: Definition __AS3__.vec:Vector could not be found.

    File –

    • Paul Firth October 24, 2011 at 7:05 pm - Reply

      Hmmm, are you sure you’ve set the class-paths to the correct location?

      edit: sorry, I mean SDK path πŸ™‚

  31. Trevor Calabro October 26, 2011 at 1:06 pm - Reply

    It was an SDK issue. I had to reinstall the SDK files to make it work. Thanks for everything. Great tut.

    • Paul Firth October 27, 2011 at 10:17 am - Reply

      Glad to know you got it working in the end πŸ™‚

  32. Game TESTER October 28, 2011 at 9:02 am - Reply

    Ahhhh, Great Template…

    However did u notice, after slinging Your Character, You can then Drag thus shot character All over the screen And Destroy Objects.

    You might want to disable Drag / Click After Object is shot.


    Other than that fantastic!!!.

    If You Amend this, I am VERY interested in Purchasing the Customizable Flash Game Template for my own use.

    Also is it Compatible with Flash MX ?


    • Paul Firth October 28, 2011 at 10:26 am - Reply

      Hi there,

      Yes, I left this in on purpose to allow the user to experiment with the physics πŸ™‚

      I’m not sure about compatibility with Flash MX…

      Cheers, Paul.

  33. harold khan November 27, 2011 at 11:21 pm - Reply

    Hi Paul,

    is there anyway to stop dragging objects after the bird has been slung? I have also posted the game on my website wall.


    • Paul Firth November 28, 2011 at 7:10 pm - Reply

      Sure, in GameLogic.OnMouseDown(), insert the following code after the PickRigidBody(…) line:

      if ( m_dragObj!=m_currentBird )
      m_dragObj = null;


      Cheers, Paul.

    • Paul Firth November 28, 2011 at 7:16 pm - Reply

      Loving your version of the game, btw – graphics look really nice πŸ™‚

  34. harold khan November 28, 2011 at 9:36 pm - Reply

    Thanks! I’m currently putting up the score/High score logic and hoping to finish the game by Wednesday

  35. harold khan November 29, 2011 at 7:27 am - Reply

    I noticed that your solution will only work if it’s not m_currentBird, therefore while the engine is running m_currentBird will still be draggable and I was trying to insert it in the code that It would check if the FireBird() has been invoked, then call m_dragObj = null on m_currentBird. When everything is still we call m_dragObj = true. I haven’t dived too deep yet into the code and will find a place to insert my theory. My game needs more work but it’s getting there πŸ˜€

    • Paul Firth November 29, 2011 at 7:23 pm - Reply

      Ahhh, I see what you’re after – in that case replace my earlier solution with this one:

      if ( m_dragObj!=m_currentBird || m_watchForTryOver )
      m_dragObj = null;

      That should make sure the bird is only manipulatable when firing and not afterwards πŸ™‚

      Cheers, Paul.

  36. Don November 29, 2011 at 7:29 pm - Reply

    Hi Paul,

    Quick question on the SWC creation. I’m working in Flash CS5 in Windows 7 when I publish the SWC it is about twice the size of the one you provided. Flash originally was throwing “conflicted” errors. I seem to have that resolved however now after I “touch” the code in VStudio and once the build starts it throws again more errors. Such as:

    Can not resolve a multiname reference unambiuously. Level (…\…\Assets.swc(Level).

    Any advice you can provide would be a huge help.

    Thank you,

    • Paul Firth November 29, 2011 at 7:35 pm - Reply

      Hi Don,

      Thats a bit odd… How did you resolve the original errors you were getting?

      Does the .swc export from flash with no errors now?

      Have you set the class-paths up in the flash ide?

      Cheers, Paul.

      • Don November 29, 2011 at 7:50 pm - Reply

        The first error resolved itself just on the selection of the components that you have linkages setup for prior to convert to symbol.

        I did not setup the class paths however in the Flash IDE. Thank you for you incredibly prompt reply.

        Take care,

        • Paul Firth November 29, 2011 at 8:09 pm - Reply

          No problem, glad to help…

          Is everything working now? πŸ™‚

          • Don November 29, 2011 at 8:24 pm

            Not yet I have to go take care of my daughter and will return to this late tonight.

            Thanks again,

  37. harold khan November 29, 2011 at 8:26 pm - Reply

    Hi Paul,

    Thanks for the last part, saved me a few hours of work, much simpler than what I had came up with.

  38. harold khan December 4, 2011 at 2:47 am - Reply

    Hi Paul,

    there’s a small bug with your last solution in which when you click on any object during the game it will not drag but will sporadically move the objects (like it’s exploding). I just wanted to share my solution: I removed the mouse down event listener from Gamelogic() and moved it under BeginTry():

    if ( m_currentBirdIndex >= 1 ) {
    m_parent.stage.addEventListener( MouseEvent.MOUSE_DOWN, OnMouseDown );

    then forcefully removed it again under “if (m_watchForElasticDetach)” with m_parent.stage.removeEventListener( MouseEvent.MOUSE_DOWN, OnMouseDown );

    Hope this can help others. You can also check out the finished game here


    • Paul Firth December 4, 2011 at 6:44 pm - Reply

      Hi Harold,

      Thanks for the correction πŸ™‚

      Your version is looking lovely, great work!

      Cheers, Paul.

    • Alexis March 5, 2012 at 7:10 pm - Reply

      Nice work! But how did you make that ‘Sound button’ be static/frozen on the same place, while whole Level is moving? I can’t figure it out, tried different approach, layers, etc.. but no luck. Any tips? Would be great to know, thanks!

      • Paul Firth March 5, 2012 at 7:18 pm - Reply

        Hi Alexis,

        IIRC they’re added to the stage instead of the level, so they stay in the same place as the camera moves πŸ™‚

        Cheers, Paul.

        • Alexis March 5, 2012 at 10:11 pm - Reply

          Ok,.. does IIRC stands for something? Is it a library or?

          • Paul Firth March 5, 2012 at 10:57 pm

            If I Remember Correctly πŸ™‚

          • Alexis March 5, 2012 at 11:12 pm

            Ok, got it, thanks! πŸ™‚

  39. Don December 15, 2011 at 9:50 pm - Reply

    Hey Paul,

    Everything you provided before corrected my problems. I do have another question concerning what happens when I enlarge the size of the game. When I expand it to play lets say full screen or with a height of “500” it seems to lock up when the user picks up objects and smashes them around or pulls back on the slingshot I’ve been trying to rectify my problem but just can not finding a solution any insights would be a greatly appreciated.

    By the way I’m having a blast with this. Thanks for all your hard work.

    • Paul Firth December 16, 2011 at 11:31 am - Reply

      Hi Don,

      That sounds like a strange problem – there is a screen dimension constant inside the Constants class which would need to be changed into a var and updated whenever the screen-sized changed to be fully correct, but I wouldn’t expect it to lock up without that…

      Glad you enjoyed the article! πŸ™‚

      Cheers, Paul.

  40. Kurt Stevenson January 4, 2012 at 12:35 am - Reply

    Just found your blog! I’ve created a new character set for an animated book and other stuff and wanted to create a game like angry birds that uses my characters and scenes. Please contact me so we can talk about possibly using your code to do it. I need it to work on iphone, ipad, android primarily.

    • Paul Firth January 4, 2012 at 10:49 am - Reply

      Hi Kurt,

      If you know how to use Flash it should be pretty simple – you just need to replace my artwork and then re-export the .swc and rebuild the game πŸ™‚

      Cheers, Paul.

  41. […] Members ← Collision detection for dummies How to make Angry Birds – part 2 → […]

  42. Android by movo - Pearltrees January 11, 2012 at 6:55 am - Reply

    […] How to make Angry Birds – part 2 | Paul's blog@Wildbunny […]

  43. […] requires Flash CS4+ and builds with Amethyst or FlashDevelop.?Source?wildbunny? ???? QQ?? ???? ??? […]

  44. Alexis March 17, 2012 at 9:43 pm - Reply

    Hi Paul,
    working with your scripts for some time now – amazing work men!
    Question: is it possible to make dynamic triangles as well (may be even octagons)? Seems like it narrowed to 2-3 files where it has to be specified or is it more complex task? Thanks for any tips on that!

  45. Angry Birds flash March 18, 2012 at 12:47 am - Reply

    Very good thanks

    Angry birds Like

  46. adam bacon April 29, 2012 at 8:58 am - Reply

    I would like to make an angry bird game please

  47. Jose May 25, 2012 at 5:28 pm - Reply

    Hello Paul,
    I bought the code source of this game and I have some problems trying to implement the zoom camera to view the scenary completely. Please could you help me giving some ideas how to implement that?
    Nice work!

    • Paul Firth May 27, 2012 at 11:24 am - Reply

      Hi Jose,

      Sorry for the late reply, I’ve been away from the computer for a few days πŸ™‚

      Zoom camera is something that I originally was going to implement, but I discovered that it was too slow to use because it caused all the flash graphics to redraw themselves completely – they are all usually cached to bitmap.

      If you look in Code/ you’ll see a member called m_scale – if you set the x and y components of this, the scene will zoom in/out. The default is 1.0 which is no scale, and 0.5 would be zoomed out by half.

      Hope that helps!

      Cheers, Paul.

      • Jose June 7, 2012 at 10:55 pm - Reply

        Thank you Master! It was very helpful =)

  48. codeBeast July 20, 2012 at 12:44 pm - Reply

    Hi. I have downloaded the game from Wild Bunny. I just took a screen capture of the game on Mr Khan’s site and there is a massive bug. One of the blocks should be falling and it’s supended in thin air.
    I can’t attach the capture here but if you mail me I can send it.

    • Paul Firth July 20, 2012 at 12:49 pm - Reply

      Hi Gerry,

      It is possible for this to occur in quite rare circumstances – what happens is the physics world sends the block to sleep and it doesn’t get correctly re-awoken when blocks beneath it fall away.

      I’ve only seen this once or twice making it rather hard to debug πŸ™‚

      Cheers, Paul.

  49. codeBeast July 20, 2012 at 12:52 pm - Reply

    Flash IDE: How do I open this project – I can’t see a .fla
    Flash develop: Which file do I use to run project. I tried AngryBird file but it just starts up my flash pro IDE and then says no document open.

    BTW your captcha security siftware is not good. I have tried 5 times already to send this mail. I will keep trying.

    • Paul Firth July 20, 2012 at 12:57 pm - Reply


      This particular project was built with Amethyst – I never made a FD project file for it, sorry about that. However, its very easy to make one yourself, just point FD at the directory above the ‘Code’ directory and make sure assets.swc is linked in as a library reference.

      What problems are you having with captcha?

      Cheers, Paul.

Leave A Comment