xxxxxxxxxx
1933
//player variables
var player1x = 100;
var player1y = 100;
var player2y = 400;
var player2x = 400;
var player1dir = 1;
var player2dir = 5;
var player1spinCoolDown = 0;
var player2spinCoolDown = 0;
var fist1Lx = 125;
var fist1Ly = 100;
var fist1Rx = 100;
var fist1Ry = 125;
var fist2Lx = 375;
var fist2Ly = 400;
var fist2Rx = 400;
var fist2Ry = 375;
let points1 = [];
let points2 = [];
//punch variable
var p1punchRmoveX=1;
var p1punchRmoveY=1;
var p1Rcool = 0;
var p1Lcool = 0;
var p1punchLmoveX=1;
var p1punchLmoveY=1;
//p2 punches
var p2punchRmoveX=1;
var p2punchRmoveY=1;
var p2punchLmoveX=1;
var p2punchLmoveY=1;
var p2Rcool = 0;
var p2Lcool = 0;
var p1Disp2 = 0;
var p1LDisp2L = 0;
var p1LDisp2R = 0;
var p1RDisp2L = 0;
var p1RDisp2R = 0;
var p1Health = 200;
var p2Health = 200;
var p1LHitDist = 0;
var p1RHitDist = 0;
var p2LHitDist = 0;
var p2RHitDist = 0;
var p1Lblock = false;
var p1Rblock = false;
var p2Lblock = false;
var p2Rblock = false;
var closestDirectionDist = 0;
var screen = 1;
var sayingTime = 0;
var p1Hook = false;
var p2Hook = false;
var p1Coach = 0;
var p1BlockTimeR = 0;
var p1BlockTimeL = 0;
var p2BlockTimeR = 0;
var p2BlockTimeL = 0;
function setup() {
createCanvas(500, 500);
//arrays
for(let i=0; i<32; i++)
{
points1[i] = new Points(player1x,player1y,0);
}
for(let l=0; l<32; l++)
{
points2[l] = new Points(0,0,0);
}
button1 = createButton("Next");
button1.mousePressed(Next);
button1.position(20,20);
}
function draw() {
background("gray");
if(screen==1)
{
textSize(70);
text("Boxing",150,250);
fill("rgb(221,25,25)");
noStroke();
circle(250,100,100);
circle(200,120,70);
rect(210,80,80,130);
}
if(screen == 2)
{
text("How to play",70,70);
textSize(25);
text("player one uses WASD to move",50,200);
text("player two uses IJKL to move",50,300);
}
if(screen==3)
{
textSize(25);
text("player one uses Q and E for jabs",50,200);
text("player two uses U and O for jabs",50,300);
}
if(screen==4)
{
textSize(20);
text("If a normal punch hits your fist, it gets blocked",50,100);
text("player one uses shift and F for braced blocks",50,200);
text("player two uses H and ; for braced blocks",50,300);
}
if(screen==5)
{
textSize(20);
text("player one uses Z and C for breakthrough strike",50,200);
text("player two uses N and M for breakthrough strike",50,300);
text("breakthrough strikes will hit through normal blocks",50,400);
text("but not through braced blocks",50,450);
}
if(screen==6)
{
button1.position(-200,250);
//ring
strokeWeight(5);
fill("rgb(89,89,209)");
rect(50,50,400,400);
//players
strokeWeight(8);
//player1
fill("orange");
circle(player1x,player1y,50);
circle(fist1Lx,fist1Ly,20);
circle(fist1Rx,fist1Ry,20);
//player2
fill("purple")
circle(player2x,player2y,50);
circle(fist2Lx,fist2Ly,20);
circle(fist2Rx,fist2Ry,20);
//lines
strokeWeight(5);
rect(50,10,400,5);
rect(50,30,400,5);
rect(50,410,400,5);
rect(50,430,400,5);
//posts
fill("red");
rect(50,0,10,50);
rect(440,0,10,50);
//other line
rect(52,30,5,400);
rect(442,30,5,400);
//otherposts
rect(50,400,10,50);
rect(440,400,10,50);
//healthbars
//p1
fill("rgb(117,107,107)");
rect(25,460,200,20);
fill("red");
rect(25,460,p1Health,20);
//p2
fill("rgb(117,107,107)");
rect(275,460,200,20);
fill("red");
rect(275,460,p2Health,20);
//p1 coach
fill("orange");
circle(30,50,50);
circle(50,50,25);
circle(30,70,25);
//p2 coach
fill("purple");
circle(470,450,50);
circle(450,450,25);
circle(470,430,25);
Movement();
}
if(screen == 7)
{
//p1 wins
fill("orange");
text("Player 1 Wins",50,50);
strokeWeight(8);
player1x = 100;
player1y = 175;
player2x = 300;
player2y = 175;
fist1Lx = 125;
fist1Ly = 150;
fist1Rx = 75;
fist1Ry = 150;
fist2Lx = 325;
fist2Ly = 150;
fist2Rx = 275;
fist2Ry = 150;
//the belt
fill("brown");
rect(30,80,120,20);
fill("gold");
circle(90,90,30);
//player1
fill("orange");
circle(player1x,player1y,50);
circle(fist1Lx,fist1Ly,20);
circle(fist1Rx,fist1Ry,20);
//player2
fill("purple")
circle(player2x,player2y,50);
circle(fist2Lx,fist2Ly,20);
circle(fist2Rx,fist2Ry,20);
}
if(screen == 8)
{
//p1 wins
text("Player 2 Wins",200,50);
strokeWeight(8);
player1x = 100;
player1y = 175;
player2x = 300;
player2y = 175;
fist1Lx = 125;
fist1Ly = 150;
fist1Rx = 75;
fist1Ry = 150;
fist2Lx = 325;
fist2Ly = 150;
fist2Rx = 275;
fist2Ry = 150;
//the belt
fill("brown");
rect(200,80,120,20);
fill("gold");
circle(240,90,30);
//player1
fill("orange");
circle(player1x,player1y,50);
circle(fist1Lx,fist1Ly,20);
circle(fist1Rx,fist1Ry,20);
//player2
fill("purple")
circle(player2x,player2y,50);
circle(fist2Lx,fist2Ly,20);
circle(fist2Rx,fist2Ry,20);
}
}
function Movement()
{
if(p1Health==0)
{
screen=8;
}
if(p2Health==0)
{
screen=7;
}
//rotating
if(player1x < player2x && player1y < player2y)
{
player1dir = 1;
player2dir = 5;
}
else if(player1x > player2x && player1y < player2y)
{
player1dir = 3;
player2dir = 7;
}
else if(player1x < player2x && player1y > player2y)
{
player1dir = 7;
player2dir = 3;
}
else if(player1x > player2x && player1y > player2y)
{
player1dir = 5;
player2dir = 1;
}
//punching hitting
p1LHitDist = dist(fist1Lx,fist1Ly,player2x,player2y);
p1RHitDist = dist(fist1Rx,fist1Ry,player2x,player2y);
p2LHitDist = dist(fist2Lx,fist2Ly,player1x,player1y);
p2RHitDist = dist(fist2Rx,fist2Ry,player1x,player1y);
if(p1LHitDist < 25)
{
sayingTime = 50;
p2Health-=10;
p1Lcool = 0;
p1punchLmoveX = 0;
move1();
}
if(p1RHitDist < 25)
{
sayingTime = 50;
p2Health-=10;
p1Rcool = 0;
p1punchRmoveX = 0;
move1();
}
if(p2LHitDist < 25)
{
sayingTime = 50;
p1Health-=10;
p2Lcool = 0;
p2punchLmoveX = 0;
move2();
}
if(p2RHitDist < 25)
{
sayingTime = 50;
p1Health-=10;
p2Rcool = 0;
p2punchRmoveX = 0;
move2();
}
//dist from players to each other
p1Distp2 = dist(player1x,player1y,player2x,player2y);
//dist from fists
p1LDisp2L = dist(fist1Lx, fist1Ly, fist2Lx, fist2Ly);
p1LDisp2R = dist(fist1Lx, fist1Ly, fist2Rx, fist2Ry);
p1RDisp2L = dist(fist1Rx, fist1Ry, fist2Lx, fist2Ly);
p1RDisp2R = dist(fist1Rx, fist1Ry, fist2Rx, fist2Ry);
if(player1spinCoolDown>=1)
{
player1spinCoolDown -= 1;
}
if(player2spinCoolDown>=1)
{
player2spinCoolDown -= 1;
}
//cooldowns
if(sayingTime >=1)
{
sayingTime-=1;
coachSaying();
}
if(p1Rcool>=1)
{
p1Rcool-=1;
if(p1Hook == false)
{
punch1R();
}
if(p1Hook == true)
{
p1HookR();
}
}
else
{
p1punchRmoveX =0;
}
if(p1Lcool>=1)
{
p1Lcool-=1;
if(p1Hook == false)
{
punch1L();
}
if(p1Hook == true)
{
p1HookL();
}
}
else
{
p1punchLmoveX =0;
}
if(p2Rcool>=1)
{
p2Rcool-=1;
if(p2Hook == false)
{
punch2R();
}
if(p2Hook == true)
{
p2HookR();
}
}
else
{
p2punchRmoveX =0;
}
if(p2Lcool>=1)
{
p2Lcool-=1;
if(p2Hook == false)
{
punch2L();
}
if(p2Hook == true)
{
p2HookL();
}
}
else
{
p2punchLmoveX =0;
}
if(p1BlockTimeR > 0)
{
if(p1BlockTimeR==1)
{
p1BlockTimeR -= 1;
move1();
}
p1BlockTimeR -= 1;
}
if(p1BlockTimeL > 0)
{
if(p1BlockTimeL==1)
{
p1BlockTimeL -= 1;
move1();
}
p1BlockTimeL -= 1;
}
if(p2BlockTimeR > 0)
{
if(p2BlockTimeR==1)
{
p2BlockTimeR -= 1;
move2();
}
p2BlockTimeR -= 1;
}
if(p2BlockTimeL > 0)
{
if(p2BlockTimeL==1)
{
p2BlockTimeL -= 1;
move2();
}
p2BlockTimeL -= 1;
}
if(p1Rcool == 0 && p1Lcool==0)
{
//resets x and y punch movements
p1punchLmoveY =0;
p2punchLmoveY =0;
//player 1
if(keyIsDown(87))
{
if(p1Distp2 > 50)
{
if(player1y>75)
{
player1y -=1;
fist1Ly -=1;
fist1Ry -=1;
move1();
}
}
else
{
player1y +=2.1;
fist1Ly +=2.1;
fist1Ry +=2.1;
}
}
if(keyIsDown(68))
{
if(p1Distp2 > 50)
{
if(player1x<425)
{
player1x +=1;
fist1Lx +=1;
fist1Rx +=1;
move1();
}
}
else
{
player1x -=2.1;
fist1Lx -=2.1;
fist1Rx -=2.1;
}
}
if(keyIsDown(83))
{
if(p1Distp2 > 50)
{
if(player1y<425)
{
player1y +=1;
fist1Ly +=1;
fist1Ry +=1;
move1();
}
}
else
{
player1y -=2.1;
fist1Ly -=2.1;
fist1Ry -=2.1;
}
}
if(keyIsDown(65))
{
if(p1Distp2 > 50)
{
if(player1x>75)
{
player1x -=1;
fist1Lx -=1;
fist1Rx -=1;
move1();
}
}
else
{
player1x +=2.1;
fist1Lx +=2.1;
fist1Rx +=2.1;
}
}
}
//player 2
if(p2Rcool == 0 && p2Lcool==0)
{
if(keyIsDown(73))
{
if(p1Distp2 > 50)
{
if(player2y>75)
{
player2y -=1;
fist2Ly -=1;
fist2Ry -=1;
move2();
}
}
else
{
player2y +=2.1;
fist2Ly +=2.1;
fist2Ry +=2.1;
}
}
if(keyIsDown(76))
{
if(p1Distp2 > 50)
{
if(player2x<425)
{
player2x +=1;
fist2Lx +=1;
fist2Rx +=1;
move2();
}
}
else
{
player2x -=2.1;
fist2Lx -=2.1;
fist2Rx -=2.1;
}
}
if(keyIsDown(75))
{
if(p1Distp2 > 50)
{
if(player2y<425)
{
player2y +=1;
fist2Ly +=1;
fist2Ry +=1;
move2();
}
}
else
{
player2y -=2.1;
fist2Ly -=2.1;
fist2Ry -=2.1;
}
}
if(keyIsDown(74))
{
if(p1Distp2 > 50)
{
if(player2x>75)
{
player2x -=1;
fist2Lx -=1;
fist2Rx -=1;
move2();
}
}
else
{
player2x +=2.1;
fist2Lx +=2.1;
fist2Rx +=2.1;
}
}
}
//rotate buttons
//player1
if(p1Rcool == 0 && p1Lcool==0)
{
//player2
if(p2Rcool == 0 && p2Lcool==0)
{
if(keyIsDown(188))
{
if(player2spinCoolDown == 0)
{
if(player2dir<8)
{
player2dir+=1;
}
else if(player2dir == 8)
{
player2dir = 1;
}
move2();
player2spinCoolDown=10;
}
}
}
//player1 punchin
if(keyIsDown(69))
{
if(p1Rcool==0)
{
//right jab
p1Hook=false;
p1Rcool=30;
}
}
if(keyIsDown(81))
{
if(p1Lcool==0)
{
//left jab
p1Hook=false;
p1Lcool=30;
}
}
//player 2 punch
if(keyIsDown(79))
{
if(p2Rcool==0)
{
//right jab
p2Hook=false;
p2Rcool=30;
}
}
if(keyIsDown(85))
{
if(p2Lcool==0)
{
//left jab
p2Hook=false;
p2Lcool=30;
}
}
//hooks
if(keyIsDown(90))
{
if(p1Lcool == 0)
{
p1punchLmoveX =0;
p1Lcool=30;
p1Hook = true;
}
}
if(keyIsDown(67))
{
if(p1Rcool == 0)
{
p1punchRmoveX =0;
p1Rcool=30;
p1Hook = true;
}
}
//p2
if(keyIsDown(78))
{
if(p2Lcool == 0)
{
p2punchLmoveX =0;
p2Lcool=30;
p2Hook = true;
}
}
if(keyIsDown(77))
{
if(p2Rcool == 0)
{
p2punchRmoveX =0;
p2Rcool=30;
p2Hook = true;
}
}
}
//blocks
//p1
if(keyIsDown(16))
{
//left block
p1Lblock = true;
p1BlockTimeL = 10;
move1();
}
if(keyIsDown(70))
{
//right block
p1BlockTimeR = 10;
p1Rblock = true;
move1();
}
//p1
if(keyIsDown(72))
{
//left block
p2BlockTimeL = 10;
p2Lblock = true;
move2();
}
if(keyIsDown(186))
{
//right block
p2BlockTimeR = 10;
p2Rblock = true;
move2();
}
}
function move1()
{
//blocks time
if(p1BlockTimeR == 0)
{
p1Rblock = false;
}
if(p1BlockTimeL == 0)
{
p1Lblock = false;
}
//player1 fists direction
if(player1dir==1)
{
if(p1Lblock==false)
{
fist1Lx=player1x+25;
fist1Ly=player1y;
}
else
{
fist1Lx=player1x+30;
fist1Ly=player1y-10;
}
if(p1Rblock==false)
{
fist1Rx=player1x;
fist1Ry=player1y+25;
}
else
{
fist1Rx=player1x-10;
fist1Ry=player1y+30;
}
}
if(player1dir==2 )
{
if(p1Lblock==false)
{
fist1Lx=player1x+20;
fist1Ly=player1y+20;
}
else
{
fist1Lx=player1x+30;
fist1Ly=player1y+10;
}
if(p1Rblock==false)
{
fist1Ry=player1y+20;
fist1Rx=player1x-20;
}
else
{
fist1Ry=player1y+10;
fist1Rx=player1x-30;
}
}
if(player1dir==3)
{
if(p1Lblock==false)
{
fist1Lx=player1x;
fist1Ly=player1y+25;
}
else
{
fist1Lx=player1x+10;
fist1Ly=player1y+25;
}
if(p1Rblock==false)
{
fist1Rx=player1x-25;
fist1Ry=player1y;
}
else
{
fist1Rx=player1x-25;
fist1Ry=player1y-10;
}
}
if(player1dir==4)
{
if(p1Lblock==false)
{
fist1Lx=player1x-20;
fist1Ly=player1y+20;
}
else
{
fist1Lx=player1x-30;
fist1Ly=player1y1+10;
}
if(p1Rblock==false)
{
fist1Rx=player1x-20;
fist1Ry=player1y-20;
}
else
{
fist1Rx=player1x+30;
fist1Ry=player1y+10;
}
}
if(player1dir==5)
{
if(p1Lblock==false)
{
fist1Lx=player1x-25;
fist1Ly=player1y;
}
else
{
fist1Lx=player1x-20;
fist1Ly=player1y+20;
}
if(p1Rblock==false)
{
fist1Rx=player1x;
fist1Ry=player1y-25;
}
else
{
fist1Rx=player1x+30;
fist1Ry=player1y-10;
}
}
if(player1dir==6)
{
if(p1Lblock==false)
{
fist1Lx=player1x-20;
fist1Ly=player1y-20;
}
else
{
fist1Lx=player1x-20;
fist1Ly=player1y+20;
}
if(p1Rblock==false)
{
fist1Rx=player1x+20;
fist1Ry=player1y-20;
}
else
{
fist1Rx=player1x+20;
fist1Ry=player1y+20;
}
}
if(player1dir==7)
{
if(p1Lblock==false)
{
fist1Lx=player1x;
fist1Ly=player1y-25;
}
else
{
fist1Lx=player1x-20;
fist1Ly=player1y-20;
}
if(p1Rblock==false)
{
fist1Rx=player1x+25;
fist1Ry=player1y;
}
else
{
fist1Rx=player1x+20;
fist1Ry=player1y+20;
}
}
if(player1dir==8)
{
if(p1Lblock==false)
{
fist1Lx=player1x+20;
fist1Ly=player1y-20;
}
else
{
fist1Lx=player1x-20;
fist1Ly=player1y+20;
}
if(p1Rblock==false)
{
fist1Rx=player1x+20;
fist1Ry=player1y+20;
}
else
{
fist1Rx=player1x+20;
fist1Ry=player1y+20;
}
}
}
function move2()
{
//blocks time
if(p2BlockTimeR == 0)
{
p2Rblock = false;
}
if(p2BlockTimeL == 0)
{
p2Lblock = false;
}
//player1 fists direction
if(player2dir==1)
{
if(p2Lblock==false)
{
fist2Lx=player2x+25;
fist2Ly=player2y;
}
else
{
fist2Lx=player2x+30;
fist2Ly=player2y-10;
}
if(p2Rblock==false)
{
fist2Rx=player2x;
fist2Ry=player2y+25;
}
else
{
fist2Rx=player2x-10;
fist2Ry=player2y+30;
}
}
if(player2dir==2 )
{
if(p2Lblock==false)
{
fist2Lx=player2x+20;
fist2Ly=player2y+20;
}
else
{
fist2Lx=player2x+30;
fist2Ly=player2y+10;
}
if(p2Rblock==false)
{
fist2Ry=player2y+20;
fist2Rx=player2x-20;
}
else
{
fist2Ry=player2y+10;
fist2Rx=player2x-30;
}
}
if(player2dir==3)
{
if(p2Lblock==false)
{
fist2Lx=player2x;
fist2Ly=player2y+25;
}
else
{
fist2Lx=player2x+10;
fist2Ly=player2y+25;
}
if(p2Rblock==false)
{
fist2Rx=player2x-25;
fist2Ry=player2y;
}
else
{
fist2Rx=player2x-25;
fist2Ry=player2y-10;
}
}
if(player2dir==4)
{
if(p2Lblock==false)
{
fist2Lx=player2x-20;
fist2Ly=player2y+20;
}
else
{
fist2Lx=player2x-20;
fist2Ly=player2y+20;
}
if(p2Rblock==false)
{
fist2Rx=player2x-20;
fist2Ry=player2y-20;
}
else
{
fist2Rx=player2x+20;
fist2Ry=player2y+20;
}
}
if(player2dir==5)
{
if(p2Lblock==false)
{
fist2Lx=player2x-25;
fist2Ly=player2y;
}
else
{
fist2Lx=player2x-20;
fist2Ly=player2y+20;
}
if(p2Rblock==false)
{
fist2Rx=player2x;
fist2Ry=player2y-25;
}
else
{
fist2Rx=player2x+20;
fist2Ry=player2y+20;
}
}
if(player2dir==6)
{
if(p2Lblock==false)
{
fist2Lx=player2x-20;
fist2Ly=player2y-20;
}
else
{
fist2Lx=player2x-20;
fist2Ly=player2y+20;
}
if(p2Rblock==false)
{
fist2Rx=player2x+20;
fist2Ry=player2y-20;
}
else
{
fist2Rx=player2x+20;
fist2Ry=player2y+20;
}
}
if(player2dir==7)
{
if(p2Lblock==false)
{
fist2Lx=player2x;
fist2Ly=player2y-25;
}
else
{
fist2Lx=player2x-20;
fist2Ly=player2y+20;
}
if(p2Rblock==false)
{
fist2Rx=player2x+25;
fist2Ry=player2y;
}
else
{
fist2Rx=player2x+20;
fist2Ry=player2y+20;
}
}
if(player2dir==8)
{
if(p2Lblock==false)
{
fist2Lx=player2x+20;
fist2Ly=player2y-20;
}
else
{
fist2Lx=player2x-20;
fist2Ly=player2y+20;
}
if(p2Rblock==false)
{
fist2Rx=player2x+20;
fist2Ry=player2y+20;
}
else
{
fist2Rx=player2x+20;
fist2Ry=player2y+20;
}
}
}
function punch1R()
{
if(p1RDisp2L < 15)
{
move1();
p1Rcool = 0;
}
if(p1RDisp2R < 15)
{
move1();
p1Rcool = 0;
}
if(player1dir==1)
{
p1punchRmoveX=1;
p1punchRmoveY=1;
}
if(player1dir==2)
{
p1punchRmoveX=0;
p1punchRmoveY=2;
}
if(player1dir==3)
{
p1punchRmoveX=-1;
p1punchRmoveY=1;
}
if(player1dir==4)
{
p1punchRmoveX=-2;
p1punchRmoveY=0;
}
if(player1dir==5)
{
p1punchRmoveX=-1;
p1punchRmoveY=-1;
}
if(player1dir==6)
{
p1punchRmoveX=0;
p1punchRmoveY=-2;
}
if(player1dir==7)
{
p1punchRmoveX=1;
p1punchRmoveY=-1;
}
if(player1dir==8)
{
p1punchRmoveX=2;
p1punchRmoveY=0;
}
if(p1Rcool>=15)
{
fist1Rx+=p1punchRmoveX;
fist1Ry+=p1punchRmoveY;
}
else
{
fist1Rx-=p1punchRmoveX;
fist1Ry-=p1punchRmoveY;
}
}
function punch1L()
{
if(p1LDisp2L < 15)
{
move1();
p1Lcool = 0;
}
if(p1LDisp2R < 15)
{
move1();
p1Lcool = 0;
}
if(player1dir==1)
{
p1punchLmoveX=1;
p1punchLmoveY=1;
}
if(player1dir==2)
{
p1punchLmoveX=0;
p1punchLmoveY=2;
}
if(player1dir==3)
{
p1punchLmoveX=-1;
p1punchLmoveY=1;
}
if(player1dir==4)
{
p1punchLmoveX=-2;
p1punchLmoveY=0;
}
if(player1dir==5)
{
p1punchLmoveX=-1;
p1punchLmoveY=-1;
}
if(player1dir==6)
{
p1punchLmoveX=0;
p1punchLmoveY=-2;
}
if(player1dir==7)
{
p1punchLmoveX=1;
p1punchLmoveY=-1;
}
if(player1dir==8)
{
p1punchLmoveX=2;
p1punchLmoveY=0;
}
if(p1Lcool>=15)
{
fist1Lx+=p1punchLmoveX;
fist1Ly+=p1punchLmoveY;
}
else
{
fist1Lx-=p1punchLmoveX;
fist1Ly-=p1punchLmoveY;
}
}
function punch2R()
{
if(p1LDisp2R < 15)
{
move2();
p2Rcool = 0;
}
if(p1RDisp2R < 15)
{
move2();
p2Rcool = 0;
}
if(player2dir==1)
{
p2punchRmoveX=1;
p2punchRmoveY=1;
}
if(player2dir==2)
{
p2punchRmoveX=0;
p2punchRmoveY=2;
}
if(player2dir==3)
{
p2punchRmoveX=-1;
p2punchRmoveY=1;
}
if(player2dir==4)
{
p2punchRmoveX=-2;
p2punchRmoveY=0;
}
if(player2dir==5)
{
p2punchRmoveX=-1;
p2punchRmoveY=-1;
}
if(player2dir==6)
{
p2punchRmoveX=0;
p2punchRmoveY=-2;
}
if(player2dir==7)
{
p2punchRmoveX=1;
p2punchRmoveY=-1;
}
if(player2dir==8)
{
p2punchRmoveX=2;
p2punchRmoveY=0;
}
if(p2Rcool>=15)
{
fist2Rx+=p2punchRmoveX;
fist2Ry+=p2punchRmoveY;
}
else
{
fist2Rx-=p2punchRmoveX;
fist2Ry-=p2punchRmoveY;
}
}
function punch2L()
{
if(p1LDisp2L < 15)
{
move2();
p2Lcool = 0;
}
if(p1RDisp2L < 15)
{
move2();
p2Lcool = 0;
}
if(player2dir==1)
{
p2punchLmoveX=1;
p2punchLmoveY=1;
}
if(player2dir==2)
{
p2punchLmoveX=0;
p2punchLmoveY=2;
}
if(player2dir==3)
{
p2punchLmoveX=-1;
p2punchLmoveY=1;
}
if(player2dir==4)
{
p2punchLmoveX=-2;
p2punchLmoveY=0;
}
if(player2dir==5)
{
p2punchLmoveX=-1;
p2punchLmoveY=-1;
}
if(player2dir==6)
{
p2punchLmoveX=0;
p2punchLmoveY=-2;
}
if(player2dir==7)
{
p2punchLmoveX=1;
p2punchLmoveY=-1;
}
if(player2dir==8)
{
p2punchLmoveX=2;
p2punchLmoveY=0;
}
if(p2Lcool>=15)
{
fist2Lx+=p2punchLmoveX;
fist2Ly+=p2punchLmoveY;
}
else
{
fist2Lx-=p2punchLmoveX;
fist2Ly-=p2punchLmoveY;
}
}
function Next()
{
screen+=1;
}
function p1HookR()
{
//blocks
if(p1RDisp2L < 15 && p2Lblock == true)
{
move1();
p1Rcool = 0;
}
if(p1RDisp2R < 15 && p2Rblock == true)
{
move1();
p1Rcool = 0;
}
if(player1dir==1)
{
if(p1Rcool > 15)
{
p1punchRmoveX +=.25;
p1punchRmoveY = 1.5;
}
else if(p1Rcool == 15)
{
p1punchRmoveX = 0;
}
else
{
p1punchRmoveX += .25;
p1punchRmoveY = 1.5;
}
}
if(player1dir==3)
{
if(p1Rcool > 15)
{
p1punchRmoveX -=.25;
p1punchRmoveY = 1.5;
}
else if(p1Rcool == 15)
{
p1punchRmoveX = 0;
}
else
{
p1punchRmoveX -= .25;
p1punchRmoveY = 1.5;
}
}
if(player1dir==5)
{
if(p1Rcool > 15)
{
p1punchRmoveX -=.25;
p1punchRmoveY = -1.5;
}
else if(p1Rcool == 15)
{
p1punchRmoveX = 0;
}
else
{
p1punchRmoveX -= .25;
p1punchRmoveY = -1.5;
}
}
if(player1dir==7)
{
if(p1Rcool > 15)
{
p1punchRmoveX +=.25;
p1punchRmoveY = -1.5;
}
else if(p1Rcool == 15)
{
p1punchRmoveX = 0;
}
else
{
p1punchRmoveX += .25;
p1punchRmoveY = -1.5;
}
}
if(p1Rcool>=15)
{
fist1Rx+=p1punchRmoveX;
fist1Ry+=p1punchRmoveY;
}
else
{
fist1Rx-=p1punchRmoveX;
fist1Ry-=p1punchRmoveY;
}
}
function p1HookL()
{
//blocks
if(p1LDisp2L < 15 && p2Lblock == true)
{
move1();
p1Lcool = 0;
}
if(p1LDisp2R < 15 && p2Rblock == true)
{
move1();
p1Lcool = 0;
}
if(player1dir==1)
{
if(p1Lcool > 15)
{
p1punchLmoveX +=.25;
p1punchLmoveY = 1.5;
}
else if(p1Lcool == 15)
{
p1punchLmoveX = 0;
}
else
{
p1punchLmoveX += .25;
p1punchLmoveY = 1.5;
}
}
if(player1dir==3)
{
if(p1Lcool > 15)
{
p1punchLmoveX -=.25;
p1punchLmoveY = 1.5;
}
else if(p1Lcool == 15)
{
p1punchLmoveX = 0;
}
else
{
p1punchLmoveX -= .25;
p1punchLmoveY = 1.5;
}
}
if(player1dir==5)
{
if(p1Lcool > 15)
{
p1punchLmoveX -=.25;
p1punchLmoveY = -1.5;
}
else if(p1Lcool == 15)
{
p1punchLmoveX = 0;
}
else
{
p1punchLmoveX -= .25;
p1punchLmoveY = -1.5;
}
}
if(player1dir==7)
{
if(p1Lcool > 15)
{
p1punchLmoveX +=.25;
p1punchLmoveY = -1.5;
}
else if(p1Lcool == 15)
{
p1punchLmoveX = 0;
}
else
{
p1punchLmoveX += .25;
p1punchLmoveY = -1.5;
}
}
if(p1Lcool>=15)
{
fist1Lx+=p1punchLmoveX;
fist1Ly+=p1punchLmoveY;
}
else
{
fist1Lx-=p1punchLmoveX;
fist1Ly-=p1punchLmoveY;
}
}
function p2HookR()
{
//blocks
if(p1LDisp2R < 15 && p1Lblock == true)
{
move2();
p2Rcool = 0;
}
if(p1RDisp2R < 15 && p1Rblock == true)
{
move2();
p2Rcool = 0;
}
if(player2dir==1)
{
if(p2Rcool > 15)
{
p2punchRmoveX +=.25;
p2punchRmoveY = 1.5;
}
else if(p2Rcool == 15)
{
p2punchRmoveX = 0;
}
else
{
p2punchRmoveX += .25;
p2punchRmoveY = 1.5;
}
}
if(player2dir==3)
{
if(p2Rcool > 15)
{
p2punchRmoveX -=.25;
p2punchRmoveY = 1.5;
}
else if(p2Rcool == 15)
{
p2punchRmoveX = 0;
}
else
{
p2punchRmoveX -= .25;
p2punchRmoveY = 1.5;
}
}
if(player2dir==5)
{
if(p2Rcool > 15)
{
p2punchRmoveX -=.25;
p2punchRmoveY = -1.5;
}
else if(p2Rcool == 15)
{
p2punchRmoveX = 0;
}
else
{
p2punchRmoveX -= .25;
p2punchRmoveY = -1.5;
}
}
if(player2dir==7)
{
if(p2Rcool > 15)
{
p2punchRmoveX +=.25;
p2punchRmoveY = -1.5;
}
else if(p2Rcool == 15)
{
p2punchRmoveX = 0;
}
else
{
p2punchRmoveX += .25;
p2punchRmoveY = -1.5;
}
}
if(p2Rcool>=15)
{
fist2Rx+=p2punchRmoveX;
fist2Ry+=p2punchRmoveY;
}
else
{
fist2Rx-=p2punchRmoveX;
fist2Ry-=p2punchRmoveY;
}
}
function p2HookL()
{
//blocks
if(p1LDisp2L < 15 && p1Lblock == true)
{
move2();
p2Lcool = 0;
}
if(p1RDisp2L < 15 && p1Rblock == true)
{
move2();
p2Lcool = 0;
}
if(player2dir==1)
{
if(p2Lcool > 15)
{
p2punchLmoveX +=.25;
p2punchLmoveY = 1.5;
}
else if(p2Lcool == 15)
{
p2punchLmoveX = 0;
}
else
{
p2punchLmoveX += .25;
p2punchLmoveY = 1.5;
}
}
if(player2dir==3)
{
if(p2Lcool > 15)
{
p2punchLmoveX -=.25;
p2punchLmoveY = 1.5;
}
else if(p2Lcool == 15)
{
p2punchLmoveX = 0;
}
else
{
p2punchLmoveX -= .25;
p2punchLmoveY = 1.5;
}
}
if(player2dir==5)
{
if(p2Lcool > 15)
{
p2punchLmoveX -=.25;
p2punchLmoveY = -1.5;
}
else if(p2Lcool == 15)
{
p2punchLmoveX = 0;
}
else
{
p2punchLmoveX -= .25;
p2punchLmoveY = -1.5;
}
}
if(player2dir==7)
{
if(p2Lcool > 15)
{
p2punchLmoveX +=.25;
p2punchLmoveY = -1.5;
}
else if(p2Lcool == 15)
{
p2punchLmoveX = 0;
}
else
{
p2punchLmoveX += .25;
p2punchLmoveY = -1.5;
}
}
if(p2Lcool>=15)
{
fist2Lx+=p2punchLmoveX;
fist2Ly+=p2punchLmoveY;
}
else
{
fist2Lx-=p2punchLmoveX;
fist2Ly-=p2punchLmoveY;
}
}
function coachSaying()
{
if(sayingTime==49)
{
p1Coach = int(random(0,10));
}
textSize(15);
if(p1Coach==0)
{
text("GET HIM",100,100);
text("OUCH",300,400);
}
if(p1Coach==1)
{
text("ITS FOR THE BELT",100,100);
text("WIN FOR MOM",300,400);
}
if(p1Coach==2)
{
text("Owwww....",100,100);
text("AT LEAST GIVE HIM A CHANCE",270,400);
}
if(p1Coach==3)
{
text("BLOCK BLOCK",100,100);
text("POWER PUNCH",300,400);
}
if(p1Coach==4)
{
text("OUCH",100,100);
text("GET HIM",300,400);
}
if(p1Coach==5)
{
text("THROW IN THE TOWEL",100,100);
text("...",300,400);
}
if(p1Coach==6)
{
text("YIPPEE",100,100);
text("KNOCK EM OUT",300,400);
}
if(p1Coach==7)
{
text("HIT EM WITH THE ONE TWO",100,100);
text("WATCH OUT FOR THE ONE TWO",270,400);
}
if(p1Coach==8)
{
text("YOU GOT THIS",100,100);
text("BRING THE PAIN",300,400);
}
if(p1Coach==9)
{
text("IDK",100,100);
text("OKAY IMA FIGHT",300,400);
}
}