所以我正在使用Eclipse和Proclipsing在不同的计算机(Windows 10)上开展项目。然后我将文件通过电子邮件发送给自己在我的家用电脑上工作(Mac 10.10.1)(通过Proclipsing运行Processing)。然而,当我尝试运行该程序时,它询问我是否要在ANT构建中运行它,它之前没有运行过。尝试将其作为ANT构建运行,它告诉我&#34 ;构建失败。原因:无法找到要运行的ANT文件。"以下是参考代码:
package myfinalproject;
import java.util.Random;
import processing.core.PApplet;
import processing.core.PFont;
public class MyFinalProject extends PApplet {
public float speed = 5;
public float vy=5;
public float vx=5;
public float x = 400;
public float y = 350;
PFont f;
public boolean moveleft = false;
public boolean moveright=false;
public boolean moveleft2 = false;
public boolean moveright2=false;
public void setup() {
frameRate(100);
size(1000, 1000);
background(0);
f = createFont("Arial",16,true);
rectMode(CENTER);
ellipseMode(CENTER);
ellipseMode(RADIUS);
}
float boxX=500;
float boxY=950;
float boxX2=500;
float boxY2=50;
float ballX=500;
float ballY=500;
float radius=25;
float ballradius=30;
float boxheight= 25;
float boxwidth= 150;
float player1score=0;
float player2score=0;
float boxcdy=boxY+(boxheight/2);
float boxcdy2=boxY2+(boxheight/2);
float boxcdx=boxX+boxwidth/2;
float boxcdx2=boxX2+boxwidth/2;
public void draw(){
background(0);
gametext();
drawellipse();
values();
drawrect();
offscreen();
move();
collision();
gameover();
}
public void values() {
boxcdy=boxY+(boxheight/2);
boxcdy2=boxY2+(boxheight/2);
boxcdx=boxX+(boxwidth/2);
boxcdx2=boxX2+(boxwidth/2);
}
public void gametext(){
textFont(f,18);
fill(255);
text(player1score,500, 50);
text(player2score, 500,950);
}
public void drawellipse(){
ellipse(ballX, ballY, radius, radius);
fill(255,255,255);
}
public void ballmovement(){
ballY+=vy;
ballX+=vx;}
public void collision(){
if((boxX-75<ballX)&&(ballX<boxX+75)&&(dist(boxX,boxY,ballX,ballY)<radius+(boxheight/2))){
vx=vx;
vy=-vy;
}
if((boxX2-75<ballX)&&(ballX<boxX2+75)&&(dist(boxX2,boxY2,ballX,ballY)<radius+(boxheight/2))){
vx=vx;
vy=-vy;
}}
public void drawrect(){
rect(boxX,boxY,boxwidth,boxheight);
fill(255,255,255);
rect(boxX2,boxY2,boxwidth,boxheight);
fill(255,255,255);
}
public void moveleft(){
if((moveleft == true)&&(boxX>0)){
boxX-=speed;}
if((moveleft2 == true)&&(boxX2>0)){
boxX2-=speed;}
}
public void moveright(){
if((moveright == true)&&(boxX<1000)){
boxX+=speed;}
if((moveright2 == true)&&(boxX2<1000)){
boxX2+=speed;}
}
public void offscreen(){
if ((ballX>1000)||(ballX<0)){
vy=-vy;
vx=-vx;
}}
public void keyPressed(){
if(key == 'd'){
moveright=true;
}
if(key == 'j'){
moveleft2=true;
}
if(key == 'l'){
moveright2=true;
}
if(key=='a'){
moveleft=true;}}
public void keyReleased(){
if(key == 'a'){
moveleft=false;}
if(key == 'j'){
moveleft2=false;}
if(key == 'l'){
moveright2=false;}
if(key=='d'){
moveright=false;}}
public void move(){
moveright();
moveleft();
ballmovement();
}
public void gameover(){
if (ballY>1025){
player2score=player2score+1;
ballX=500;
ballY=500;}
if(ballY<0){
player1score=player1score+1;
ballX=500;
ballY=500;
if((player1score>=3)||(player2score>=3)){
player1score=0;
player2score=0;
text("You Won!",300,500);
ballX=500;
ballY=500;
background(0);
textFont(f,36);
fill(255);
text("Welcome to 2 Player Pong!",300,500);
}
}
}
}