Balloon Buster Game
Codes:-
var bg = createSprite(200,200);
bg.setAnimation("bg");
bg.scale = 8;
bg.velocityX = -5;
var bow = createSprite(350,200);
bow.setAnimation("bowImg");
bow.scale = 5;
var arrowGrp = createGroup();
var redBGrp = createGroup();
var blueBGrp = createGroup();
var greenBGrp = createGroup();
var yellowBGrp = createGroup();
var score = 0;
function Arrow(){
if(keyDown("space")){
var arrow = createSprite();
arrow.setAnimation("arrowImg");
arrow.scale = 3
arrow.x = bow.x;
arrow.y = bow.y;
arrow.velocityX = -15;
arrow.lifetime = 50;
arrowGrp.add(arrow);
playSound("sound://category_movement/puzzle_game_whoosh_01.mp3");
}
}
function randomBalloon(){
if(World.frameCount%80==0){
var redBalloon = createSprite(random(10,200),-5);
redBalloon.setAnimation("redB");
redBalloon.scale = 0.8;
redBalloon.velocityY=8;
redBalloon.lifetime = 100;
redBGrp.add(redBalloon);
}
if(World.frameCount%50==0){
var greenBalloon = createSprite(random(10,200),-8);
greenBalloon.setAnimation("greenB");
greenBalloon.scale = 0.8;
greenBalloon.velocityY=8;
greenBalloon.lifetime = 100;
greenBGrp.add(greenBalloon)
}
if(World.frameCount%20==0){
var blueBalloon = createSprite(random(10,200),-11);
blueBalloon.setAnimation("blueB");
blueBalloon.scale = 0.8;
blueBalloon.velocityY=8;
blueBalloon.lifetime = 100;
blueBGrp.add(blueBalloon);
}
if(World.frameCount%120==0){
var yellowBalloon = createSprite(random(10,200),-14);
yellowBalloon.setAnimation("yellowB");
yellowBalloon.scale = 0.8;
yellowBalloon.velocityY=8;
yellowBalloon.lifetime = 100;
yellowBGrp.add(yellowBalloon);
}
}
function draw() {
background("white");
bow.y = World.mouseY;
if(bg.x<0){
bg.x = bg.width/2;
}
if(arrowGrp.isTouching(redBGrp)){
redBGrp.destroyEach();
arrowGrp.destroyEach();
score = score+2;
}
if(arrowGrp.isTouching(blueBGrp)){
blueBGrp.destroyEach();
arrowGrp.destroyEach();
score = score+3;
}
if(arrowGrp.isTouching(greenBGrp)){
greenBGrp.destroyEach();
arrowGrp.destroyEach();
score = score+4;
}
if(arrowGrp.isTouching(yellowBGrp)){
yellowBGrp.destroyEach();
arrowGrp.destroyEach();
score = score+5;
}
Arrow();
randomBalloon();
drawSprites();
textSize(25);
fill("purple");
text("Score: "+score,270,50);
}
Watch Video:-
0 Comments: