I've been learning flash over the last couple of weeks (using AS3) and have tried to write a game in it. However I've started to stumble on a problem I'm finding really confusing now. I've been making a bubble game where you shoot bubbles out and other bubbles and when you get a group of 3 or more bubbles, they explode (not a great explanation I know but the link to the swf should give you an idea). Right now it's at the start of development, you can shoot bubbles upwards, but none will explode and there is only one bubble type. However I'm trying to get the physics right and the collisions are confusing me. Bubbles are colliding into each other in a funny way and I can't figure out exactly how would be a good way of doing it.
Anyways heres a link to the swf:
And here's a link to the fla file
I know I've done it a bit stupidly without using classes properly and having functions each on different layers, I think I just find it less confusing this way whilst im developing stuff...
Anyway I believe this to be where I've got big problems (The FLA file has all this code in and it's probably easier to understand looking at that than this)..
Many thanks in advance for any ideas people might have, I figure it can't be too hard as there's so many of these games around on the web...
function doBallMovement() /* When a ball is shot, this function is called */
// Get what current array tile we're in - roughly
var xPos = Math.round(((futureX-gridStartX)/squareWidth));
var yPos = Math.round((futureY-accumulatedMovement-gridStartY-(squareHeight/2))/squareHeight);
var yPosTip = Math.round((ballToFly.y-accumulatedMovement-gridStartY-(squareHeight/2))/squareHeight);
if(((yPos>0)&&(yPos<gridHeight+extraVerticalBuffer))&& /* if we can collide, place it here THIS PART IS WRONG!! */
bubbleGrid[i][yPos+1] = ballToFly;
bubbleGrid[i][yPos+2] = ballToFly;
if(futureX<gridStartX) /*Bounce off the left */
ballAngle = 180-(ballAngle % 180);
if(futureX>gridStartX+(gridWidth*squareWidth-(squareWidth/2))) /*Bounce off the right*/
ballAngle = 360-ballAngle;