Actually, the color does matter. Here's how it works.
There is a ballshooter at the top of the screen. It has a round light that shows you the color of the hat you have to aim at.
Each hat has a counter on it, starting with 3. Every time you get a ball into that hat when the ballshooter has the same color light lit, the counter counts down. When it gets down to 1, that hat will disappear.
When all 4 hats are gone, you win the game.
You can shoot all the balls you want to into any hat, but if the hat color doesn't match the ballshooter light, the shots won't count towards winning the game.
The ballshooter will stay in each position for about 30 seconds. During that time you can either place pegs anywhere on the board or remove pegs (by clicking on them). Every time you place a new peg the ballshooter will release a ball.
If you get the pegs lined up just right so the balls are going into the hat of the right color, you can just put additional pegs into the holes on the far side of the board to get the ballshooter to release more balls down the same path.
Some shots are going to be very hard, some are going to be easy. The key is to take advantage of times when you have the ballshooter lined up correctly and release balls quickly (by putting pegs into other parts of the board).