Don Havey

Sustainably harvested information

Archive for the 2D tag

Tutorial #6: Colliders  

Colliders previewHere’s another brief tutorial. This one relates to object collisions and velocity transfers. Basically, we’re making simulated billiard balls: objects that bounce off each other and the sides of the applet. Not too much else to introduce, so I’ll just get started…

What it looks like

Here are the files: Collider classes

And here’s the final result: I’m a super collider

Click on the applet to rejuvenate each Collider’s y-velocity and prepare for another round of bouncy goodness. If you find the motion blur distracting, you can always look at this blur-free example.

What you’ll learn

Some of the math you’ll have to decipher yourself, but in general, I’ll touch on each of the following:

  • Preventing circular shapes from overlapping.
  • Constraining points within an area.
  • Transferring velocities upon object collision.
  • And I’ll show you how to do that cheesy motion blur trick… if you don’t already know.

Ready?

Read more…

The article has

no responses yet

Written by Don

April 29th, 2008 at 9:56 am

Inverse-kinematic springy grass  

IK grass previewThis isn’t a formal tutorial… just a source code dump. I made this randomized, springy IK grass in Flash for Curiobot a while ago, but decided that it was too CPU-intensive to risk combining with all of the DOM-scripting on the site. As such, I didn’t bother optimizing it much, so that’s up to you.

The files: IK grass classes

The final result: Springy IK grass

Click on the stage and then move your mouse left and right to simulate a breeze through the grass.

The variables contained in the .fla are pretty well labeled… you shouldn’t have any trouble playing around with them. I’m afraid the thing was built in Flash MX 2004… so it’s AS2.0, not AS3.0. But it wouldn’t be hard to convert… it’s already OOPed. I think I’ll put it into Processing soon. Should run much better.

Enjoy!

The article has

13 responses

Written by Don

April 28th, 2008 at 9:31 am