首页>代码>java swing贪吃蛇小游戏>/代码部分--以工作空间的形式打开此文件夹/贪吃蛇/src/贪吃蛇/food.java
package 贪吃蛇;

public class food {
	int id;
	int x;
	int y;
	public food() {
		this((int)(80*Math.random()),(int)(80*Math.random()));
	}
	public food(int x,int y) {
		this((int)(1000*Math.random()),x,y);
		
	}
	//生成食物并不在蛇的身上
	public food(int id,int x,int y) {
		this.id=id;
		this.x=x;
		this.y=y;
		
	}
	public dop checkfood(dop[] d) {//递归运算
		dop dd=new dop(0,x,y);
		for(int n=0;n<d.length;n++) {
			if(d[n].getx()==x&&d[n].gety()==y) {
				x=(int) (80*Math.random());y=(int)(80*Math.random());
				dd=checkfood((d));
			}
		}
		return dd;
		
	}

}
最近下载更多
爱情戴罪的羔羊  LV7 4月2日
微信网友_6798355699273728  LV1 2023年12月28日
kuknkk  LV1 2023年12月27日
koichenchen  LV1 2023年11月3日
2949957869  LV1 2023年10月31日
luo110012  LV9 2023年5月15日
微信网友_6268131861106688  LV5 2022年12月21日
总有人间一两风  LV8 2022年12月12日
1h2k3q  LV1 2022年11月29日
微信网友_6190732568825856  LV1 2022年10月25日
最近浏览更多
爱情戴罪的羔羊  LV7 4月2日
下课了 1月14日
暂无贡献等级
782629583 1月3日
暂无贡献等级
微信网友_6798355699273728  LV1 2023年12月28日
kuknkk  LV1 2023年12月27日
lshlsh 2023年12月27日
暂无贡献等级
zhihong fan  LV2 2023年12月26日
bangyiyang  LV2 2023年12月21日
jxd2007kl  LV2 2023年11月29日
koichenchen  LV1 2023年11月3日
顶部 客服 微信二维码 底部
>扫描二维码关注最代码为好友扫描二维码关注最代码为好友