Create a Flash game like The Impossible Line step 2 – the collision sensor

Welcome to the second step of the series. In the first step we created the basics of The Impossible Line game, now it’s time to add the collision sensor.

In the original game, once you start moving your finger, walls and obstacles disappear, forcing you to remember their initial position.

To help you, a red collision sensor in the top right of the screen will get smaller and smaller as you are getting closer and closer to walls, acting something like a parking sensor.

This means every time the player moves the arrow, we have to check for the closest distance between the arrow and the wall, and update collision sensor size accordingly.

The basics of this feature are taken from the post Create a survival horror game in Flash – AS3 version: I just cast a series of rays looking for obstacles, and return the shortest ray.

This is the modified class, new lines are highlighted and fully commented:

And this is the result:

Drag mouse around the screen and see what happens to the top right collision sensor when you get too close to walls. To show you what happens, I am drawing the rays used to scan for walls.

Download the source code.

Next time, power-ups and replay, and we’ll have the final prototype.

  • MC

    cool

  • Thank you, it’s interesting)