Commit 1cdc152f authored by Gaurav Arora (gaa721)'s avatar Gaurav Arora (gaa721)
Browse files

fixed some buds

parents 471f6d17 55d536ef
File mode changed from 100755 to 100644
function declareWinner(gp) {
<<<<<<< HEAD
=======
<<<<<<< HEAD
>>>>>>> origin/master
scenario();
push();
fill(0, 10, 153);
......@@ -20,10 +24,44 @@ function createBoat(id, x, y, angle) {
0, this.rightOarY = 0, this.leftIn = false, this.rightIn = false, this.velocity =
0, this.vx = 0, this.vy = 0, this.prevLeftOarY = 0, this.prevLeftOarX =
0, this.score = 0;
<<<<<<< HEAD
this.max_hor_vel = 400;
this.max_ver_vel = 400;
this.vangle = -angle * 4;
=======
this.max_hor_vel = 400;
this.max_ver_vel = 400;
this.vangle = -angle * 4;
=======
function createBoat(id,x,y,angle){
this.id=id,
this.x = x,
this.y = y,
this.orix=x,
this.oriy=y,
this.oriA=angle;
this.angle=-angle*4,
this.leftOarX=0,
this.leftOarY=0,
this.rightOarX=0,
this.rightOarY=0,
this.leftIn=false,
this.rightIn=false,
this.velocity=0,
this.vx=0,
this.vy=0,
this.prevLeftOarY=0,
this.prevLeftOarX=0,
this.score=0;
this.max_hor_vel = 400;
this.max_ver_vel = 400;
this.vangle=-angle*4;
>>>>>>> 0260c3044e26947aa7c6c037cefe74f85233ad5f
>>>>>>> origin/master
this.polySd = new b2PolyDef();
this.polySd.density = 0.8;
this.polySd.vertexCount = points.length;
......@@ -33,6 +71,10 @@ function createBoat(id, x, y, angle) {
var polyBd = new b2BodyDef();
polyBd.AddShape(this.polySd);
<<<<<<< HEAD
=======
<<<<<<< HEAD
>>>>>>> origin/master
polyBd.position.Set(x, y);
// polyBd.rotation=PI/2;
this.body = world.CreateBody(polyBd);
......@@ -42,10 +84,39 @@ function createBoat(id, x, y, angle) {
this.leftStartPoint= {x: (-75)*smallFactor1 ,y:0};
this.leftEndPoint= {x:(this.leftOarX)*smallFactor1 ,y:(this.leftOarY)*smallFactor1};
<<<<<<< HEAD
=======
=======
polyBd.position.Set(x,y);
// polyBd.rotation=PI/2;
this.body = world.CreateBody(polyBd);
this.body.SetCenterPosition(new b2Vec2(x,y),angle);
// this.body.SetAngularVelocity(radians(angle));
// this.add_velocityang();
};
createBoat.prototype.reset=function()
{
if(this.score==3)
this.declareWinner();
>>>>>>> 0260c3044e26947aa7c6c037cefe74f85233ad5f
>>>>>>> origin/master
this.rightStartPoint= {x:(40)*smallFactor1 ,y:0};
this.rightEndPoint= {x:(this.rightOarX)*smallFactor1 ,y:(this.rightOarY)*smallFactor1};
<<<<<<< HEAD
=======
<<<<<<< HEAD
>>>>>>> origin/master
this.polL = new SAT
.Polygon(new SAT.Vector(ll+x,y), [ new SAT.Vector(this.leftStartPoint.x,this.leftStartPoint.y),new SAT.Vector(this.leftEndPoint.x,this.leftEndPoint.y)]);
this.polR = new SAT
......@@ -62,6 +133,14 @@ createBoat.prototype.reset=function()
this.x = this.orix;
this.y = this.oriy;
this.angle=-this.oriA*4;
<<<<<<< HEAD
=======
=======
this.x = this.orix;
this.y = this.oriy;
this.angle=-this.oriA*4;
>>>>>>> 0260c3044e26947aa7c6c037cefe74f85233ad5f
>>>>>>> origin/master
this.leftOarX=0;
this.leftOarY=0;
this.rightOarX=0;
......@@ -90,6 +169,7 @@ createBoat.prototype.reset=function()
polyBd.AddShape(this.polySd);
polyBd.position.Set(this.x,this.y);
<<<<<<< HEAD
this.body = world.CreateBody(polyBd);
this.body.SetCenterPosition(new b2Vec2(this.x,this.y),this.oriA);
......@@ -116,6 +196,53 @@ createBoat.prototype.moveBoat= function(gp)
}
=======
<<<<<<< HEAD
this.body = world.CreateBody(polyBd);
this.body.SetCenterPosition(new b2Vec2(this.x,this.y),this.oriA);
=======
this.body = world.CreateBody(polyBd);
this.body.SetCenterPosition(new b2Vec2(this.x,this.y),this.oriA);
>>>>>>> 0260c3044e26947aa7c6c037cefe74f85233ad5f
}
createBoat.prototype.moveBoat= function(gp)
{
//find left oar
if(gp.axes.length !=4)
{
this.leftOarX = 80 * gp.axes[1] - 100;
this.leftOarY = 100 * gp.axes[0];
// find right oar
this.rightOarX = 80 * gp.axes[3] + 100;
this.rightOarY = 100 * gp.axes[2];
}
else
{
this.leftOarX = 80 * gp.axes[0] - 100;
this.leftOarY = 100 * gp.axes[1];
// find right oar
this.rightOarX = 80 * gp.axes[2] + 100;
this.rightOarY = 100 * gp.axes[3];
}
>>>>>>> origin/master
// calculate movement
if (this.leftIn) {
......@@ -176,12 +303,21 @@ createBoat.prototype.moveBoat= function(gp)
this.leftEndPoint= {x:this.leftOarX*smallFactor1 ,y:this.leftOarY*smallFactor1};
this.rightStartPoint= {x:40*smallFactor1 ,y:0};
this.rightEndPoint= {x:this.rightOarX*smallFactor1 ,y:this.rightOarY*smallFactor1};
<<<<<<< HEAD
this.polL.pos.x=this.x+ll;
this.polL.pos.y=this.y;
this.polL.setPoints( [ new SAT.Vector(this.leftStartPoint.x,this.leftStartPoint.y),new SAT.Vector(this.leftEndPoint.x,this.leftEndPoint.y)] );
this.polL.rotate(this.vangle);
=======
this.polL.pos.x=this.x+ll;
this.polL.pos.y=this.y;
this.polL.setPoints( [ new SAT.Vector(this.leftStartPoint.x,this.leftStartPoint.y),new SAT.Vector(this.leftEndPoint.x,this.leftEndPoint.y)] );
this.polL.rotate(this.vangle);
>>>>>>> origin/master
this.polR.pos.x=this.x+ll;
this.polR.pos.y=this.y;
this.polR.setPoints( [ new SAT.Vector(this.rightStartPoint.x,this.rightStartPoint.y),new SAT.Vector(this.rightEndPoint.x,this.rightEndPoint.y)] );
......@@ -216,10 +352,29 @@ createBoat.prototype.moveBoat= function(gp)
this.y=this.body.GetOriginPosition().y;
this.vangle=this.body.GetRotation();
<<<<<<< HEAD
=======
<<<<<<< HEAD
>>>>>>> origin/master
}
createBoat.prototype.add_velocity = function(vel)
{
<<<<<<< HEAD
=======
=======
}
createBoat.prototype.add_velocity = function(vel)
{
>>>>>>> 0260c3044e26947aa7c6c037cefe74f85233ad5f
>>>>>>> origin/master
var b = this.body;
var v = b.GetLinearVelocity();
......@@ -263,7 +418,19 @@ createBoat.prototype.drawBoat= function()
// translate(ll + (this.x)*smallFactor,(-viewYU+this.y)*smallFactor);
// rotate(-(this.angle)/4); //rotating the boat
<<<<<<< HEAD
push();
translate(ll+this.x*smallFactor,(-viewYU+this.y)*smallFactor);
rotate(this.vangle);
// rect(-0,0,100, 100);
//if(sPoint<(boat.length)/2)
// {
image(bimg[floor((this.id)/((boat.length)/2))], (-95)*smallFactor1,-170*smallFactor1, bimg[0].width*smallFactor1, bimg[0].height*smallFactor1);
push();
=======
push();
<<<<<<< HEAD
translate(ll+this.x*smallFactor,(-viewYU+this.y)*smallFactor);
rotate(this.vangle);
// rect(-0,0,100, 100);
......@@ -272,6 +439,7 @@ createBoat.prototype.drawBoat= function()
// {
image(bimg[floor((this.id)/((boat.length)/2))], (-95)*smallFactor1,-170*smallFactor1, bimg[0].width*smallFactor1, bimg[0].height*smallFactor1);
push();
>>>>>>> origin/master
fill(125,12,15);
textSize(20);
......@@ -286,6 +454,37 @@ createBoat.prototype.drawBoat= function()
// vertex(points[0][0], points[0][1]);
// endShape();
<<<<<<< HEAD
=======
=======
translate(ll+this.x*smallFactor,(-viewYU+this.y)*smallFactor);
rotate(this.vangle);
// rect(-0,0,100, 100);
if(!sCheck)
{
image(bimg[this.id], (-95)*smallFactor1,-170*smallFactor1, bimg[this.id].width*smallFactor1, bimg[this.id].height*smallFactor1);
}
else
{
if(this.id<=1)
{
image(bimg[0], (-95)*smallFactor1,-170*smallFactor1, bimg[0].width*smallFactor1, bimg[0].height*smallFactor1);
}
else
image(bimg[1], (-95)*smallFactor1,-170*smallFactor1, bimg[1].width*smallFactor1, bimg[1].height*smallFactor1);
}
// beginShape();
// for (var i = 0; i <points.length; i++) {
// vertex(points[i][0], points[i][1]);
// }
// vertex(points[0][0], points[0][1]);
// endShape();
>>>>>>> 0260c3044e26947aa7c6c037cefe74f85233ad5f
>>>>>>> origin/master
pop();
push();
......@@ -310,6 +509,60 @@ createBoat.prototype.drawBoat= function()
line(this.rightStartPoint.x,this.rightStartPoint.y , this.rightEndPoint.x,this.rightEndPoint.y );
pop();
this.body.SetLinearVelocity(new b2Vec2(0,0));
<<<<<<< HEAD
=======
<<<<<<< HEAD
=======
}
createBoat.prototype.collision= function()
{
this.velocity+=0.1;
this.score--;
}
createBoat.prototype.moveView=function()
{
viewYU+=(this.velocity*(cos((this.angle)/4)))/3;
viewYD+=(this.velocity*(cos((this.angle)/4)))/3;
}
createBoat.prototype.declareWinner=function(gp)
{
scenario();
push();
fill(0,10,153);
textSize(80);
if(!sCheck){
text("Congratulations " + ("Player " +(this.id+ 1)) + " won" ,ll,height/2);
}
else
text("Congratulations " + ("Team " +((this.id/2)+1)) + " won" ,ll,height/2);
pop();
noLoop();
}
>>>>>>> 0260c3044e26947aa7c6c037cefe74f85233ad5f
>>>>>>> origin/master
}
function Soccer(x, y) {
this.y = height / 2;
<<<<<<< HEAD
this.x = ((rl - ll) / 2);
......@@ -27,6 +28,34 @@ Soccer.prototype.drawBall =function() {
push();
=======
this.x = ((rl - ll) / 2);
this.polySd = new b2CircleDef();
this.polySd.density = 0.5;
this.polySd.friction = 1.0;
this.polySd.radius = 65 / 2;
this.polyBd = new b2BodyDef();
this.polyBd.AddShape(this.polySd);
this.polyBd.position.Set(this.x, this.y);
this.body = world.CreateBody(this.polyBd);
this.body.m_linearDamping = 0.95;
this.SatCircle = new SAT
.Circle(new SAT.Vector(ll+this.x,this.y),65/2);
}
Soccer.prototype.drawBall =function() {
this.SatCircle.pos.x= ll+(this.body.GetOriginPosition().x)*smallFactor;
this.SatCircle.pos.y=-viewYU+this.body.GetOriginPosition().y;
push();
>>>>>>> origin/master
imageMode(CENTER);
image(simg, ll + (this.body.GetOriginPosition().x)*smallFactor , (this.body.GetOriginPosition().y)*smallFactor,img.height*smallFactor,img.width*smallFactor);
// ellipse( ll + (this.body.GetOriginPosition().x)*smallFactor , (-viewYU+this.body.GetOriginPosition().y)*smallFactor,65*smallFactor,65*smallFactor);
......@@ -36,7 +65,17 @@ Soccer.prototype.drawBall =function() {
Soccer.prototype.check =function() {
// ellipse(ll,100,50,50);
if(this.body.GetOriginPosition().x<=ll-ll+38)
<<<<<<< HEAD
{
team2+=1;
applauseSound.play();
allowed=false;
GoalText(0,0,119);
=======
{
<<<<<<< HEAD
team2+=1;
applauseSound.play();
......@@ -62,6 +101,32 @@ Soccer.prototype.check =function() {
if(this.body.GetOriginPosition().x>=rl-ll-38)
{
team1+=1;
applauseSound.play();
allowed=false;
GoalText(0,109,0);
>>>>>>> origin/master
for(var i=0;i<boat.length;i++)
boat[i].reset();
world.DestroyBody(this.body);
this.polySd = new b2CircleDef();
this.polySd.density = 0.5;
this.polySd.friction= 1.0;
this.polySd.radius = 65/2;
this.polyBd = new b2BodyDef();
this.polyBd.AddShape(this.polySd);
this.polyBd.position.Set(this.x,this.y);
this.body = world.CreateBody(this.polyBd);
this.body. m_linearDamping=0.95;
this.SatCircle= new SAT.Circle(new SAT.Vector(ll+this.x,this.y),65/2);
<<<<<<< HEAD
}
if(this.body.GetOriginPosition().x>=rl-ll-38)
{
team1+=1;
applauseSound.play();
......@@ -85,6 +150,62 @@ Soccer.prototype.check =function() {
}
=======
}
=======
if(sCheck)
{
boat[2].score+=1;
}
else
boat[1].score+=1;
allowed=false;
GoalText(0,0,119);
for(var i=0;i<boat.length;i++)
boat[i].reset();
this.body.m_position.Set(this.x,this.y);
}
if(this.body.GetOriginPosition().x>=1002)
{
boat[0].score+=1;
allowed=false;
GoalText(0,109,0);
for(var i=0;i<boat.length;i++)
boat[i].reset();
this.body.m_position.Set(this.x,this.y);
}
}
function GoalText(a,b,c)
{
push();
fill(a,b,c);
textSize(100);
text("Goal" ,(800),(height/2));
textSize(30);
text("Player 1, press X to continue" ,(750),(height/2+50));
pop();
>>>>>>> 0260c3044e26947aa7c6c037cefe74f85233ad5f
>>>>>>> origin/master
}
function GoalText(a, b, c) {
......@@ -121,12 +242,22 @@ waterStream.prototype.move=function()
if(this.y>=hght)
{
<<<<<<< HEAD
=======
<<<<<<< HEAD
>>>>>>> origin/master
this.x=random(20,860);
this.y= -300;
}
}
<<<<<<< HEAD
=======
=======
}
>>>>>>> 0260c3044e26947aa7c6c037cefe74f85233ad5f
>>>>>>> origin/master
waterStream.prototype.draw=function()
{
......
......@@ -302,10 +302,12 @@ function startMenu(gp) {
if (!gamepads)
return;
var gp = gamepads[0];
if (gp.axes.length != 4) {
background(20);
background(20);
scenario();
image(timg, ll + 75, 30, timg.width * 0.8, timg.height * 0.8);
if (gp.axes.length != 4) {
if (gp.axes[6] == 1) {
prevPress = true;
}
......@@ -336,102 +338,13 @@ function startMenu(gp) {
//UP key Released
if (gp.buttons[0].pressed) {
if (sPoint == 0) {
for (var i = 0; i < boat.length; i++)
world.DestroyBody(boat[i].body);
boat=[];
boat.push(new createBoat(0, 100, height / 2, radians(90)));
boat.push(
new createBoat(1, rl - ll - 100, height / 2, radians(-90)));
socbal = new Soccer();
return true;
}
else if (sPoint == 1) {
for (var i = 0; i < boat.length; i++)
world.DestroyBody(boat[i].body);
boat=[];
boat.push(new createBoat(0, 100, height / 2 - 200, radians(90)));
boat.push(new createBoat(1, 100, height / 2 + 200, radians(90)));
boat.push(
new createBoat(2, rl - ll - 100, height / 2 - 200,
radians(-90)));
boat.push(
new createBoat(3, rl - ll - 100, height / 2 + 200,
radians(-90)));
socbal = new Soccer();
return true;
}
else if (sPoint == 2) {
for (var i = 0; i < boat.length; i++)
world.DestroyBody(boat[i].body);
boat=[];
boat.push(new createBoat(0, 100, height / 2 - 300, radians(90)));
boat.push(new createBoat(1, 100, height / 2, radians(90)));
boat.push(new createBoat(2, 100, height / 2 + 300, radians(90)));
boat.push(
new createBoat(3, rl - ll - 100, height / 2 - 300,
radians(-90)));
boat.push(
new createBoat(4, rl - ll - 100, height / 2, radians(-90)));
boat.push(
new createBoat(5, rl - ll - 100, height / 2 + 300,
radians(-90)));
socbal = new Soccer();
return true;
}
else if (sPoint == 3) {
for (var i = 0; i < boat.length; i++)
world.DestroyBody(boat[i].body);
boat=[];
boat.push(new createBoat(0, 100, height / 2 - 200, radians(90)));
boat.push(new createBoat(1, 100, height / 2 - 400, radians(90)));
boat.push(new createBoat(2, 100, height / 2 + 200, radians(90)));
boat.push(new createBoat(3, 100, height / 2 + 400, radians(90)));
boat.push(
new createBoat(4, rl - ll - 100, height / 2 - 200,
radians(-90)));
boat.push(
new createBoat(5, rl - ll - 100, height / 2 - 400,
radians(-90)));
boat.push(
new createBoat(6, rl - ll - 100, height / 2 + 200,
radians(-90)));