# AS3 HitTestPoint / Collision Detection / Car Game

**URL:** <https://forum.kirupa.com/t/as3-hittestpoint-collision-detection-car-game/326654>\
**Category:** Uncategorized\
**Created:** [January 3, 2012, 2:51am UTC](https://forum.kirupa.com/t/as3-hittestpoint-collision-detection-car-game/326654 "2012-01-03T02:51:54Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![ChrisW182](https://avatars.discourse-cdn.com/v4/letter/c/58956e/32.png) [@ChrisW182](https://forum.kirupa.com/u/ChrisW182)\
**Post date:** [January 3, 2012, 2:51am UTC](https://forum.kirupa.com/t/as3-hittestpoint-collision-detection-car-game/326654/1 "2012-01-03T02:51:54Z")

</div>

Hi guys and girls,

Never had much luck on Forums in the past but i have been urged to try out this site, so here i am.

My problem is simple (i imagine) i have in the past made a simple car game that collects coins. In the past to stop the car from going off the stage i used a peice of code like…

```auto
                var playerBounds = car_mc.getBounds(stage);
                if (playerBounds.left < 0 || playerBounds.right > stage.stageWidth)
                {
                    if (speed < 0)
                    {
                        car_mc.rotation + 10;
                        speed = speed + speedAcceleration;
                        trace (speed);
                        trace ("speed < 0");
                    }
                    if (speed > 0)
                    {
                        trace ("hellllllo");
                        car_mc.rotation + 10;
                        speed = speedMaxReverse;
                    }                    
                        
                }

```

This would then do the appropiate turns/speed reductions to simulate a bounce off effect.

Now my level is a bit more demanding, made up of several different “islands”, and bridges where the rules are different. See image below:

If the car bounces into any of the walls on the green “islands” i want it to do the similar bouncing off effect, If they hit the edges on the brown “bridges” i want the car to fall off (some animation/tween to simulate falling and then loose a life and start again).

I have tried converting the line of the side of one of the islands to a movieclip, and doing a test against it like so:

```auto
                if (Boundary1.hitTestPoint(car_mc.x, car_mc.y, true))
                {
                trace ("Collision Detected");               
                }     

```

But this does not do anything at all. Any ideas please i am going mad.

Thanks in advance  
Chris
