Bubble shooter game in as3
Copy link to clipboard
Copied
hi ....anyone pls send tutorial for creating a bubble shooter game in as3 ......i am trying to creating a game which look like this
Thnks in advance ......
Copy link to clipboard
Copied
google: 'actionscript 3 shooter tutorial'.
Copy link to clipboard
Copied
i ant get clear tutorial bro /........
Copy link to clipboard
Copied
Copy link to clipboard
Copied
k
Copy link to clipboard
Copied
bro i cant get clear view to create bubble shooter game .....i have tried some thing
Copy link to clipboard
Copied
can i send u my flash file ...will you plz check out .
Copy link to clipboard
Copied
i don't download and correct files unless hired.
free help i offer via the adobe forums. if you can narrow the problem to a handful lines of code, you can copy and paste your code and i'll correct it.
Copy link to clipboard
Copied
k bro .......
i will paste my code ..
Copy link to clipboard
Copied
package {
import flash.display.Sprite;
import flash.events.KeyboardEvent;
import flash.events.Event;
public class Main extends Sprite {
private const ROT_SPEED:uint=2;
private const BRICK_W:int = 36;
private const BRICK_H:int = 36;
private const OFFSET:int = 20;
private const R:uint=18;
private const W_LEN:int = 20;
private var bricks:Vector.<Sprite> = new Vector.<Sprite>();
private const D:Number=R*Math.sqrt(3);
private const DEG_TO_RAD:Number=0.0174532925;
private const BUBBLE_SPEED:uint=10;
private var cannon:cannon_mc;
private var nextTetromino:uint;
private var left:Boolean=false;
private var right:Boolean=false;
private var bubCont:Sprite;
private var bubble:bubble_mc;
private var fire:Boolean=false;
private var vx,vy:Number;
private var fieldArray:Array;
private var chainArray:Array;
private var connArray:Array;
private const LEVEL_1:Array = [[1,1,1,1,1,1,1,1],
[1,1,1,1,1,1,1,1],
[1,1,1,1,1,1,1,1],
[1,1,1,1,1,1,1,1],
[1,1,1,1,1,1,1,1],
[0,1,1,1,1,1,1,0],
[0,0,0,1,1,0,0,0],
[0,0,0,1,1,0,0,0],
[0,0,0,0,1,0,0,0],];
public function Main() {
placeContainer();
placeCannon();
loadBubble();
buildLevel(LEVEL_1);
nextTetromino=Math.floor(Math.random()*7);
stage.addEventListener(KeyboardEvent.KEY_DOWN,onKDown);
stage.addEventListener(KeyboardEvent.KEY_UP,onKUp);
addEventListener(Event.ENTER_FRAME,onEFrame);
}
private function loadBubble():void {
bubble = new bubble_mc();
addChild(bubble);
bubble.gotoAndStop(Math.floor(Math.random()*6))+1;
bubble.x=R*8;
bubble.y=450;
}
private function placeContainer():void {
fieldArray=new Array();
bubCont=new Sprite();
addChild(bubCont);
bubCont.graphics.lineStyle(1,0xffffff,0.2);
for (var i:uint=0; i<11; i++) {
fieldArray=new Array();
for (var j:uint=0; j<8; j++) {
if (i%2==0) {
bubCont.graphics.drawCircle(R+j*R*2,R+i*D,R);
fieldArray
} else {
if (j<7) {
with (bubCont.graphics) {
drawCircle(2*R+j*R*2,R+i*D,R);
fieldArray
}
}
}
}
}
}
private function placeCannon():void {
cannon=new cannon_mc();
addChild(cannon);
cannon.y=450;
cannon.x=R*8;
}
private final function buildLevel(level:Array):void
{
/* Level length, height */
var len:int = level.length;
for(var i:int = 0; i < len; i++)
{
for(var j:int = 0; j < W_LEN; j++)
{
if(level
{
var brick:bubble_mc = new bubble_mc();
brick.x = OFFSET + (BRICK_W * j);
brick.y = BRICK_H * i;
addChild(brick);
brick.gotoAndStop(Math.floor(Math.random()*6))+1;
bricks.push(brick);
}
}
}
}
private function onKDown(e:KeyboardEvent):void {
switch (e.keyCode) {
case 37 :
left=true;
break;
case 39 :
right=true;
break;
case 38 :
if (! fire) {
fire=true;
var radians=(cannon.rotation-90)*DEG_TO_RAD;
vx=BUBBLE_SPEED*Math.cos(radians);
vy=BUBBLE_SPEED*Math.sin(radians);
}
break;
}
}
private function onKUp(e:KeyboardEvent):void {
switch (e.keyCode) {
case 37 :
left=false;
break;
case 39 :
right=false;
break;
}
}
private function onEFrame(e:Event):void {
if (left) {
cannon.rotation-=ROT_SPEED;
}
if (right) {
cannon.rotation+=ROT_SPEED;
}
if (fire) {
bubble.x+=vx;
bubble.y+=vy;
if (bubble.x<R) {
bubble.x=R;
vx*=-1;
}
if (bubble.x>R*15) {
bubble.x=R*15;
vx*=-1;
}
if (bubble.y<R) {
parkBubble();
} else {
for (var i:uint = 0; i<bubCont.numChildren; i++) {
var tmp:bubble_mc;
tmp=bubCont.getChildAt(i) as bubble_mc;
if (collide(tmp)) {
parkBubble();
break;
}
}
}
}
}
private function collide(bub:bubble_mc):Boolean {
var dist_x:Number=bub.x-bubble.x;
var dist_y:Number=bub.y-bubble.y;
return Math.sqrt(dist_x*dist_x+dist_y*dist_y)<=2*R;
}
private function parkBubble():void {
var row:uint=Math.floor(bubble.y/D);
var col:uint;
if (row%2==0) {
col=Math.floor(bubble.x/(R*2));
} else {
col=Math.floor((bubble.x-R)/(R*2));
}
var placedBubble:bubble_mc = new bubble_mc();
bubCont.addChild(placedBubble);
if (row%2==0) {
placedBubble.x=(col*R*2)+R;
} else {
placedBubble.x=(col*R*2)+2*R;
}
placedBubble.y=(row*D)+R;
placedBubble.gotoAndStop(bubble.currentFrame);
placedBubble.name=row+"_"+col;
fieldArray[row][col]=bubble.currentFrame;
chainArray=new Array();
getChain(row,col);
if (chainArray.length>2) {
for (var i:uint=0; i<chainArray.length; i++) {
with (bubCont) {
removeChild(getChildByName(chainArray));
}
var coords:Array=chainArray.split("_");
fieldArray[coords[0]][coords[1]]=0;
}
removeNotConnected();
}
removeChild(bubble);
fire=false;
loadBubble();
}
private function getValue(row:int,col:int):int {
if (fieldArray[row]==null) {
return -1;
}
if (fieldArray[row][col]==null) {
return -1;
}
return fieldArray[row][col];
}
private function getChain(row:int,col:int):void {
chainArray.push(row+"_"+col);
var odd:uint=row%2;
var match:uint=fieldArray[row][col];
for (var i:int=-1; i<=1; i++) {
for (var j:int=-1; j<=1; j++) {
if (i!=0||j!=0) {
if (i==0||j==0||(j==-1&&odd==0)||(j==1&&odd==1)) {
if (isNewChain(row+i,col+j,match)) {
getChain(row+i,col+j);
}
}
}
}
}
}
private function isNewChain(row:int,col:int,val:uint):Boolean {
return val == getValue(row,col)&&chainArray.indexOf(row+"_"+col)==-1;
}
private function removeNotConnected():void {
for (var i:uint=1; i<11; i++) {
for (var j:uint=0; j<8; j++) {
if (getValue(i,j)>0) {
connArray=new Array();
getConnections(i,j);
if (connArray[0]!="connected") {
with (bubCont) {
removeChild(getChildByName(i+"_"+j));
}
fieldArray
}
}
}
}
}
private function getConnections(row:int,col:int):void {
connArray.push(row+","+col);
var odd:uint=row%2;
for (var i:int=-1; i<=1; i++) {
for (var j:int=-1; j<=1; j++) {
if (i!=0||j!=0) {
if (i==0||j==0||(j==-1&&odd==0)||(j==1&&odd==1)) {
if (isNewConnection(row+i,col+j)) {
if (row+i==0) {
connArray[0]="connected";
} else {
getConnections(row+i,col+j);
}
}
}
}
}
}
}
private function isNewConnection(row:int,col:int):Boolean {
return getValue(row,col)>0&&connArray.indexOf(row+","+col)==-1;
}
}
}
Copy link to clipboard
Copied
In above code i don't know how to show next loading bubble and how to place the bubble in the stage for an level 1
Copy link to clipboard
Copied
again, if you can narrow the problem to a handful lines of code, you can copy and paste your code and i'll correct it.
use the trace function to pinpoint the problem.
Copy link to clipboard
Copied
k bro
Copy link to clipboard
Copied
bro .i need script for placing bubbles in stage and show next loading bubble near the cannon ......pls help i dnt knw how to do these things in my above code
Copy link to clipboard
Copied
use the 'new' constuctor to create another bubble and use addChild() to add that bubble to the stage. assign the new bubbles x and y properties to position it near your cannon:
var bubble:Bubble=new Bubble();
addChild(bubble);
bubble.x=
bubble.y=
Copy link to clipboard
Copied
bro if i do that means both bubble showing same color and changing the color simultaneously ....if there is any other idea bro ................
Copy link to clipboard
Copied
bro how can i show next loading bubble like above figure bro .....
Copy link to clipboard
Copied
bro how can i show next loading bubble like above figure bro .....
Copy link to clipboard
Copied
do you understand the code in message 9?
Copy link to clipboard
Copied
sorry ......No bro i don't understand ....
Copy link to clipboard
Copied
then you'll need to start learning actionscript or hire someone to do this for you.
if you want help learning and have questions, you can post them here and get free help. if you want to hire someone, send me a private message.

