## Posts Tagged ‘as3

13
Feb
09

### Global Game Jam – The Deep – Capture Detection

ii) In ‘The Deep’ game we have a string membrane that can contort into many shapes both concave and convex. I needed to be able to detect if a ‘plankton’ (or many) is within the membrane when the digest mechanism is triggered (the creature’s orbs touching together).

My method was to draw a shape using the membrane as a template. Fill the shape, then test the plankton to see if their coordinates are over the fill colour.

The Deep: Plankton Capture Detection

1) The creature’s orbs touch triggering the digest mechanism.

2) Using the vertices on the rope chain draw a shape.

3) Colour fill the shape.

4) Find the extents of the shape. Calculate the bounding box. Now check to see which plankton are within the bounding box. Take the coordinates of each of these plankton and test whether they have the fill colour at that coordinate. If so, then the plankton must be inside and is therefore digested. Points scored.

Again the source of the game can be found here.

13
Feb
09

### Global Gam Jam – The Deep – How to produce a string in water with AS3

I attended the Global Game Jam 2009 recently – forming the team ‘Fish Don’t Flock’. We produced a game called ‘The Deep’ – in 48 sleepless hours.

In the game you get to control a deep sea bio-luminescent creature that is formed from two orbs and a membrane. The creature eats plankton by enveloping it inside it’s membrane.

There were a couple of innovations we managed fit into the game. The first I will detail here, the other will be in my next post.

(i) We needed to make the membrane behave like a ribbon under water:

I’m a huge fan of Box2D, and have done a few AS3 rope experiments. To get the behaviour I wanted, I figured that I could chain together a series of balls within Box2D, turn off the gravity for the top-down underwater view effect. This way I could detect collisions and if all creatures have mass within the physics engine they would interact correctly with the membrane.

The Deep: Rope membrane

(1) Create a chain out of box2D circles.

(2) Link the chain circles using revolute joints.

(3) Draw membrane/rope by drawing from joint point to joint point and add orb sprite.

(4) Remove rendering of circles.

The source is available for this game here.
(Obviously it was a rush job so expect a lot of code imperfection.)