⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 cutoffcanvas.java

📁 Source code for j2me game Capture
💻 JAVA
📖 第 1 页 / 共 3 页
字号:
				if (ballDX[p]==0) {				ballX[p]++;				}				else {				ballX[p]--;				}				ballMA[p]++;				if (ballMA[p]>ballMY[p]) {				ballMA[p]=0;				if (ballDY[p]==0) {				ballY[p]++;				}				else {				ballY[p]--;				}				}				}//balldm==0			 	else {				ballMA[p]++;				if (ballMA[p]>ballMX[p]) {					ballMA[p]=0;				if (ballDX[p]==0) {						ballX[p]++;						}						else {						ballX[p]--;						}						}						if (ballDY[p]==0) {						ballY[p]++;						}						else {						ballY[p]--;						}				}		}//for p numballs		if (arrowMoveUp==true) {		arrowMoveDown=false;		arrowMoveRight=false;		arrowMoveLeft=false;		}		if (arrowMoveDown==true) {				arrowMoveUp=false;				arrowMoveRight=false;				arrowMoveLeft=false;				}		if (arrowMoveLeft==true) {				arrowMoveDown=false;				arrowMoveRight=false;				arrowMoveUp=false;				}		if (arrowMoveRight==true) {				arrowMoveDown=false;				arrowMoveUp=false;				arrowMoveLeft=false;				}		if (arrowMoveUp==true) {			found=false;			for (p=0;p<numBounderPoints;p++) {			j=p+1;if (j>=numBounderPoints) j=0;			if (onLine (arrowX,arrowY-1,bounderPointsX[p],bounderPointsY[p],bounderPointsX[j],bounderPointsY[j])) found=true;			}			if (contains(arrowX,arrowY-1,bounderPointsX,bounderPointsY,numBounderPoints)=='i' ||			found==true			) {		arrowY--;		cutPointsX[0]=startCutPointX;		cutPointsY[0]=startCutPointY;		if (numCutPoints<1) numCutPoints++;		cutPointsX[numCutPoints]=arrowX;		cutPointsY[numCutPoints]=arrowY;		if (numCutPoints==1) if (cutPointsX[numCutPoints]!=cutPointsX[0]) cutPointsX[0]=cutPointsX[numCutPoints];		if (resting==true) {			resting=false;			for (p=0;p<numBounderPoints;p++)			{			i=p;			j=i+1;			if (j>=numBounderPoints) j=0;			if (onLine (arrowX,arrowY,bounderPointsX[i],bounderPointsY[i],bounderPointsX[j],bounderPointsY[j])==true) resting=true;	} }		}		}		if (arrowMoveDown==true) {			found=false;						for (p=0;p<numBounderPoints;p++) {						j=p+1;if (j>=numBounderPoints) j=0;						if (onLine (arrowX,arrowY+1,bounderPointsX[p],bounderPointsY[p],bounderPointsX[j],bounderPointsY[j])) found=true;						}			if (contains(arrowX,arrowY+1,bounderPointsX,bounderPointsY,numBounderPoints)=='i' ||			found==true			) {	arrowY++;	cutPointsX[0]=startCutPointX;			cutPointsY[0]=startCutPointY;			if (numCutPoints<1) numCutPoints++;				cutPointsX[numCutPoints]=arrowX;				cutPointsY[numCutPoints]=arrowY;				if (numCutPoints==1) if (cutPointsX[numCutPoints]!=cutPointsX[0]) cutPointsX[0]=cutPointsX[numCutPoints];		if (resting==true) {	resting=false;	for (p=0;p<numBounderPoints;p++)	{	i=p;	j=i+1;	if (j>=numBounderPoints) j=0;	if (onLine (arrowX,arrowY,bounderPointsX[i],bounderPointsY[i],bounderPointsX[j],bounderPointsY[j])==true) resting=true;	}	}		}		}		if (arrowMoveLeft==true) {			found=false;						for (p=0;p<numBounderPoints;p++) {						j=p+1;if (j>=numBounderPoints) j=0;						if (onLine (arrowX-1,arrowY,bounderPointsX[p],bounderPointsY[p],bounderPointsX[j],bounderPointsY[j])) found=true;						}			if (contains(arrowX-1,arrowY,bounderPointsX,bounderPointsY,numBounderPoints)=='i' ||			found==true			) {	arrowX--;	cutPointsX[0]=startCutPointX;			cutPointsY[0]=startCutPointY;			if (numCutPoints<1) numCutPoints++;				cutPointsX[numCutPoints]=arrowX;				cutPointsY[numCutPoints]=arrowY;				if (numCutPoints==1) if (cutPointsY[numCutPoints]!=cutPointsY[0]) cutPointsY[0]=cutPointsY[numCutPoints];				if (resting==true) {					resting=false;					for (p=0;p<numBounderPoints;p++)					{					i=p;					j=i+1;					if (j>=numBounderPoints) j=0;					if (onLine (arrowX,arrowY,bounderPointsX[i],bounderPointsY[i],bounderPointsX[j],bounderPointsY[j])==true) resting=true;	}}		}		}		if (arrowMoveRight==true) {				found=false;							for (p=0;p<numBounderPoints;p++) {							j=p+1;if (j>=numBounderPoints) j=0;							if (onLine (arrowX+1,arrowY,bounderPointsX[p],bounderPointsY[p],bounderPointsX[j],bounderPointsY[j])) found=true;							}				if (contains(arrowX+1,arrowY,bounderPointsX,bounderPointsY,numBounderPoints)=='i' ||				found==true			) {		arrowX++;		cutPointsX[0]=startCutPointX;				cutPointsY[0]=startCutPointY;				if (numCutPoints<1) numCutPoints++;				cutPointsX[numCutPoints]=arrowX;				cutPointsY[numCutPoints]=arrowY;				if (numCutPoints==1) if (cutPointsY[numCutPoints]!=cutPointsY[0]) cutPointsY[0]=cutPointsY[numCutPoints];				if (resting==true) {					resting=false;					for (p=0;p<numBounderPoints;p++)					{					i=p;					j=i+1;					if (j>=numBounderPoints) j=0;					if (onLine (arrowX,arrowY,bounderPointsX[i],bounderPointsY[i],bounderPointsX[j],bounderPointsY[j])==true) resting=true;	}}		}		}		if (resting==true) if (arrowMoveRight==true || arrowMoveUp==true || arrowMoveDown==true || arrowMoveLeft==true) {		for (p=0;p<numBounderPoints;p++)			{			i=p;			j=i+1;			if (j>=numBounderPoints) j=0;			if (onLine (arrowX,arrowY,bounderPointsX[i],bounderPointsY[i],bounderPointsX[j],bounderPointsY[j])==true) foundd=true;			}			if (foundd==true) {			startCutPointX=arrowX;			startCutPointY=arrowY;			}		}		np=0;		if (resting==false)		for (p=0;p<numBounderPoints;p++) {			np=p+1;			if (np==numBounderPoints) np=0;		//if (foundd==false)		if (onLine (arrowX,arrowY,bounderPointsX[p],bounderPointsY[p],bounderPointsX[np],bounderPointsY[np]))		{		numPolyAPoints=0;				numPolyBPoints=0;	//	System.out.println ("polyA");		polyAorB=false;		cutPointsX[numCutPoints]=arrowX;		cutPointsY[numCutPoints]=arrowY;		numCutPoints++;		for (p=0;p<numBounderPoints;p++) {			np=p+1;		if (np==numBounderPoints) np=0;			if (onLine (cutPointsX[0],cutPointsY[0],bounderPointsX[p],bounderPointsY[p],bounderPointsX[np],bounderPointsY[np]) ||				onLine (cutPointsX[numCutPoints-1],cutPointsY[numCutPoints-1],bounderPointsX[p],bounderPointsY[p],bounderPointsX[np],bounderPointsY[np])				) {		i=p;		j=i-1;		if (j<0) j=numBounderPoints-1;	//	System.out.println ("i"+i);		int cutPointX,cutPointY;		cutPointX=11795;cutPointY=11795;		if (onLine (cutPointsX[0],cutPointsY[0],bounderPointsX[i],bounderPointsY[i],bounderPointsX[j],bounderPointsY[j])==true)		{		cutPointX=cutPointsX[0];		cutPointY=cutPointsY[0];		}		if (onLine (cutPointsX[numCutPoints-1],cutPointsY[numCutPoints-1],bounderPointsX[i],bounderPointsY[i],bounderPointsX[j],bounderPointsY[j])==true)		{		cutPointX=cutPointsX[numCutPoints-1];		cutPointY=cutPointsY[numCutPoints-1];		}		while ((onLine (cutPointsX[0],cutPointsY[0],bounderPointsX[i],bounderPointsY[i],bounderPointsX[j],bounderPointsY[j])==false &&		onLine (cutPointsX[numCutPoints-1],cutPointsY[numCutPoints-1],bounderPointsX[i],bounderPointsY[i],bounderPointsX[j],bounderPointsY[j])==false) ||		lineTouches (cutPointX,cutPointY,bounderPointsX[i],bounderPointsY[i],bounderPointsX[j],bounderPointsY[j],		bounderPointsX[p],bounderPointsY[p],bounderPointsX[np],bounderPointsY[np])		) {			cutPointX=11795;			cutPointY=11879;	//	System.out.println ("boud "+bounderPointsX[i]+" "+i);		polyAX[numPolyAPoints]=bounderPointsX[i];		polyAY[numPolyAPoints]=bounderPointsY[i];		numPolyAPoints++;		i--;		if (i<0) {			i=numBounderPoints-1;	//		System.out.println ("<0 "+i);		}		j=i-1;		if (j<0) j=numBounderPoints-1;		}//while		polyAX[numPolyAPoints]=bounderPointsX[i];		polyAY[numPolyAPoints]=bounderPointsY[i];		numPolyAPoints++;		if (onLine (cutPointsX[0],cutPointsY[0],bounderPointsX[i],bounderPointsY[i],bounderPointsX[j],bounderPointsY[j])==true &&				onLine (cutPointsX[numCutPoints-1],cutPointsY[numCutPoints-1],bounderPointsX[i],bounderPointsY[i],bounderPointsX[j],bounderPointsY[j])==true)		{		//	System.out.println ("sdklfj "+i);		int a=bounderPointsX[i]-cutPointsX[0];		if (a<0) a=a+ (a*-2);		int b=bounderPointsY[i]-cutPointsY[0];		if (b<0) b=b+(b*-2);		int c=a+b;		a=bounderPointsX[i]-cutPointsX[numCutPoints-1];		if (a<0) a=a+ (a*-2);		b=bounderPointsY[i]-cutPointsY[numCutPoints-1];		if (b<0) b=b+(b*-2);		if (			//(i==0 && c>=a+b) || (i!=0 &&			c<=a+b) {		for (g=0;g<numCutPoints;g++) {		polyAX[numPolyAPoints]=cutPointsX[g];		polyAY[numPolyAPoints]=cutPointsY[g];		numPolyAPoints++;		}		}//if c<a+b		else {		for (g=numCutPoints-1;g>-1;g--) {		polyAX[numPolyAPoints]=cutPointsX[g];		polyAY[numPolyAPoints]=cutPointsY[g];		numPolyAPoints++;		}		}//elsxe		}//iif online both		else {		if (onLine (cutPointsX[0],cutPointsY[0],bounderPointsX[i],bounderPointsY[i],bounderPointsX[j],bounderPointsY[j])==true)				{				for (g=0;g<numCutPoints;g++) {		polyAX[numPolyAPoints]=cutPointsX[g];		polyAY[numPolyAPoints]=cutPointsY[g];		numPolyAPoints++;		}//g		}//iif online0		if (onLine (cutPointsX[numCutPoints-1],cutPointsY[numCutPoints-1],bounderPointsX[i],bounderPointsY[i],bounderPointsX[j],bounderPointsY[j])==true)		{		for (g=numCutPoints-1;g>-1;g--) {		polyAX[numPolyAPoints]=cutPointsX[g];		polyAY[numPolyAPoints]=cutPointsY[g];		numPolyAPoints++;		}//g				}//iif online0			}//onlineelse		/*int polyPoints [] = new int [500];		i=0;		for (g=numPolyAPoints-1;g>=0;g--) polyPoints [i++]=polyAX[g];		for (g=0;g<numPolyAPoints;g++) polyAX[g]=polyPoints[g];		i=0;		for (g=numPolyAPoints-1;g>=0;g--) polyPoints [i++]=polyAY[g];		for (g=0;g<numPolyAPoints;g++) polyAY[g]=polyPoints[g];	//	System.out.println ("numPolyAPoints"+numPolyAPoints);		*/		//////////////////////////////////2nd		foundd=false;		for (i=0;i<numBounderPoints;i++) {			j=i+1;			if (j>=numBounderPoints) j=0;		if (onLine (cutPointsX[0],cutPointsY[0],bounderPointsX[i],bounderPointsY[i],bounderPointsX[j],bounderPointsY[j])==true &&				onLine (cutPointsX[numCutPoints-1],cutPointsY[numCutPoints-1],bounderPointsX[i],bounderPointsY[i],bounderPointsX[j],bounderPointsY[j])==true) foundd=true;				}				if (foundd==true) {				for (i=0;i<numCutPoints;i++) {				polyBX[i]=cutPointsX[i];				polyBY[i]=cutPointsY[i];				}				numPolyBPoints=numCutPoints;			//	System.out.println ("sameline");				}//foundd==true				else {				i=p+1;				if (i>=numBounderPoints) i=0;				j=i+1;				if (j>=numBounderPoints) j=0;				cutPointX=11795;cutPointY=11795;						if (onLine (cutPointsX[0],cutPointsY[0],bounderPointsX[i],bounderPointsY[i],bounderPointsX[j],bounderPointsY[j])==true)						{						cutPointX=cutPointsX[0];						cutPointY=cutPointsY[0];						}						if (onLine (cutPointsX[numCutPoints-1],cutPointsY[numCutPoints-1],bounderPointsX[i],bounderPointsY[i],bounderPointsX[j],bounderPointsY[j])==true)						{						cutPointX=cutPointsX[numCutPoints-1];						cutPointY=cutPointsY[numCutPoints-1];		}		//		System.out.println ("polyB");		//		System.out.println ("i"+i);				while ((onLine (cutPointsX[0],cutPointsY[0],bounderPointsX[i],bounderPointsY[i],bounderPointsX[j],bounderPointsY[j])==false &&				onLine (cutPointsX[numCutPoints-1],cutPointsY[numCutPoints-1],bounderPointsX[i],bounderPointsY[i],bounderPointsX[j],bounderPointsY[j])==false) ||				lineTouches (cutPointX,cutPointY,bounderPointsX[i],bounderPointsY[i],bounderPointsX[j],bounderPointsY[j],				bounderPointsX[p],bounderPointsY[p],bounderPointsX[np],bounderPointsY[np])				) {				cutPointX=11878;				cutPointY=11876;			//	System.out.println ("boud "+bounderPointsX[i]+" "+i);				polyBX[numPolyBPoints]=bounderPointsX[i];				polyBY[numPolyBPoints]=bounderPointsY[i];				numPolyBPoints++;				i++;				if (i>=numBounderPoints) i=0;				j=i+1;				if (j>=numBounderPoints) j=0;				}//while				polyBX[numPolyBPoints]=bounderPointsX[i];				polyBY[numPolyBPoints]=bounderPointsY[i];				numPolyBPoints++;				if (onLine (cutPointsX[0],cutPointsY[0],bounderPointsX[i],bounderPointsY[i],bounderPointsX[j],bounderPointsY[j])==true &&						onLine (cutPointsX[numCutPoints-1],cutPointsY[numCutPoints-1],bounderPointsX[i],bounderPointsY[i],bounderPointsX[j],bounderPointsY[j])==true)				{				int a=bounderPointsX[i]-cutPointsX[0];				if (a<0) a=a+ (a*-2);				int b=bounderPointsY[i]-cutPointsY[0];				if (b<0) b=b+(a*-2);				int c=a+b;				a=bounderPointsX[i]-cutPointsX[numCutPoints-1];				if (a<0) a=a+ (a*-2);				b=bounderPointsY[i]-cutPointsY[numCutPoints-1];				if (b<0) b=b+(a*-2);				if (c<=a+b) {				for (g=0;g<numCutPoints;g++) {				polyBX[numPolyBPoints]=cutPointsX[g];				polyBY[numPolyBPoints]=cutPointsY[g];				numPolyBPoints++;				}				}//if c<a+b				else {				for (g=numCutPoints-1;g>-1;g--) {				polyBX[numPolyBPoints]=cutPointsX[g];				polyBY[numPolyBPoints]=cutPointsY[g];				numPolyBPoints++;				}				}//elsxe				}//iif online both				else {				if (onLine (cutPointsX[0],cutPointsY[0],bounderPointsX[i],bounderPointsY[i],bounderPointsX[j],bounderPointsY[j])==true)						{						for (g=0;g<numCutPoints;g++) {				polyBX[numPolyBPoints]=cutPointsX[g];				polyBY[numPolyBPoints]=cutPointsY[g];				numPolyBPoints++;				}//g				}//iif online0				if (onLine (cutPointsX[numCutPoints-1],cutPointsY[numCutPoints-1],bounderPointsX[i],bounderPointsY[i],bounderPointsX[j],bounderPointsY[j])==true)				{				for (g=numCutPoints-1;g>-1;g--) {				polyBX[numPolyBPoints]=cutPointsX[g];				polyBY[numPolyBPoints]=cutPointsY[g];				numPolyBPoints++;				}//g						}//iif online0					}//onlineelse		//			System.out.println ("numPolyBPoints"+numPolyBPoints);				}//sameline else		i=0;		j=0;		k=0;		//l=0;		for (i=0;i<numPolyAPoints;i++) {		j=i+1;		if (j>=numPolyAPoints) j=0;		k=i-1;		if (k<0) k=numPolyAPoints-1;		areaA+=polyAX[i]*(polyAY[j]-polyAY[k]);		}		areaA=areaA/2;		if (areaA<0) areaA=areaA*-1;		for (i=0;i<numPolyBPoints;i++) {		j=i+1;		if (j>=numPolyBPoints) j=0;		k=i-1;		if (k<0) k=numPolyBPoints-1;				areaB+=polyBX[i]*(polyBY[j]-polyBY[k]);				}		areaB=areaB/2;		if (areaB<0) areaB=areaB*-1;		if (areaA>=areaB) {			polyAorB=true;		for (g=0;g<numPolyAPoints;g++) {				bounderPointsX[g]=polyAX[g];				bounderPointsY[g]=polyAY[g];				}				numBounderPoints=numPolyAPoints;				p=10000;			//	System.out.println (""+(((totalArea*1000)-(areaA*1000))/totalArea));				score=score+(1+(((areaB*1000)/totalArea)/200))*(((areaB*1000)/totalArea)/10);				if (((totalArea*1000)-(areaA*1000))/totalArea>800) {					level++;					startLevel();				}		} else		{		for (g=0;g<numPolyBPoints;g++) {						bounderPointsX[g]=polyBX[g];						bounderPointsY[g]=polyBY[g];						}						numBounderPoints=numPolyBPoints;		for (g=0;g<numPolyAPoints;g++) {		polyBX[g]=polyAX[g];		polyBY[g]=polyAY[g];		}		numPolyBPoints=numPolyAPoints;		score=score+(1+(((areaA*1000)/totalArea)/200))*(((areaA*1000)/totalArea)/10);		if (((totalArea*1000)-(areaB*1000))/totalArea>800) {							level++;							startLevel();				}		}		numCutPoints=0;		resting=true;		startCutPointX=arrowX;		startCutPointY=arrowY;		p=10000;		for (g=0;g<numPolyBPoints;g++) {			i=g+1;			if (i>=numPolyBPoints) i=0;			addRect (g,polyBX[g],polyBY[g],polyBX[i],polyBY[i]);	}//addrects	//System.out.println ("num Rects"+numFillerRects);	}		}//p		}//if		}//p		for (p=0;p<numBalls;p++) {				for (t=0;t<numCutPoints;t++) {					if (onLine (ballX[p],ballY[p],cutPointsX[t],cutPointsY[t],cutPointsX[t+1],cutPointsY[t+1]) ||						onLine (ballX[p]+ballWidth,ballY[p],cutPointsX[t],cutPointsY[t],cutPointsX[t+1],cutPointsY[t+1]) ||						onLine (ballX[p],ballY[p]+ballHeight,cutPointsX[t],cutPointsY[t],cutPointsX[t+1],cutPointsY[t+1]) ||						onLine (ballX[p]+ballWidth,ballY[p]+ballHeight,cutPointsX[t],cutPointsY[t],cutPointsX[t+1],cutPointsY[t+1])) if (resting==false) {							resetLine();							t=10000;							p=numBalls;						}				}//t		}//p		for (p=0;p<numCutPoints-1;p++) if (onLine (arrowX,arrowY,cutPointsX[p],cutPointsY[p],cutPointsX[p+1],cutPointsY[p+1])==true) resetLine ();		if (numBalls<1) {		level++;		startLevel();		}}//advan   private final void addRect (int n,int lineX1,int lineY1,int lineX2,int lineY2) {  	int p,t,i;  	int x=0,y=0;  	int x1=0,x2=0,y1=0,y2=0;  	int xx1=0,xx2=0,yy1=0,yy2=0;  	int saveX=0,saveY=0;  	boolean found=false;  	boolean right=false;  	boolean up=false;  	boolean left=false;  	boolean down=false;  	boolean none=false;  	if (lineX1<=lineX2) {			x1=lineX1;			x2=lineX2;			} else {		x1=lineX2;		x2=lineX1;		}		if (lineY1<=lineY2) {			y1=lineY1;			y2=lineY2;		} else {		y1=lineY2;		y2=lineY1;		}		lineX1=x1;		lineX2=x2;		lineY1=y1;		lineY2=y2;		saveX=x1;	saveY=y1;  	if (lineX1==lineX2) {		if (lineY2-lineY1<=1) none=true;		for (p=0;p<numPolyBPoints;p++) {		if (p!=n) if (polyBX[p]==lineX1+1) none=true;

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -