Carrom: help pls multiple puck movement when hit

Hi all,

First post here and I hope I am clear and someone can help. I’m working on a project that is like a Carrom game or something similar to pool/ billiards.

I’m stuck on making my pucks or balls move once they are hit by a ‘striker’ puck.

So far I have striker that I place on the board, the cue stick hits it and the striker moves in the direction the cue was aiming it. I have 18 colored pucks in he center of the board that are placed there using attributes such as color, xpos and ypos in XML and are held in a public array in the model called _allPucks.

I created a hit test between striker and puck and ran a trace and all seemed well at the time.

Now I am trying to get the hit pucks to move but what I’m seeing is that half the pucks move in any direction hit regardless if they were hit or not and they move in unison with the striker even if I only hit the striker. So if one puck gets hit, 9 of them move as a group in a certain direction and the other 9 just stay in place whether they are hit or not and after the initial striker collision, they seem attached to the striker.

What I want is for each of them to eventually go off in different direction individually when hit by the striker. I think thats the first step before moving on the puck to puck collisions.

I hope that makes sense and bits of code that control movement is below.

I’m thinking I somehow need each x and y position of all 18 pucks but not sure how to go about that without lots of vars to hold them? Ugh this is driving me crazy!

Could someone point me in the right direction please?

n.b this is loosely MVC. Will make it more mvc after i get the details outta the way.


View Class:

private function strikerLive(evt:Event):void
{
	//moves the striker and adds friction		
	_model.strikerX -= _model.vx;  
	_model.strikerY -= _model.vy;  
			
	_model.vx *= _model.friction;  
	_model.vy *= _model.friction; 
			
	for(var i:int = 0; i < _model._allPucks.length; i++) 
	{
		if(_striker.hitTestObject(_model._allPucks*)) 
		{
                        //moves the pucks away from pointer
			_model.vx = Math.cos(_model.ar)*10;  
			_model.vy = Math.sin(_model.ar)*10;  
			_model.addEventListener("UPDATE", pucksLive);
			_model.puckHit = true;		
		}
				
	}//end for
}

private function pucksLive(evt:Event):void
{
	for(var i:int = 0; i < _model._allPucks.length; i++)
	{
              
		_model._allPucks*.x -= _model.vx;  
		_model._allPucks*.y -= _model.vy;  
					
		_model.vx *= _model.friction;  
	        _model.vy *= _model.friction; 
	}
}




Striker Class (another view)

private function startListening():void 
{
_model.addEventListener("UPDATE", update);
_model.addEventListener("STRIKER_SET", readyStriker);
}
		
private function update(evt:Event):void 
{
	x = _model.strikerX;
	y = _model.strikerY;

			
	if(_model.puckHit == true)
	{
				
		for(var i:int = 0; i < _model._allPucks.length; i++)
		{
                        //calculates angle between striker and puck
			dx = _model.strikerX - _model._allPucks*.x;  
			dy = _model.strikerY - _model._allPucks*.y;  
			_model.ar = Math.atan2(dy,dx);  
			a = _model.ar * 180 / Math.PI;  
			rotation = a;
				
		}
	}

}