xxxxxxxxxx
149
const Engine = Matter.Engine;
const World = Matter.World;
const Bodies = Matter.Bodies;
const Body = Matter.Body;
var engine,world;
let song;
let song2,song3;
var ground;
var plinkos=[]
var curentsong;
var button,button2;
var count=0;
var Tframes=0;
var santa,santaImage
function preload()
{song = loadSound('song.mp3');
song2=loadSound('song2.mp3');
song3=loadSound('song3.mp3')
santaImage=loadImage('image.jpg')
}
function setup() {
button = createButton('wish you a mery chrismas');
button.position(width/2, 600);
button.mousePressed(changeSond);
button = createButton('12 days of chrismas');
button.position(width/2+190, 600);
button.mousePressed(changeSond2);
button2 = createButton('jingle bells');
button2.position(width/2-100, 600);
button2.mousePressed(changeSond3);
santa=createSprite(800,100,10,10)
angleMode(DEGREES)
curentsong=song
createCanvas(800, 700);
curentsong.play()
engine = Engine.create();
world = engine.world;
//Create the Bodies Here.
ground= new Ground(width/2,height/2+180,800,10)
santa.addImage ( 'sanat' ,santaImage )
santa.setVelocity ( -2,0 )
santa.scale=0.1
Engine.run(engine);
}
function draw() {
rectMode(CENTER);
background(135,206,235);
fill(255)
stroke(255)
ellipse(width/2-30,height/2+100,150,150)
ellipse(width/2-30,height/2-20,100,100)
push()
fill(0)
ellipse(width/2-20,height/2-20,10,10)
ellipse(width/2-40,height/2-20,10,10)
push()
strokeWeight(6)
stroke(0)
line(width/2-70,height/2+60,width/2-100,height/2+60)
line(width/2-100,height/2+60,width/2-120,height/2+80)
line(width/2-100,height/2+60,width/2-120,height/2+40)
line(width/2+30,height/2+60,width/2+50,height/2+60)
line(width/2+50,height/2+60,width/2+70,height/2+80)
line(width/2+50,height/2+60,width/2+70,height/2+40)
pop()
noFill()
strokeWeight(3)
stroke(255,0,0)
arc(width/2-30, height/2, 50, 50, 0,180 ,0 );
pop()
push()
fill(0)
text('by sarvagya singh' ,width/2,10)
pop()
if(santa.x<-300)
{
santa.x=800
}
for (var i = 0; i < plinkos.length; i++) {
plinkos[i].display();
}
drawSprites();
{
if(count<=400)
{
for (var j = 50; j <=width-10; j=j+50)
{
plinkos.push(new Plinko(j,0,10));
count++
}
}
else
{
Tframes++
}
if(Tframes>=100&&count>100)
{
Tframes=0
count=0
for (var i=0;i<plinkos.length;i++)
{
Matter.Composite.remove(world,plinkos[i].body )
}
plinkos=[]
}
}
ground.display()
}
function changeSond()
{
curentsong.stop()
curentsong=song2;
curentsong.play()
}
function changeSond2()
{
curentsong.stop()
curentsong=song;
curentsong.play()
}
function changeSond3()
{
curentsong.stop()
curentsong=song3;
curentsong.play()
}