ฟังก์ชัน KeyPressed
void keyPressed() {
if (keyCode == UP&&sno>=0&&sno<2) {
sno = sno+1;
snoopyY = snoopyY-100;
}
if (keyCode == DOWN&&sno>0&&sno<=2) {
sno = sno-1;
snoopyY = snoopyY+100;
}
if (key=='s' || key=='S') {
if (life==1) {
miss=0;
score=0;
life=3;
ten1_Boy=0;
ten2_Boy=0;
ten1_Girl=1;
ten2_Girl=1;
ball = 0;
ball2 = 1;
ball3 = 1;
ball4 = 1;
step = 0;
step2 = 0;
step3 = 1;
step4 = 1;
background(195, 255, 230);
sceen();
Life(life, width-150, 15);
textFont(createFont("Arial", 17));
fill(0, 0, 255);
text("score = "+score+" Life "+life, 30, 30);
}
}
if (sno==set_ten1||sno==set_ten2||sno==set_ten3||sno==set_ten4) {
if (key=='T'||key=='t') {
if (ten1_Boy==ball-1) {
score = score+2; //score
ball = Ball_Girl[0].length; //ตีกลับ boy
step = sno+1;
ten1_Boy = ball-1;
}
else if (ten2_Boy==ball2-1) {
score = score+2; //score
ball2 = Ball_Girl[0].length; //ตีกลับ boy
step2 = sno+1;
ten2_Boy = ball2-1;
}
else if (ten1_Girl==ball3-1) {
score = score+3;
step3 = sno+1;
}
else if (ten2_Girl==ball4-1) {
score = score+3; //score
step4 = sno+1;
}
sno = sno+3; //ท่าตี snoopy
if (score==10||score>10&&score%3==0) {
hit_Girl = 1;
}
}
}
}
ไม่มีความคิดเห็น:
แสดงความคิดเห็น