float x = 1;//knight x-axis float x1= 1;//samurai x-axis float y ;// Condition of injury area float y1;// Condition of injury area float cloudx1 =300; float cloudx2 =20; float cloudx3 =180; float wf1 = 200;//waterfall animation float wf11 = 240; float wf12 = 265; float wf2 = 195; float wf21 = 220; float wf22 = 250; float wf3 = 205; float wf31 = 230; float wf32 = 260; float wf33 = 275; float wf4 =200; float wf41=215; float wf42=235; float wf43=245; float wf44=265; float space=10; float shealth=-150;//samurai health float khealth=150;//knight health boolean kdamage = false;//damages cast by knight boolean sdamage =false;//damages cast by knight boolean kright = false; //knight movement boolean kleft = false; boolean sright= false; //samurai movement boolean sleft=false; boolean kup =false; //knight weapon boolean kdown =false; boolean kattack = false;//attack boolean sup =false;//samurai weapon boolean sdown = false; boolean sattack = false;//samurai attack int kweapon =0; int sweapon =0; int movement = 0; int movement1 =0; ////////////////////////////////// //////////player2///////////////// ////////////////////////////////// void player2() { //head noStroke(); fill(0, 0, 0); rect(290+x1, 140+sin(0.03*(frameCount))*3, 25, 5); fill(33, 150, 253); rect(290+x1, 145+sin(0.03*(frameCount))*3, 25, 5); fill(255, 224, 178); rect(290+x1, 150+sin(0.03*(frameCount))*3, 25, 20); fill(255, 183, 77); rect(290+x1, 150+sin(0.03*(frameCount))*3, 5, 5); rect(300+x1, 150+sin(0.03*(frameCount))*3, 5, 5); fill(255, 204, 128); rect(295+x1, 150+sin(0.03*(frameCount))*3, 5, 10); rect(305+x1, 150+sin(0.03*(frameCount))*3, 10, 20); //body fill(33, 150, 243); rect(295+x1, 170+sin(0.03*(frameCount))*3, 30, 115);//layer1 rect(290+x1, 175+sin(0.03*(frameCount))*3, 30, 110);//layer2 rect(325+x1, 225+5+sin(0.03*(frameCount))*3, 10,55);//layer3 //body detail fill(1, 87, 155); rect(315+x1, 170+sin(0.03*(frameCount))*3, 5, 15); rect(310+x1, 185+sin(0.03*(frameCount))*3, 5, 15); rect(305+x1, 200+sin(0.03*(frameCount))*3, 5, 15); rect(300+x1, 215+sin(0.03*(frameCount))*3, 5, 5); fill(60, 60, 60); rect(290+x1, 220+sin(0.03*(frameCount))*3, 35, 5); rect(290+x1, 225+sin(0.03*(frameCount))*3, 40, 5); } ///////////////////////////////// ///////////player1/////////////// ///////////////////////////////// void player1() { //left arm fill(219, 219, 219); rect(x+25, 180+sin(0.03*(frameCount))*3, 5, 20);//left arm layer1 fill(167, 167, 167); rect(x+25, 190+sin(0.03*(frameCount))*3, 5, 10);//left arm shade1 fill(219, 219, 219); rect(x+20, 185+sin(0.03*(frameCount))*3, 5, 20);//left arm layer2 fill(219, 219, 219); rect(x+15, 190+sin(0.03*(frameCount))*3, 5, 25);//left arm layer3 fill(219, 219, 219); rect(x+10, 195+sin(0.03*(frameCount))*3, 5, 20);//left arm layer3 fill(219, 219, 219); rect(x+5, 200+sin(0.03*(frameCount))*3, 5, 10);//left arm layer5 fill(219, 219, 219); rect(x+20, 205+sin(0.03*(frameCount))*3, 10, 15);//left hand fill(167, 167, 167); rect(x+20, 195+sin(0.03*(frameCount))*3, 5, 15);//left arm shade2 fill(167, 167, 167); rect(x+15, 200+sin(0.03*(frameCount))*3, 5, 5);//left arm shade3 fill(167, 167, 167); rect(x+25, 205+sin(0.03*(frameCount))*3, 5, 10);//left arm shade4 //body fill(176, 176, 176); rect(x+40, 140+sin(0.03*(frameCount))*3, 25, 25);//head fill(143, 143, 143); rect(x+55, 140+sin(0.03*(frameCount))*3, 5, 20);//head detail 1 rect(x+45, 145+sin(0.03*(frameCount))*3, 20, 5);//head detail 2 fill(193, 193, 193); rect(x+40, 165+sin(0.03*(frameCount))*3, 20, 5);//neck fill(255, 255, 255); rect(x+35, 170+sin(0.03*(frameCount))*3, 30, 80);//body layer1 fill(255, 255, 255); rect(x+30, 175+sin(0.03*(frameCount))*3, 35, 55);//body layer2 //cloth detail fill(255, 255, 255); rect(x+35, 230+sin(0.03*(frameCount))*3, 30, 50);//cloth fill(235, 235, 235); rect(x+35, 230+sin(0.03*(frameCount))*3, 5, 50);// cloth shade rect(x+30, 175+sin(0.03*(frameCount))*3, 5, 50);// body shade rect(x+35, 170+sin(0.03*(frameCount))*3, 5, 5);// body shade 2 rect(x+35, 210+sin(0.03*(frameCount))*3, 5, 20);// body shade 3 fill(129, 1, 1); rect(x+40, 195+sin(0.03*(frameCount))*3, 25, 5);//player 1 red cross 1 rect(x+55, 175+sin(0.03*(frameCount))*3, 5, 50);//player 1 red cross 2 fill(70, 37, 1); rect(x+30, 225+sin(0.03*(frameCount))*3, 35, 5);//belt } void movementControl(){ ////knight movement animation////// if (movement <0) {//reset when it = 0 movement = 30; } if (movement >30) {//reset movement = 0; } if (movement >=0 && movement <=6) {//movement*1 //left legs fill(219, 219, 219); rect(x+25, 230+sin(0.03*(frameCount))*3, 20, 25);//left leg layer1 fill(219, 219, 219); rect(x+20, 240+sin(0.03*(frameCount))*2, 20, 20);//left leg layer2//speed increased by 1.5 times fill(219, 219, 219); rect(x+15, 250+sin(0.03*(frameCount))*1, 20, 20);//left leg layer3//speed increased by 1.5 times fill(219, 219, 219); rect(x+10, 260, 20, 20);//left leg layer4//speed increased by 1.5 times fill(219, 219, 219); rect(x+5, 270, 20, 20);//left leg layer5// fill(219, 219, 219); rect(x+0, 285, 20, 15);//foot fill(167, 167, 167); rect(x+30, 260+sin(0.03*(frameCount))*2, 5, 11.5);//left leg shade1 rect(x+25, 270+sin(0.03*(frameCount))*1, 5, 11.5);//left leg shade2 rect(x+20, 280, 5, 10);//left leg shade3 rect(x+15, 285, 5, 15);//left leg shade4 //right legs fill(219, 219, 219); rect(x+55, 235+sin(0.03*(frameCount))*3, 15, 20);//right leg layer1 fill(219, 219, 219); rect(x+60, 240+sin(0.03*(frameCount))*2, 15, 20);//right leg layer2 fill(219, 219, 219); rect(x+65, 245+sin(0.03*(frameCount))*1, 15, 20);//right leg layer3 fill(219, 219, 219); rect(x+70, 255, 15, 40);//right leg layer4 fill(219, 219, 219); rect(x+75, 295, 10, 5);//right leg layer5 fill(167, 167, 167); rect(x+65, 260+sin(0.03*(frameCount))*2, 5, 6.5);//right leg shade1 rect(x+70, 265+sin(0.03*(frameCount))*1, 5, 31.5);//right leg shade2 } else if (movement >=7 && movement <=12) {//movement*2 //left legs fill(219, 219, 219); rect(x+25+0.83333, 230+sin(0.03*(frameCount))*3, 20, 25);//left leg layer1 fill(219, 219, 219); rect(x+20+1.25, 240+sin(0.03*(frameCount))*2, 20, 20);//left leg layer2 fill(219, 219, 219); rect(x+15+1.875, 250+sin(0.03*(frameCount))*1, 20, 20);//left leg layer3 fill(219, 219, 219); rect(x+10+2.8125, 260, 20, 20);//left leg layer4 fill(219, 219, 219); rect(x+5+2.8125, 270, 20, 20);//left leg layer5 fill(219, 219, 219); rect(x+0+2.8125, 285, 20, 15);//foot fill(167, 167, 167); rect(x+30+2.8125, 260+sin(0.03*(frameCount))*2, 5, 11.5);//left leg shade1 rect(x+25+2.8125, 270+sin(0.03*(frameCount))*1, 5, 11.5);//left leg shade2 rect(x+20+2.8125, 280, 5, 10);//left leg shade3 rect(x+15+2.8125, 285, 5, 15);//left leg shade4 //right legs fill(219, 219, 219); rect(x+55+0.75, 235+sin(0.03*(frameCount))*3, 15, 20);//right leg layer1 fill(219, 219, 219); rect(x+60+0.75, 240+sin(0.03*(frameCount))*2, 15, 20);//right leg layer2 fill(219, 219, 219); rect(x+65+0.75, 245+sin(0.03*(frameCount))*1, 15, 20);//right leg layer3 fill(219, 219, 219); rect(x+70+0.75, 255, 15, 40);//right leg layer4 fill(219, 219, 219); rect(x+75+0.75, 295, 10, 5);//right leg layer5 fill(167, 167, 167); rect(x+65+0.75, 260+sin(0.03*(frameCount))*2, 5, 6.5);//right leg shade1 rect(x+70+0.75, 265+sin(0.03*(frameCount))*1, 5, 31.5);//right leg shade2 } else if (movement >=13 && movement <=18) {//movement*3 //left legs fill(219, 219, 219); rect(x+25+0.83333*2, 230+sin(0.03*(frameCount))*3, 20, 25);//left leg layer1 fill(219, 219, 219); rect(x+20+1.25*2, 240+sin(0.03*(frameCount))*2, 20, 20);//left leg layer2 fill(219, 219, 219); rect(x+15+1.875*2, 250+sin(0.03*(frameCount))*1, 20, 20);//left leg layer3 fill(219, 219, 219); rect(x+10+2.8125*2, 260, 20, 20);//left leg layer4 fill(219, 219, 219); rect(x+5+2.8125*2, 270, 20, 20);//left leg layer5 fill(219, 219, 219); rect(x+0+2.8125*2, 285, 20, 15);//foot fill(167, 167, 167); rect(x+30+2.8125*2, 260+sin(0.03*(frameCount))*2, 5, 11.5);//left leg shade1 rect(x+25+2.8125*2, 270+sin(0.03*(frameCount))*1, 5, 11.5);//left leg shade2 rect(x+20+2.8125*2, 280, 5, 10);//left leg shade3 rect(x+15+2.8125*2, 285, 5, 15);//left leg shade4 //right legs fill(219, 219, 219); rect(x+55+0.75*2, 235+sin(0.03*(frameCount))*3, 15, 20);//right leg layer1 fill(219, 219, 219); rect(x+60+0.75*2, 240+sin(0.03*(frameCount))*2, 15, 20);//right leg layer2 fill(219, 219, 219); rect(x+65+0.75*2, 245+sin(0.03*(frameCount))*1, 15, 20);//right leg layer3 fill(219, 219, 219); rect(x+70+0.75*2, 255, 15, 40);//right leg layer4 fill(219, 219, 219); rect(x+75+0.75*2, 295, 10, 5);//right leg layer5 fill(167, 167, 167); rect(x+65+0.75*2, 260+sin(0.03*(frameCount))*2, 5, 6.5);//right leg shade1 rect(x+70+0.75*2, 265+sin(0.03*(frameCount))*1, 5, 31.5);//right leg shade2 } else if (movement >=19 && movement <=24) {//movement*2 //left legs fill(219, 219, 219); rect(x+25+0.83333*2, 230+sin(0.03*(frameCount))*3, 20, 25);//left leg layer1 fill(219, 219, 219); rect(x+20+1.25, 240+sin(0.03*(frameCount))*2, 20, 20);//left leg layer2 fill(219, 219, 219); rect(x+15+1.875, 250+sin(0.03*(frameCount))*1, 20, 20);//left leg layer3 fill(219, 219, 219); rect(x+10+2.8125, 260, 20, 20);//left leg layer4 fill(219, 219, 219); rect(x+5+2.8125, 270, 20, 20);//left leg layer5 fill(219, 219, 219); rect(x+0+2.8125, 285, 20, 15);//foot fill(167, 167, 167); rect(x+30+2.8125, 260+sin(0.03*(frameCount))*2, 5, 11.5);//left leg shade1 rect(x+25+2.8125, 270+sin(0.03*(frameCount))*1, 5, 11.5);//left leg shade2 rect(x+20+2.8125, 280, 5, 10);//left leg shade3 rect(x+15+2.8125, 285, 5, 15);//left leg shade4 //right legs fill(219, 219, 219); rect(x+55+0.75, 235+sin(0.03*(frameCount))*3, 15, 20);//right leg layer1 fill(219, 219, 219); rect(x+60+0.75, 240+sin(0.03*(frameCount))*2, 15, 20);//right leg layer2 fill(219, 219, 219); rect(x+65+0.75, 245+sin(0.03*(frameCount))*1, 15, 20);//right leg layer3 fill(219, 219, 219); rect(x+70+0.75, 255, 15, 40);//right leg layer4 fill(219, 219, 219); rect(x+75+0.75, 295, 10, 5);//right leg layer5 fill(167, 167, 167); rect(x+65+0.75, 260+sin(0.03*(frameCount))*2, 5, 6.5);//right leg shade1 rect(x+70+0.75, 265+sin(0.03*(frameCount))*1, 5, 31.5);//right leg shade2 } else if (movement >=25 && movement <=30) {//movement*1 //left legs fill(219, 219, 219); rect(x+25, 230+sin(0.03*(frameCount))*3, 20, 25);//left leg layer1 fill(219, 219, 219); rect(x+20, 240+sin(0.03*(frameCount))*2, 20, 20);//left leg layer2 fill(219, 219, 219); rect(x+15, 250+sin(0.03*(frameCount))*1, 20, 20);//left leg layer3 fill(219, 219, 219); rect(x+10, 260, 20, 20);//left leg layer4 fill(219, 219, 219); rect(x+5, 270, 20, 20);//left leg layer5 fill(219, 219, 219); rect(x+0, 285, 20, 15);//foot fill(167, 167, 167); rect(x+30, 260+sin(0.03*(frameCount))*2, 5, 11.5);//left leg shade1 rect(x+25, 270+sin(0.03*(frameCount))*1, 5, 11.5);//left leg shade2 rect(x+20, 280, 5, 10);//left leg shade3 rect(x+15, 285, 5, 15);//left leg shade4 //right legs fill(219, 219, 219); rect(x+55, 235+sin(0.03*(frameCount))*3, 15, 20);//right leg layer1 fill(219, 219, 219); rect(x+60, 240+sin(0.03*(frameCount))*2, 15, 20);//right leg layer2 fill(219, 219, 219); rect(x+65, 245+sin(0.03*(frameCount))*1, 15, 20);//right leg layer3 fill(219, 219, 219); rect(x+70, 255, 15, 40);//right leg layer4 fill(219, 219, 219); rect(x+75, 295, 10, 5);//right leg layer5 fill(167, 167, 167); rect(x+65, 260+sin(0.03*(frameCount))*2, 5, 6.5);//right leg shade1 rect(x+70, 265+sin(0.03*(frameCount))*1, 5, 31.5);//right leg shade2 } ////sumurai movement animation////// if (movement1 <0) {//reset when it = 0 movement1 = 30; } if (movement1 >30) {//reset movement1 = 0; } if (movement1 >=0 && movement1 <=6) {//movement //left leg fill(97, 97, 97); rect(265+x1, 275, 15, 25);//foot fill(33, 150, 243); rect(285+x1, 235+sin(0.03*(frameCount))*3, 5, 50);//layer1 rect(280+x1, 240+sin(0.03*(frameCount))*3, 5, 45);//layer2 rect(275+x1, 245+sin(0.03*(frameCount))*3, 5, 40);//layer3 rect(270+x1, 250+sin(0.03*(frameCount))*3, 5, 35);//layer4 rect(265+x1, 260+sin(0.03*(frameCount))*3, 5, 25);//layer5 //right leg fill(97, 97, 97); rect(350+x1, 275, 15, 25);//foot fill(33, 150, 243); rect(325+x1, 230+sin(0.03*(frameCount))*3, 5, 55);//layer1 rect(330+x1, 230+sin(0.03*(frameCount))*3, 5, 55);//layer2 rect(335+x1, 235+sin(0.03*(frameCount))*3, 5, 50);//layer3 rect(340+x1, 240+sin(0.03*(frameCount))*3, 5, 45);//layer4 rect(345+x1, 245+sin(0.03*(frameCount))*3, 5, 40);//layer5 rect(350+x1, 250+sin(0.03*(frameCount))*3, 5, 35);//layer6 rect(355+x1, 255+sin(0.03*(frameCount))*3, 5, 30);//layer7 rect(360+x1, 265+sin(0.03*(frameCount))*3, 5, 20);//layer8 } else if (movement1 >=7 && movement1 <=12) {//movement*2 //left leg fill(97, 97, 97); rect(265+x1, 275, 15, 25);//foot fill(33, 150, 243); rect(285+x1, 235+sin(0.03*(frameCount))*3, 5, 50);//layer1 rect(280+x1, 240+sin(0.03*(frameCount))*3, 5, 45);//layer2 rect(275+x1, 245+sin(0.03*(frameCount))*3, 5, 40);//layer3 rect(270+x1, 250+sin(0.03*(frameCount))*3, 5, 35);//layer4 rect(265+x1, 260+sin(0.03*(frameCount))*3, 5, 25);//layer5 //right leg fill(97, 97, 97); rect(350+x1, 275, 15, 25);//foot fill(33, 150, 243); rect(325+x1+0.83333, 230+sin(0.03*(frameCount))*3, 5, 55);//layer1 rect(330+x1, 230+sin(0.03*(frameCount))*3, 5, 55);//layer2 rect(335+x1, 235+sin(0.03*(frameCount))*3, 5, 50);//layer3 rect(340+x1, 240+sin(0.03*(frameCount))*3, 5, 45);//layer4 rect(345+x1, 245+sin(0.03*(frameCount))*3, 5, 40);//layer5 rect(350+x1, 250+sin(0.03*(frameCount))*3, 5, 35);//layer6 rect(355+x1, 255+sin(0.03*(frameCount))*3, 5, 30);//layer7 rect(360+x1, 265+sin(0.03*(frameCount))*3, 5, 20);//layer8 } else if (movement1 >=13 && movement1 <=18) {//movement*3 //left leg fill(97, 97, 97); rect(265+x1, 275, 15, 25);//foot fill(33, 150, 243); rect(285+x1, 235+sin(0.03*(frameCount))*3, 5, 50);//layer1 rect(280+x1, 240+sin(0.03*(frameCount))*3, 5, 45);//layer2 rect(275+x1, 245+sin(0.03*(frameCount))*3, 5, 40);//layer3 rect(270+x1, 250+sin(0.03*(frameCount))*3, 5, 35);//layer4 rect(265+x1, 260+sin(0.03*(frameCount))*3, 5, 25);//layer5 //right leg fill(97, 97, 97); rect(350+x1, 275, 15, 25);//foot fill(33, 150, 243); rect(325+x1+1*2, 230+sin(0.03*(frameCount))*3, 5, 55);//layer1 rect(330+x1+1*2, 230+sin(0.03*(frameCount))*3, 5, 55);//layer2 rect(335+x1+1*2, 235+sin(0.03*(frameCount))*3, 5, 50);//layer3 rect(340+x1+1*2, 240+sin(0.03*(frameCount))*3, 5, 45);//layer4 rect(345+x1+1*2, 245+sin(0.03*(frameCount))*3, 5, 40);//layer5 rect(350+x1+1*2, 250+sin(0.03*(frameCount))*3, 5, 35);//layer6 rect(355+x1+1*2, 255+sin(0.03*(frameCount))*3, 5, 30);//layer7 rect(360+x1+1*2, 265+sin(0.03*(frameCount))*3, 5, 20);//layer8 } else if (movement1 >=19 && movement1 <=24) {//movement*2 //left leg fill(97, 97, 97); rect(265+x1, 275, 15, 25);//foot fill(33, 150, 243); rect(285+x1, 235+sin(0.03*(frameCount))*3, 5, 50);//layer1 rect(280+x1, 240+sin(0.03*(frameCount))*3, 5, 45);//layer2 rect(275+x1, 245+sin(0.03*(frameCount))*3, 5, 40);//layer3 rect(270+x1, 250+sin(0.03*(frameCount))*3, 5, 35);//layer4 rect(265+x1, 260+sin(0.03*(frameCount))*3, 5, 25);//layer5 //right leg fill(97, 97, 97); rect(350+x1, 275, 15, 25);//foot fill(33, 150, 243); rect(325+x1+0.83333, 230+sin(0.03*(frameCount))*3, 5, 55);//layer1 rect(330+x1+0.83333, 230+sin(0.03*(frameCount))*3, 5, 55);//layer2 rect(335+x1+0.83333, 235+sin(0.03*(frameCount))*3, 5, 50);//layer3 rect(340+x1+0.83333, 240+sin(0.03*(frameCount))*3, 5, 45);//layer4 rect(345+x1+0.83333, 245+sin(0.03*(frameCount))*3, 5, 40);//layer5 rect(350+x1+0.83333, 250+sin(0.03*(frameCount))*3, 5, 35);//layer6 rect(355+x1+0.83333, 255+sin(0.03*(frameCount))*3, 5, 30);//layer7 rect(360+x1+0.83333, 265+sin(0.03*(frameCount))*3, 5, 20);//layer8 } else if (movement1 >=25 && movement1 <=30) {//movement //left leg fill(97, 97, 97); rect(265+x1, 275, 15, 25);//foot fill(33, 150, 243); rect(285+x1, 235+sin(0.03*(frameCount))*3, 5, 50);//layer1 rect(280+x1, 240+sin(0.03*(frameCount))*3, 5, 45);//layer2 rect(275+x1, 245+sin(0.03*(frameCount))*3, 5, 40);//layer3 rect(270+x1, 250+sin(0.03*(frameCount))*3, 5, 35);//layer4 rect(265+x1, 260+sin(0.03*(frameCount))*3, 5, 25);//layer5 //right leg fill(97, 97, 97); rect(350+x1, 275, 15, 25);//foot fill(33, 150, 243); rect(325+x1, 230+sin(0.03*(frameCount))*3, 5, 55);//layer1 rect(330+x1, 230+sin(0.03*(frameCount))*3, 5, 55);//layer2 rect(335+x1, 235+sin(0.03*(frameCount))*3, 5, 50);//layer3 rect(340+x1, 240+sin(0.03*(frameCount))*3, 5, 45);//layer4 rect(345+x1, 245+sin(0.03*(frameCount))*3, 5, 40);//layer5 rect(350+x1, 250+sin(0.03*(frameCount))*3, 5, 35);//layer6 rect(355+x1, 255+sin(0.03*(frameCount))*3, 5, 30);//layer7 rect(360+x1, 265+sin(0.03*(frameCount))*3, 5, 20);//layer8 } } void samuraiWin(){//Victory screen if ( khealth <= 0){ println("SAMURAI WIN!!!!!!!!!!"); /////G/////// fill(0, 0, 0); rect(0, 0, 400, 400); fill(255, 255, 255); rect(75, 90, 40, 10); rect(70, 95, 10, 55); rect(110, 95, 10, 10); rect(115, 105, 5, 5); rect(75, 145, 40, 10); rect(110, 130, 10, 20); rect(110, 125, 15, 10); rect(105, 120, 10, 10); rect(100, 120, 5, 5); /////////A//////// rect(130, 90, 10, 60); rect(130, 90, 45, 5); rect(170, 90, 10, 60); rect(130, 115, 45, 5); rect(140, 120, 5, 5); rect(165, 120, 5, 5); rect(130, 150, 5, 5); rect(175, 150, 5, 5); ////////M///////// rect(190, 90, 5, 65); rect(195, 95, 5, 60); rect(200, 105, 5, 20); rect(205, 115, 5, 20); rect(210, 125, 5, 20); rect(215, 135, 5, 20); rect(220, 125, 5, 20); rect(225, 115, 5, 20); rect(230, 105, 5, 20); rect(235, 95, 5, 60); rect(240, 90, 5, 65); ////////E////////// rect(255, 90, 55, 5); rect(255, 95, 45, 5); rect(255, 90, 10, 65); rect(255, 120, 50, 5); rect(255, 145, 45, 5); rect(255, 150, 55, 5); ////////o////////// rect(80, 165, 35, 10); rect(75, 170, 10, 10); rect(70, 175, 5, 15); rect(65, 190, 5, 25); rect(70, 215, 5, 15); rect(75, 225, 10, 10); rect(80, 230, 35, 10); rect(110, 225, 10, 10); rect(120, 215, 5, 15); rect(125, 190, 5, 25); rect(120, 175, 5, 15); rect(110, 170, 10, 10); ////////v////////// rect(130, 165, 5, 5); rect(135, 165, 10, 20); rect(140, 175, 10, 25); rect(145, 195, 20, 30); rect(150, 225, 10, 15); rect(160, 175, 10, 25); rect(165, 165, 10, 20); rect(175, 165, 5, 5); ////////E////////// rect(255-65, 90+80, 55, 5); rect(255-65, 95+80, 45, 5); rect(255-65, 90+80, 10, 65); rect(255-65, 120+80, 50, 5); rect(255-65, 145+80, 45, 5); rect(255-65, 150+80, 55, 5); ///////R/////////// rect(255, 165, 45, 5); rect(255, 165, 10, 70); rect(255, 235, 5, 5); rect(295, 165, 5, 10); rect(300, 170, 5, 10); rect(305, 175, 5, 15); rect(300, 190, 5, 10); rect(295, 195, 5, 10); rect(255, 200, 45, 5); rect(255, 205, 35, 5); rect(280, 210, 15, 5); rect(285, 215, 15, 5); rect(290, 220, 15, 5); rect(295, 225, 15, 5); rect(300, 230, 15, 5); rect(315, 235, 5, 5);} } void knightWin(){//Victory screen if ( shealth >=0){ println("KNIGHT WIN!!!!!!!!!!!"); /////G/////// fill(0, 0, 0); rect(0, 0, 400, 400); fill(255, 255, 255); rect(75, 90, 40, 10); rect(70, 95, 10, 55); rect(110, 95, 10, 10); rect(115, 105, 5, 5); rect(75, 145, 40, 10); rect(110, 130, 10, 20); rect(110, 125, 15, 10); rect(105, 120, 10, 10); rect(100, 120, 5, 5); /////////A//////// rect(130, 90, 10, 60); rect(130, 90, 45, 5); rect(170, 90, 10, 60); rect(130, 115, 45, 5); rect(140, 120, 5, 5); rect(165, 120, 5, 5); rect(130, 150, 5, 5); rect(175, 150, 5, 5); ////////M///////// rect(190, 90, 5, 65); rect(195, 95, 5, 60); rect(200, 105, 5, 20); rect(205, 115, 5, 20); rect(210, 125, 5, 20); rect(215, 135, 5, 20); rect(220, 125, 5, 20); rect(225, 115, 5, 20); rect(230, 105, 5, 20); rect(235, 95, 5, 60); rect(240, 90, 5, 65); ////////E////////// rect(255, 90, 55, 5); rect(255, 95, 45, 5); rect(255, 90, 10, 65); rect(255, 120, 50, 5); rect(255, 145, 45, 5); rect(255, 150, 55, 5); ////////o////////// rect(80, 165, 35, 10); rect(75, 170, 10, 10); rect(70, 175, 5, 15); rect(65, 190, 5, 25); rect(70, 215, 5, 15); rect(75, 225, 10, 10); rect(80, 230, 35, 10); rect(110, 225, 10, 10); rect(120, 215, 5, 15); rect(125, 190, 5, 25); rect(120, 175, 5, 15); rect(110, 170, 10, 10); ////////v////////// rect(130, 165, 5, 5); rect(135, 165, 10, 20); rect(140, 175, 10, 25); rect(145, 195, 20, 30); rect(150, 225, 10, 15); rect(160, 175, 10, 25); rect(165, 165, 10, 20); rect(175, 165, 5, 5); ////////E////////// rect(255-65, 90+80, 55, 5); rect(255-65, 95+80, 45, 5); rect(255-65, 90+80, 10, 65); rect(255-65, 120+80, 50, 5); rect(255-65, 145+80, 45, 5); rect(255-65, 150+80, 55, 5); ///////R/////////// rect(255, 165, 45, 5); rect(255, 165, 10, 70); rect(255, 235, 5, 5); rect(295, 165, 5, 10); rect(300, 170, 5, 10); rect(305, 175, 5, 15); rect(300, 190, 5, 10); rect(295, 195, 5, 10); rect(255, 200, 45, 5); rect(255, 205, 35, 5); rect(280, 210, 15, 5); rect(285, 215, 15, 5); rect(290, 220, 15, 5); rect(295, 225, 15, 5); rect(300, 230, 15, 5); rect(315, 235, 5, 5);} } void walldetail() { fill(108, 108, 108); for (int wy = 295; wy >=235; wy += -15) { rect(0, wy, 400, 5); } for (int wx1 = 0; wx1 <=400; wx1 += 20) { rect(wx1, 280, 5, 20); } for (int wx1 = 10; wx1 <=400; wx1 += 20) { rect(wx1, 265, 5, 20); } for (int wx1 = 0; wx1 <=400; wx1 += 20) { rect(wx1, 250, 5, 20); } for (int wx1 = 10; wx1 <=400; wx1 += 20) { rect(wx1, 235, 5, 20); } fill(234, 234, 234); for (int x = 5; x <= 400; x +=10) { rect(x, 135, 5, 5); } fill(55, 71, 79); for (int x = 10; x <= 400; x+= 20) { rect(x, 115, 5, 5); } for (int x = 15; x <= 400; x+= 20) { rect(x, 120, 5, 5); } for (int x = 20; x <= 400; x+= 20) { rect(x, 125, 5, 5); } } //////////background animation\\\\\\\\\\ void waterfall() { noStroke(); fill(225, 245, 254); rect(190, 190, 20, 95); fill(255, 255, 255); rect(190, wf1, 5, 25);//waterfall 1 rect(190, wf11, 5, 5); rect(190, wf12, 5, 15); rect(195, wf2, 5, 10);//waterfall 2 rect(195, wf21, 5, 15); rect(195, wf22, 5, 15); rect(200, wf3, 5, 10);//waterfall 3 rect(200, wf31, 5, 15); rect(200, wf32, 5, 10); rect(200, wf33, 5, 5); rect(205, wf4, 5, 5);//waterfall 4 rect(205, wf41, 5, 15); rect(205, wf42, 5, 5); rect(205, wf43, 5, 10); rect(205, wf44, 5, 15); wf1=wf1+1; wf11=wf11+1; wf12=wf12+1; wf2=wf2+1.5; wf21=wf21+1.5; wf22=wf22+1.5; wf3=wf3+0.75; wf31=wf31+0.75; wf32=wf32+0.75; wf33=wf33+0.75; wf4=wf4+1.6; wf41=wf41+1.6; wf42=wf42+1.6; wf43=wf43+1.6; wf44=wf44+1.6; } void cloud() { noStroke(); fill(255, 255, 255, 200); rect(cloudx1, 50, 90, 30);///cloud 1 rect(cloudx2, 10, 60, 20);///cloud2 rect(cloudx3, 30, 70, 34);///cloud3 cloudx1=cloudx1-0.1; cloudx2=cloudx2-0.15; cloudx3=cloudx3-0.2; } ////////////////////////////////////////// void setup() { size(400, 400); println("The Knight use W, A, S, D to control the movement and weapon position, E-key attack."); println("The warrior uses the arrow keys to control the movement and weapon position, and the space attack."); println("The weapon will not cause damage if the horizntal position is the same"); } void draw() { background(100); /////////////////////////////// //////////condition//////////// /////////////////////////////// /////////Condition that triggers damage if (y == y1) { kdamage=false; sdamage=false; } if (kattack==false) { kdamage=false; } else if ((x+130)>= (280+x1) && y != y1 && kattack==true) {//condition for damage caused by player's NORMAL attack kdamage=true; } if (sattack==false) { sdamage=false; } else if ((x+130)>= (280+x1) && y != y1&& sattack==true) {//condition for damage caused by player's NORMAL attack sdamage=true; } //////////////health bar///////////// if(kdamage == false){ shealth=shealth+0; }else if (kdamage == true){ shealth=shealth+1; } if(sdamage== false){ khealth=khealth+0; } if(sdamage==true){ khealth=khealth-1; } //waterfall// if ( wf1>=280) { wf1 = ( wf1-1) - 90; } if ( wf11>=280) { wf11=( wf11-1)-90; } if ( wf12>=280) { wf12= ( wf12-1)-90; } if ( wf2 >=280) { wf2 = (wf2-1.2)-90; } if ( wf21>=280) { wf21 = (wf21 -1.2)-90; } if (wf22 >=280) { wf22 = ( wf22-1.2)-90; } if (wf3 >=280) { wf3 = ( wf3 -1)-90; } if (wf31 >=280) { wf31 = ( wf31 -1)-90; } if (wf32 >=280) { wf32 = ( wf32 -1)-90; } if (wf33 >=280) { wf33 = ( wf33 -1)-90; } if (wf4 >=280) { wf4 = ( wf4 -1)-90; } if (wf41 >=280) { wf41 = ( wf41 -1)-90; } if (wf42 >=280) { wf42 = ( wf42 -1)-90; } if (wf43 >=280) { wf43 = ( wf43 -1)-90; } if (wf4 >=280) { wf44 = ( wf44 -1)-90; } ///////////cloud reset///////////////////// if (cloudx1 <= -90) { cloudx1 = (cloudx1-0.1)+490; } if (cloudx2 <= -60) { cloudx2 = (cloudx2-0.15)+460; } if (cloudx3 <= -70) { cloudx3 = (cloudx3-0.2)+470; } //////////////control////////////////// /////////////////////////////////////// if (kup) {//knight weapon movement kweapon=kweapon+1; } if (kdown) { kweapon=kweapon-1; } if (kright) {//knight movement x=x+2; movement ++; } else if (kleft) { x=x-2; movement --; } /////////////////////////////////////////// if (sright) {//samurai movement x1=x1+2; movement1++; } if (sleft) { x1=x1-2; movement1--; } if (sup) { sweapon=sweapon+1; } if (sdown) { sweapon=sweapon-1; } ////////////////////////////////////////////////////////////////////////////// //////////////////////////////////////background/////////////////////////////// /////////////////////////////////////////////////////////////////////////////// noStroke(); fill(160, 224, 255); rect(0, 0, 400, 400); cloud(); ///wall/// fill(238, 238, 238); rect(0, 110, 400, 400); fill(114, 82, 67); rect(0, 130, 400, 15);//edge of roof fill(37, 50, 50); rect(0, 110, 400, 20);//roofbrick fill(114, 82, 67); rect(0, 105, 400, 5);//roof fill(0, 0, 0, 100);//wall shade rect(0, 145, 400, 10); fill(0, 0, 0, 30);//wall shade rect(0, 155, 400, 20); fill(0, 0, 0, 40);//wall shade rect(0, 250, 400, 50); fill(0, 0, 0, 40);//wall shade rect(0, 275, 400, 25); ///fountain/// fill(97, 97, 97); rect(195, 160, 10, 5); rect(190, 160, 5, 10); rect(205, 160, 5, 10); rect(185, 165, 5, 10); rect(210, 165, 5, 10); rect(180, 170, 5, 10); rect(215, 170, 5, 10); rect(175, 175, 5, 20); rect(170, 180, 5, 10); rect(220, 175, 5, 20); rect(225, 180, 5, 10); rect(180, 190, 5, 10); rect(215, 190, 5, 10); rect(185, 195, 5, 10); rect(210, 195, 5, 10); rect(190, 175, 5, 5); rect(205, 175, 5, 5); rect(195, 180, 10, 5); rect(190, 185, 5, 5); rect(205, 185, 5, 5); walldetail(); ///fountain detail2/// waterfall(); fill(65, 65, 65); rect(175, 280, 50, 5); rect(170, 285, 60, 5); rect(160, 290, 80, 5); rect(155, 295, 90, 5); ///ground fill(160, 120, 68); rect(0, 300, 400, 100); fill(139, 104, 58); rect(0, 320, 400, 100); fill(118, 89, 49); rect(0, 345, 400, 100); fill(98, 73, 41); rect(0, 375, 400, 100); fill(0,84,108); rect(width/2-35,350,70,60); fill(0,108,139); rect(width/2-25,360,50,60); fill(0,140,180); rect(width/2-15,370,30,60); movementControl(); ////////////////////////////////// /////////////health/////////////// ////////////////////////////////// fill(255, 209, 23); rect(15, 375, khealth, 10); rect(385, 375, shealth, 10); rectMode(CENTER); fill(255,0,0); rect(15+khealth, 380, 5, random(20)); rect((385+shealth) , 380, 5, random(20)); rectMode(CORNER); ///////////////////////////////// /////////player1///////////////// ///////////////////////////////// player1(); ///////////////////////////////// /////////player2///////////////// ///////////////////////////////// player2(); ////knight weapon animation///// if (kweapon >=-15&& kweapon <=15 && kattack == true) {//extend arm when player1 attack //right hand controlled by key y = 180; //hitbox fill(219, 219, 219); rect(x+65, 175+sin(0.03*(frameCount))*3, 5+space, 30);//right arm layer1 fill(219, 219, 219); rect(x+70+space, 185+sin(0.03*(frameCount))*3-10, 10, 25);//right arm layer2 fill(167, 167, 167); rect(x+75+space, 205+sin(0.03*(frameCount))*3-10, 5, 5);//right arm shade1 fill(219, 219, 219); rect(x+80+space, 175+sin(0.03*(frameCount))*3, 5, 20);//right arm layer3 fill(167, 167, 167); rect(x+80+space, 190+sin(0.03*(frameCount))*3-10, 5, 15);//right arm shade2 fill(219, 219, 219); rect(x+85+space, 175+sin(0.03*(frameCount))*3, 5, 20);//hand fill(167, 167, 167); rect(x+85+space, 180+sin(0.03*(frameCount))*3, 5, 15);// hand shade //sowrd fill(0, 0, 0); rect(x+90+space, 175+sin(0.03*(frameCount))*3, 10, 20);//handle fill(180, 180, 180); rect(x+100+space, 180+sin(0.03*(frameCount))*3, 45, 5);//sword } else if (kweapon >= 15 && kattack == true) {// attack above y=165; fill(219, 219, 219); rect(x+65, -10+175+sin(0.03*(frameCount))*3, 5+space, 30);//right arm layer1 fill(219, 219, 219); rect(x+70+space, -15+185+sin(0.03*(frameCount))*3-10, 10, 25);//right arm layer2 fill(167, 167, 167); rect(x+75+space, -15+205+sin(0.03*(frameCount))*3-10, 5, 5);//right arm shade1 fill(219, 219, 219); rect(x+80+space, -15+175+sin(0.03*(frameCount))*3, 5, 20);//right arm layer3 fill(167, 167, 167); rect(x+80+space, -15+190+sin(0.03*(frameCount))*3-10, 5, 15);//right arm shade2 fill(219, 219, 219); rect(x+85+space, -15+175+sin(0.03*(frameCount))*3, 5, 20);//hand fill(167, 167, 167); rect(x+85+space, -15+180+sin(0.03*(frameCount))*3, 5, 15);// hand shade //sowrd fill(0, 0, 0); rect(x+90+space, -15+175+sin(0.03*(frameCount))*3, 10, 20);//handle fill(180, 180, 180); rect(x+100+space, -15+180+sin(0.03*(frameCount))*3, 45, 5);//sword } else if (kweapon <=-15 && kattack == true) {//attack below y=195; fill(219, 219, 219); rect(x+65, 10+175+sin(0.03*(frameCount))*3, 5+space, 30);//right arm layer1 fill(219, 219, 219); rect(x+70+space, 15+185+sin(0.03*(frameCount))*3-10, 10, 25);//right arm layer2 fill(167, 167, 167); rect(x+75+space, 15+205+sin(0.03*(frameCount))*3-10, 5, 5);//right arm shade1 fill(219, 219, 219); rect(x+80+space, 15+175+sin(0.03*(frameCount))*3, 5, 20);//right arm layer3 fill(167, 167, 167); rect(x+80+space, 15+190+sin(0.03*(frameCount))*3-10, 5, 15);//right arm shade2 fill(219, 219, 219); rect(x+85+space, 15+175+sin(0.03*(frameCount))*3, 5, 20);//hand fill(167, 167, 167); rect(x+85+space, 15+180+sin(0.03*(frameCount))*3, 5, 15);// hand shade //sword fill(0, 0, 0); rect(x+90+space, 15+175+sin(0.03*(frameCount))*3, 10, 20);//handle fill(180, 180, 180); rect(x+100+space, 15+180+sin(0.03*(frameCount))*3, 45, 5);//sword } else if (kweapon >= 15 ) {//move up y=165; fill(219, 219, 219); rect(x+65, -10+175+sin(0.03*(frameCount))*3, 5, 30);//right arm layer1 fill(219, 219, 219); rect(x+70, -15+185+sin(0.03*(frameCount))*3, 10, 25);//right arm layer2 fill(167, 167, 167); rect(x+75, -15+205+sin(0.03*(frameCount))*3, 5, 5);//right arm shade1 fill(219, 219, 219); rect(x+80, -15+175+sin(0.03*(frameCount))*3, 5, 30);//right arm layer3 fill(167, 167, 167); rect(x+80, -15+190+sin(0.03*(frameCount))*3, 5, 15);//right arm shade2 fill(219, 219, 219); rect(x+85, -15+175+sin(0.03*(frameCount))*3, 5, 20);//hand fill(167, 167, 167); rect(x+85, -15+180+sin(0.03*(frameCount))*3, 5, 15);// hand shade //sowrd fill(0, 0, 0); rect(x+90, -15+175+sin(0.03*(frameCount))*3, 10, 20);//handle fill(180, 180, 180); rect(x+100, -15+180+sin(0.03*(frameCount))*3, 45, 5);//sword } else if (kweapon <=-15 ) {//move down y=195; fill(219, 219, 219); rect(x+65, 10+175+sin(0.03*(frameCount))*3, 5, 30);//right arm layer1 fill(219, 219, 219); rect(x+70, 15+185+sin(0.03*(frameCount))*3, 10, 25);//right arm layer2 fill(167, 167, 167); rect(x+75, 15+205+sin(0.03*(frameCount))*3, 5, 5);//right arm shade1 fill(219, 219, 219); rect(x+80, 15+175+sin(0.03*(frameCount))*3, 5, 30);//right arm layer3 fill(167, 167, 167); rect(x+80, 15+190+sin(0.03*(frameCount))*3, 5, 15);//right arm shade2 fill(219, 219, 219); rect(x+85, 15+175+sin(0.03*(frameCount))*3, 5, 20);//hand fill(167, 167, 167); rect(x+85, 15+180+sin(0.03*(frameCount))*3, 5, 15);// hand shade //sowrd fill(0, 0, 0); rect(x+90, 15+175+sin(0.03*(frameCount))*3, 10, 20);//handle fill(180, 180, 180); rect(x+100, 15+180+sin(0.03*(frameCount))*3, 45, 5);//sword } else if (kweapon >=-15&& kweapon <=15 ) {//normal //right hand controlled by key y = 180; //hitbox fill(219, 219, 219); rect(x+65, 175+sin(0.03*(frameCount))*3, 5, 30);//right arm layer1 fill(219, 219, 219); rect(x+70, 185+sin(0.03*(frameCount))*3, 10, 25);//right arm layer2 fill(167, 167, 167); rect(x+75, 205+sin(0.03*(frameCount))*3, 5, 5);//right arm shade1 fill(219, 219, 219); rect(x+80, 175+sin(0.03*(frameCount))*3, 5, 30);//right arm layer3 fill(167, 167, 167); rect(x+80, 190+sin(0.03*(frameCount))*3, 5, 15);//right arm shade2 fill(219, 219, 219); rect(x+85, 175+sin(0.03*(frameCount))*3, 5, 20);//hand fill(167, 167, 167); rect(x+85, 180+sin(0.03*(frameCount))*3, 5, 15);// hand shade //sowrd fill(0, 0, 0); rect(x+90, 175+sin(0.03*(frameCount))*3, 10, 20);//handle fill(180, 180, 180); rect(x+100, 180+sin(0.03*(frameCount))*3, 45, 5);//sword } ///////////////////////////////////////////////////////////////// ///////////////////samurai weapon animation//////////////// ///////////////////////////////////////////////////////////////// if (sweapon >=-15&& sweapon <=15 && sattack == true) {//extend arm when player2 attack y1 = 180; //hitbox //sword fill(0, 0, 0); rect(290+x1-space, 175+sin(0.03*(frameCount))*3, 5, 15);//handle rect(295+x1-space, 180+sin(0.03*(frameCount))*3, 20, 5); fill(180, 180, 180); rect(225+x1-space, 180+sin(0.03*(frameCount))*3, 65, 5);//blade //left arm fill(33, 150, 243); rect(285+x1, 185+sin(0.03*(frameCount))*3, 5, 35);//layer1 rect(280+x1, 195+sin(0.03*(frameCount))*3, 5, 20);//layer2 fill(1, 87, 155); rect(285+x1, 215+sin(0.03*(frameCount))*3, 10, 5);//shade1 rect(295+x1, 210+sin(0.03*(frameCount))*3, 5, 5);//shade2 fill(255, 224, 178); rect(285+x1, 205+sin(0.03*(frameCount))*3, 10, 10);//left hand1 rect(290+x1-space/2, 195+sin(0.03*(frameCount))*3, 10, 15);//left hand2 rect(295+x1-space, 180+sin(0.03*(frameCount))*3, 10, 20); //right arm fill(33, 150, 243); rect(325+x1-space, 175+sin(0.03*(frameCount))*3, 15, 45);//layer1 rect(340+x1-space, 180+sin(0.03*(frameCount))*3, 5, 50);//layer2 rect(345+x1-space, 185+sin(0.03*(frameCount))*3, 5, 45);//layer3 rect(350+x1-space, 195+sin(0.03*(frameCount))*3, 5, 35);//layer4 rect(330+x1-space, 215+sin(0.03*(frameCount))*3, 5, 10);//;layer5 rect(335+x1-space, 215+sin(0.03*(frameCount))*3, 5, 15);//layer6 fill(1, 87, 155); rect(335+x1-space, 180+sin(0.03*(frameCount))*3, 10, 35);//shade1 rect(340+x1-space, 210+sin(0.03*(frameCount))*3, 5, 10);//shade2 fill(255, 224, 178); rect(320+x1-space, 180+sin(0.03*(frameCount))*3, 20, 10);//right hand1 rect(315+x1-space, 180+sin(0.03*(frameCount))*3, 5, 5);//right hand2 } else if (sweapon >= 15 && sattack == true) {// attack above y1=165; fill(0, 0, 0); rect(290+x1-space, -15+175+sin(0.03*(frameCount))*3, 5, 15);//handle rect(295+x1-space, -15+180+sin(0.03*(frameCount))*3, 20, 5); fill(180, 180, 180); rect(225+x1-space, -15+180+sin(0.03*(frameCount))*3, 65, 5);//blade //left arm fill(33, 150, 243); rect(285+x1, -15+185+sin(0.03*(frameCount))*3, 5, 35);//layer1 rect(280+x1, -15+195+sin(0.03*(frameCount))*3, 5, 20);//layer2 fill(1, 87, 155); rect(285+x1, -15+215+sin(0.03*(frameCount))*3, 10, 5);//shade1 rect(295+x1, -15+210+sin(0.03*(frameCount))*3, 5, 5);//shade2 fill(255, 224, 178); rect(285+x1, -15+205+sin(0.03*(frameCount))*3, 10, 10);//left hand1 rect(290+x1-space/2, -15+195+sin(0.03*(frameCount))*3, 10, 15);//left hand2 rect(295+x1-space, -15+180+sin(0.03*(frameCount))*3, 10, 20); //right arm fill(33, 150, 243); rect(325+x1-space, -15+175+sin(0.03*(frameCount))*3, 15, 45);//layer1 rect(340+x1-space, -15+180+sin(0.03*(frameCount))*3, 5, 50);//layer2 rect(345+x1-space, -15+185+sin(0.03*(frameCount))*3, 5, 45);//layer3 rect(350+x1-space, -15+195+sin(0.03*(frameCount))*3, 5, 35);//layer4 rect(330+x1-space, -15+215+sin(0.03*(frameCount))*3, 5, 10);//;layer5 rect(335+x1-space, -15+215+sin(0.03*(frameCount))*3, 5, 15);//layer6 fill(1, 87, 155); rect(335+x1-space, -15+180+sin(0.03*(frameCount))*3, 10, 35);//shade1 rect(340+x1-space, -15+210+sin(0.03*(frameCount))*3, 5, 10);//shade2 fill(255, 224, 178); rect(320+x1-space, -15+180+sin(0.03*(frameCount))*3, 20, 10);//right hand1 rect(315+x1-space, -15+180+sin(0.03*(frameCount))*3, 5, 5);//right hand2 } else if (sweapon <=-15 && sattack == true) {//attack below y1=195; //left arm fill(33, 150, 243); rect(285+x1, 2+185+sin(0.03*(frameCount))*3, 5, 35);//layer1 rect(280+x1, 5+195+sin(0.03*(frameCount))*3, 5, 20);//layer2 fill(1, 87, 155); rect(285+x1, 5+215+sin(0.03*(frameCount))*3, 10, 5);//shade1 rect(295+x1, 10+210+sin(0.03*(frameCount))*3, 5, 5);//shade2 fill(255, 224, 178); rect(285+x1, 5+205+sin(0.03*(frameCount))*3, 10, 10);//left hand1 rect(290+x1-space/2, 10+195+sin(0.03*(frameCount))*3, 10, 15);//left hand2 rect(295+x1-space, 15+180+sin(0.03*(frameCount))*3, 10, 20); //right arm fill(33, 150, 243); rect(325+x1-space, 5+175+sin(0.03*(frameCount))*3, 15, 45);//layer1 rect(340+x1-space, 10+180+sin(0.03*(frameCount))*3, 5, 50);//layer2 rect(345+x1-space, 15+185+sin(0.03*(frameCount))*3, 5, 45);//layer3 rect(350+x1-space, 15+195+sin(0.03*(frameCount))*3, 5, 35);//layer4 rect(330+x1-space, 15+215+sin(0.03*(frameCount))*3, 5, 10);//;layer5 rect(335+x1-space, 15+215+sin(0.03*(frameCount))*3, 5, 15);//layer6 fill(1, 87, 155); rect(335+x1-space, 15+180+sin(0.03*(frameCount))*3, 10, 35);//shade1 rect(340+x1-space, 15+210+sin(0.03*(frameCount))*3, 5, 10);//shade2 fill(255, 224, 178); rect(320+x1-space, 15+180+sin(0.03*(frameCount))*3, 20, 10);//right hand1 rect(315+x1-space, 15+180+sin(0.03*(frameCount))*3, 5, 5);//right hand2 //sword// fill(0, 0, 0); rect(290+x1-space, 15+175+sin(0.03*(frameCount))*3, 5, 15);//handle rect(295+x1-space, 15+180+sin(0.03*(frameCount))*3, 20, 5); fill(180, 180, 180); rect(225+x1-space, 15+180+sin(0.03*(frameCount))*3, 65, 5);//blade } else if (sweapon >=-15&& sweapon <=15 ) {//normal //sword y1 = 180; //hitbox fill(0, 0, 0); rect(290+x1, 175+sin(0.03*(frameCount))*3, 5, 15);//handle rect(295+x1, 180+sin(0.03*(frameCount))*3, 20, 5); fill(180, 180, 180); rect(225+x1, 180+sin(0.03*(frameCount))*3, 65, 5);//blade //left arm fill(33, 150, 243); rect(285+x1, 185+sin(0.03*(frameCount))*3, 5, 35);//layer1 rect(280+x1, 195+sin(0.03*(frameCount))*3, 5, 20);//layer2 fill(1, 87, 155); rect(285+x1, 215+sin(0.03*(frameCount))*3, 10, 5);//shade1 rect(295+x1, 210+sin(0.03*(frameCount))*3, 5, 5);//shade2 fill(255, 224, 178); rect(285+x1, 205+sin(0.03*(frameCount))*3, 10, 10);//left hand1 rect(290+x1, 195+sin(0.03*(frameCount))*3, 10, 15);//left hand2 rect(295+x1, 180+sin(0.03*(frameCount))*3, 10, 20); //right arm fill(33, 150, 243); rect(325+x1, 175+sin(0.03*(frameCount))*3, 15, 45);//layer1 rect(340+x1, 180+sin(0.03*(frameCount))*3, 5, 50);//layer2 rect(345+x1, 185+sin(0.03*(frameCount))*3, 5, 45);//layer3 rect(350+x1, 195+sin(0.03*(frameCount))*3, 5, 35);//layer4 rect(330+x1, 215+sin(0.03*(frameCount))*3, 5, 10);//;layer5 rect(335+x1, 215+sin(0.03*(frameCount))*3, 5, 15);//layer6 fill(1, 87, 155); rect(335+x1, 180+sin(0.03*(frameCount))*3, 10, 35);//shade1 rect(340+x1, 210+sin(0.03*(frameCount))*3, 5, 10);//shade2 fill(255, 224, 178); rect(320+x1, 180+sin(0.03*(frameCount))*3, 20, 10);//right hand1 rect(315+x1, 180+sin(0.03*(frameCount))*3, 5, 5);//right hand2 } else if (sweapon >= 15 ) {//move up y1=165; fill(0, 0, 0); rect(290+x1, -15+175+sin(0.03*(frameCount))*3, 5, 15);//handle rect(295+x1, -15+180+sin(0.03*(frameCount))*3, 20, 5); fill(180, 180, 180); rect(225+x1, -15+180+sin(0.03*(frameCount))*3, 65, 5);//blade //left arm fill(33, 150, 243); rect(285+x1, -15+185+sin(0.03*(frameCount))*3, 5, 35);//layer1 rect(280+x1, -15+195+sin(0.03*(frameCount))*3, 5, 20);//layer2 fill(1, 87, 155); rect(285+x1, -15+215+sin(0.03*(frameCount))*3, 10, 5);//shade1 rect(295+x1, -15+210+sin(0.03*(frameCount))*3, 5, 5);//shade2 fill(255, 224, 178); rect(285+x1, -15+205+sin(0.03*(frameCount))*3, 10, 10);//left hand1 rect(290+x1, -15+195+sin(0.03*(frameCount))*3, 10, 15);//left hand2 rect(295+x1, -15+180+sin(0.03*(frameCount))*3, 10, 20); //right arm fill(33, 150, 243); rect(325+x1, -15+175+sin(0.03*(frameCount))*3, 15, 45);//layer1 rect(340+x1, -15+180+sin(0.03*(frameCount))*3, 5, 50);//layer2 rect(345+x1, -15+185+sin(0.03*(frameCount))*3, 5, 45);//layer3 rect(350+x1, -15+195+sin(0.03*(frameCount))*3, 5, 35);//layer4 rect(330+x1, -15+215+sin(0.03*(frameCount))*3, 5, 10);//;layer5 rect(335+x1, -15+215+sin(0.03*(frameCount))*3, 5, 15);//layer6 fill(1, 87, 155); rect(335+x1, -15+180+sin(0.03*(frameCount))*3, 10, 35);//shade1 rect(340+x1, -15+210+sin(0.03*(frameCount))*3, 5, 10);//shade2 fill(255, 224, 178); rect(320+x1, -15+180+sin(0.03*(frameCount))*3, 20, 10);//right hand1 rect(315+x1, -15+180+sin(0.03*(frameCount))*3, 5, 5);//right hand2 } else if (sweapon <=-15 ) {//move down y1=195; //left arm fill(33, 150, 243); rect(285+x1, 2+185+sin(0.03*(frameCount))*3, 5, 35);//layer1 rect(280+x1, 5+195+sin(0.03*(frameCount))*3, 5, 20);//layer2 fill(1, 87, 155); rect(285+x1, 5+215+sin(0.03*(frameCount))*3, 10, 5);//shade1 rect(295+x1, 10+210+sin(0.03*(frameCount))*3, 5, 5);//shade2 fill(255, 224, 178); rect(285+x1, 5+205+sin(0.03*(frameCount))*3, 10, 10);//left hand1 rect(290+x1, 10+195+sin(0.03*(frameCount))*3, 10, 15);//left hand2 rect(295+x1, 15+180+sin(0.03*(frameCount))*3, 10, 20); //right arm fill(33, 150, 243); rect(325+x1, 5+175+sin(0.03*(frameCount))*3, 15, 45);//layer1 rect(340+x1, 10+180+sin(0.03*(frameCount))*3, 5, 50);//layer2 rect(345+x1, 15+185+sin(0.03*(frameCount))*3, 5, 45);//layer3 rect(350+x1, 15+195+sin(0.03*(frameCount))*3, 5, 35);//layer4 rect(330+x1, 15+215+sin(0.03*(frameCount))*3, 5, 10);//;layer5 rect(335+x1, 15+215+sin(0.03*(frameCount))*3, 5, 15);//layer6 fill(1, 87, 155); rect(335+x1, 15+180+sin(0.03*(frameCount))*3, 10, 35);//shade1 rect(340+x1, 15+210+sin(0.03*(frameCount))*3, 5, 10);//shade2 fill(255, 224, 178); rect(320+x1, 15+180+sin(0.03*(frameCount))*3, 20, 10);//right hand1 rect(315+x1, 15+180+sin(0.03*(frameCount))*3, 5, 5);//right hand2 //sword// fill(0, 0, 0); rect(290+x1, 15+175+sin(0.03*(frameCount))*3, 5, 15);//handle rect(295+x1, 15+180+sin(0.03*(frameCount))*3, 20, 5); fill(180, 180, 180); rect(225+x1, 15+180+sin(0.03*(frameCount))*3, 65, 5);//blade } samuraiWin(); knightWin(); } void keyPressed() { ///////////////////////////////// ////////////control////////////// ///////////////////////////////// ///////1.movement/////////// if (key == ' ') { sattack = true; } if (key == CODED) {//samurai control if (keyCode == RIGHT) { sright=true; } else if (keyCode== LEFT) { sleft=true; } else if (keyCode== UP) {//samurai weapon control sup=true; } else if (keyCode== DOWN) { sdown=true; } } if (key == 'd') {//knight control kright = true; } else if (key =='a') { kleft = true; } if (key == 'w') {//knight weapon contorl kup = true; } else if (key =='s') { kdown = true; } if (key =='e') {//KNIGHT ATTACK BUTTON kattack=true; } ///////////////////////////limit////////////////////////// if (kweapon > 15) {///knight will not able to press key anymore kup = false; } if (kweapon < -15) { kdown = false; } if (sweapon > 15) {///samurai will not able to press key anymore sup = false; } if (sweapon < -15) { sdown = false; } if (x>x1+150) {//When the players come together, they can stop. kright =false; sleft = false; } } void keyReleased() { if (key == ' ') { sattack = false; } if (key == CODED) {//samurai control if (keyCode == RIGHT) { sright=false; } else if (keyCode== LEFT) { sleft=false; } else if (keyCode== UP) {//samurai weapon control sup=false; } else if (keyCode== DOWN) { sdown=false; } } if (key == 'd') {//knight control kright = false; } else if (key =='a') { kleft = false; } if (key == 'w') {//knight weapon control kup = false ; } else if (key =='s') { kdown = false; } if (key =='e') {//KNIGHT ATTACK BUTTON kattack=false; } }