Bounce effect using hitTestPoint

im building a flash car game where if u hit the sides of the buildings you bounce off
my problem is that sometimes you get stuck in the walls and it doesnt bounce at all

heres my bounce code


public function moveCar(timeDiff:Number) {

			
			// get current position
			var carPos:Point = new Point(gamesprite.car.x, gamesprite.car.y);
			
			// calculate change
			var carAngle:Number = gamesprite.car.rotation;
			var carAngleRadians:Number = (carAngle/360)*(2.0*Math.PI);
			var carMove:Number = speed*timeDiff;
			var dx:Number = Math.cos(carAngleRadians)*carMove;
			var dy:Number = Math.sin(carAngleRadians)*carMove;
						
			// see if car is NOT on the road
			if (!gamesprite.road.hitTestPoint(carPos.x+dx+gamesprite.x, carPos.y+dy+gamesprite.y, true)) {
					gamesprite.car.y = gamesprite.side.y;
					gamesprite.car.x = gamesprite.side.x;
					
		
				// see if car is on the side
				//bounce off
				if (gamesprite.side.hitTestPoint(gamesprite.car.x, gamesprite.car.y, true)) {
					gamesprite.y =  (Math.sin(gamesprite.car.rotation * 0.018) * speed) * 5 / -1;
					gamesprite.x = speed * Math.cos(gamesprite.car.rotation * 0.018) * 4;
					speed = 0 - speed * bounce;
					
				}
			}
			
			// set new position of car
			gamesprite.car.x = carPos.x+dx;
			gamesprite.car.y = carPos.y+dy;
		}


heres a copy of the game
here

can someone help me out plz

thanks

you may check Box2dflash library for that sort of things.

Cool game, its like a cartoonish version of GTA2, keep going :slight_smile:

thanks, i cant figure this box thing out. its really annoying me

thanks for the response

bump