亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频

? 歡迎來到蟲蟲下載站! | ?? 資源下載 ?? 資源專輯 ?? 關于我們
? 蟲蟲下載站

?? enemy2.java

?? 簡易的坦克程序
?? JAVA
字號:
import java.awt.*;

public class Enemy2{
	// control varibles
	private final int UP = 0;
	private final int DOWN = 1;
	private final int LEFT = 2;
	private final int RIGHT = 3;
	// Physical information about the enemy tank
	private int speed;
	private int interval;
	private int destination = 1;
	private final int SIZE = 12;
	private int xPos, yPos, xVPos, yVPos;
	// borders
	private Rectangle E1, EV1;
	private Rectangle border = new Rectangle(10, 10, 502, 502);
	// others
	private boolean flashing;
	private int falshingTime = 0;

//====================================== the construct method ================================

	public Enemy2(int a, int b){
		if((int)(Math.random()*10) > 6)
			destination = (int)(Math.random()*4);
		interval = (int)(Math.random()*300);
		xPos = a;
		yPos = b;
		xVPos = a;
		yVPos = b;
		E1 = new Rectangle(xPos - SIZE, yPos - SIZE, 25, 25);
		EV1 =  new Rectangle(xVPos - SIZE, yVPos - SIZE, 25, 25);
	}

//================================================ move ======================================

	public void move(Tank tank, Enemy1[] e1, Enemy2[] e2, Enemy3[] e3, Enemy4[] e4, int index, wall[] Wall, Steelwall[] SteelWall, river[] River, int timestop){
		if(speed < 4)
			speed++;

		if(flashing)
			falshingTime++;

		// Enemy2 border vs. environment border
		boolean notoutofborder = true;
		if(xPos - SIZE - speed < border.x + 1 && destination == LEFT){
			xPos = border.x + 1 + SIZE;
			notoutofborder = false;
		}
		if(xPos + SIZE + speed> border.x + border.width - 1 && destination == RIGHT){
			xPos = border.x + border.width - 2 - SIZE;
			notoutofborder = false;
		}
		if(yPos - SIZE - speed < border.y + 1 && destination == UP){
			yPos = border.y + 1 + SIZE;
			notoutofborder = false;
		}
		if(yPos + SIZE + speed> border.y + border.height - 1 && destination == DOWN){
			yPos = border.y + border.height - 2 - SIZE;
			notoutofborder = false;
		}


		// Enemy2 border vs. Tank border
		boolean canmoveup = true, canmovedown = true, canmoveleft = true, canmoveright = true;
		Rectangle tankborder = tank.getBorder();
		if(tankborder.contains(xPos + 1, yPos - 12 - speed) || tankborder.contains(xPos - 1, yPos - 12 - speed)){
			canmoveup = false;
			while(destination == 0)
				destination = (int)(Math.random()*4);
			yPos = tank.getyPos() + 25;
		}
		if(tankborder.contains(xPos + 1, yPos + 12 + speed) || tankborder.contains(xPos - 1, yPos + 12 + speed)){
			canmovedown = false;
			while(destination == 1)
				destination = (int)(Math.random()*4);
			yPos = tank.getyPos() - 25;
		}
		if(tankborder.contains(xPos - 12 - speed, yPos + 1) || tankborder.contains(xPos - 12 - speed, yPos - 1)){
			canmoveleft = false;
			while(destination == 2)
				destination = (int)(Math.random()*4);
			xPos = tank.getxPos() + 25;
		}
		if(tankborder.contains(xPos + 12 + speed, yPos + 1) || tankborder.contains(xPos + 12 + speed, yPos - 1)){
			canmoveright = false;
			while(destination == 3)
				destination = (int)(Math.random()*4);
			xPos =tank.getxPos() - 25;
		}

		// Enemy2 border vs. enemie1 borders
		Rectangle Enemy1;
		for(int i = 0; i < e1.length; i++){
			if(e1[i] != null){
				Enemy1 = e1[i].getE1();
				if(Enemy1.contains(xPos + 1, yPos - 12 - speed) || Enemy1.contains(xPos - 1, yPos - 12 - speed)){
					canmoveup = false;
					while(destination == 0)
						destination = (int)(Math.random()*4);
					yPos = e1[i].getyVPos() + 25;
				}
				if(Enemy1.contains(xPos + 1, yPos + 12 + speed) || Enemy1.contains(xPos - 1, yPos + 12 + speed)){
					canmovedown = false;
					while(destination == 1)
						destination = (int)(Math.random()*4);
					yPos = e1[i].getyVPos() - 25;
				}
				if(Enemy1.contains(xPos - 12 - speed, yPos + 1) || Enemy1.contains(xPos - 12 - speed, yPos - 1)){
					canmoveleft = false;
					while(destination == 2)
						destination = (int)(Math.random()*4);
					xPos = e1[i].getxVPos() + 25;
				}
				if(Enemy1.contains(xPos + 12 + speed, yPos + 1) || Enemy1.contains(xPos + 12 + speed, yPos - 1)){
					canmoveright = false;
					while(destination == 3)
						destination = (int)(Math.random()*4);
					xPos = e1[i].getxVPos() - 25;
				}
			}
		}

		// Enemy2 border vs. Enwmy2 border
		Rectangle Enemy2;
		for(int i = 0; i < e2.length; i++){
			if(e2[i] != null && i != index){
				Enemy2 = e2[i].getE1();
				if(Enemy2.contains(xPos + 1, yPos - 12 - speed) || Enemy2.contains(xPos - 1, yPos - 12 - speed)){
					canmoveup = false;
					while(destination == 0)
						destination = (int)(Math.random()*4);
					yPos = e2[i].getyVPos() + 25;
				}
				if(Enemy2.contains(xPos + 1, yPos + 12 + speed) || Enemy2.contains(xPos - 1, yPos + 12 + speed)){
					canmovedown = false;
					while(destination == 1)
						destination = (int)(Math.random()*4);
					yPos = e2[i].getyVPos() - 25;
				}
				if(Enemy2.contains(xPos - 12 - speed, yPos + 1) || Enemy2.contains(xPos - 12 - speed, yPos - 1)){
					canmoveleft = false;
					while(destination == 2)
						destination = (int)(Math.random()*4);
					xPos = e2[i].getxVPos() + 25;
				}
				if(Enemy2.contains(xPos + 12 + speed, yPos + 1) || Enemy2.contains(xPos + 12 + speed, yPos - 1)){
					canmoveright = false;
					while(destination == 3)
						destination = (int)(Math.random()*4);
					xPos = e2[i].getxVPos() - 25;
				}
			}
		}
		// Enemy 2 borders vd Enemy3 borders
		Rectangle Enemy3;
		for(int i = 0; i < e3.length; i++){
			if(e3[i] != null){
				Enemy3 = e3[i].getE1();
				if(Enemy3.contains(xPos + 1, yPos - 12 - speed) || Enemy3.contains(xPos - 1, yPos - 12 - speed)){
					canmoveup = false;
					while(destination == 0)
						destination = (int)(Math.random()*4);
					yPos = e3[i].getyVPos() + 25;
				}
				if(Enemy3.contains(xPos + 1, yPos + 12 + speed) || Enemy3.contains(xPos - 1, yPos + 12 + speed)){
					canmovedown = false;
					while(destination == 1)
						destination = (int)(Math.random()*4);
					yPos = e3[i].getyVPos() - 25;
				}
				if(Enemy3.contains(xPos - 12 - speed, yPos + 1) || Enemy3.contains(xPos - 12 - speed, yPos - 1)){
					canmoveleft = false;
					while(destination == 2)
						destination = (int)(Math.random()*4);
					xPos = e3[i].getxVPos() + 25;
				}
				if(Enemy3.contains(xPos + 12 + speed, yPos + 1) || Enemy3.contains(xPos + 12 + speed, yPos - 1)){
					canmoveright = false;
					while(destination == 3)
						destination = (int)(Math.random()*4);
					xPos = e3[i].getxVPos() - 25;
				}
			}
		}
		// Enemy2 border vs. enemie4 borders
		Rectangle Enemy4;
		for(int i = 0; i < e4.length; i++){
			if(e4[i] != null){
				Enemy4 = e4[i].getE1();
				if(Enemy4.contains(xPos + 1, yPos - 12 - speed) || Enemy4.contains(xPos - 1, yPos - 12 - speed)){
					canmoveup = false;
					while(destination == 0)
						destination = (int)(Math.random()*4);
					yPos = e4[i].getyVPos() + 25;
				}
				if(Enemy4.contains(xPos + 1, yPos + 12 + speed) || Enemy4.contains(xPos - 1, yPos + 12 + speed)){
					canmovedown = false;
					while(destination == 1)
						destination = (int)(Math.random()*4);
					yPos = e4[i].getyVPos() - 25;
				}
				if(Enemy4.contains(xPos - 12 - speed, yPos + 1) || Enemy4.contains(xPos - 12 - speed, yPos - 1)){
					canmoveleft = false;
					while(destination == 2)
						destination = (int)(Math.random()*4);
					xPos = e4[i].getxVPos() + 25;
				}
				if(Enemy4.contains(xPos + 12 + speed, yPos + 1) || Enemy4.contains(xPos + 12 + speed, yPos - 1)){
					canmoveright = false;
					while(destination == 3)
						destination = (int)(Math.random()*4);
					xPos = e4[i].getxVPos() - 25;
				}
			}
		}


		// Enemy2 border vs. obstacles borders
		boolean nottouchobstacles = true;
		Rectangle[] Wallborder = new Rectangle[4];
		for(int j = 0; j < Wall.length; j++){
			if(Wall[j] != null){
				Wallborder = Wall[j].detailborder();
				for(int i = 0; i < 4; i++){
					if(Wallborder[i] != null){
						if(E1.intersects(Wallborder[i])){
							if(yPos - SIZE - 7 - speed <= Wallborder[i].y + 6 && destination == 0){
								canmoveup = false;
								nottouchobstacles = false;
								break;
							}
							if(yPos + SIZE + 7 + speed >= Wallborder[i].y + 6 && destination == 1){
								canmovedown = false;
								nottouchobstacles = false;
								break;
							}
							if(xPos - SIZE - 7 - speed <= Wallborder[i].x + 6 && destination == 2){
								canmoveleft = false;
								nottouchobstacles = false;
								break;
							}
							if(xPos + SIZE + 7 + speed >= Wallborder[i].x + 6 && destination == 3){
								canmoveright = false;
								nottouchobstacles = false;
								break;
							}
						}
					}
				}
			}
		}
		for(int j = 0; j < SteelWall.length; j++){
			if(SteelWall[j] != null){
				Wallborder = SteelWall[j].detailborder();
				for(int i = 0; i < 4; i++){
					if(Wallborder[i] != null){
						if(E1.intersects(Wallborder[i])){
							if(yPos - SIZE - 7 - speed <= Wallborder[i].y + 6 && destination == 0){
								canmoveup = false;
								nottouchobstacles = false;
								break;
							}
							if(yPos + SIZE + 7 + speed >= Wallborder[i].y + 6 && destination == 1){
								canmovedown = false;
								nottouchobstacles = false;
								break;
							}
							if(xPos - SIZE - 7 - speed <= Wallborder[i].x + 6 && destination == 2){
								canmoveleft = false;
								nottouchobstacles = false;
								break;
							}
							if(xPos + SIZE + 7 + speed >= Wallborder[i].x + 6 && destination == 3){
								canmoveright = false;
								nottouchobstacles = false;
								break;
							}
						}
					}
				}
			}
		}






		// move
		if(timestop >= 1)
			speed = 0;
		if(notoutofborder && nottouchobstacles){
			if(destination == UP && canmoveup)
				yPos = yPos - speed;
			if(destination == DOWN && canmovedown)
				yPos = yPos + speed;
			if(destination == LEFT && canmoveleft)
				xPos = xPos - speed;
			if(destination == RIGHT && canmoveright)
				xPos = xPos + speed;
			interval = interval - speed;
		}

		for(int i = 0; i < River.length; i++){
			if((River[i].Riverborder()).intersects(E1)){
				xPos = xVPos;
				yPos = yVPos;
				nottouchobstacles = false;
			}
		}

		//change the movement if the enemy tank meet anything that stop its movement
		if(!notoutofborder || !nottouchobstacles || interval <= 0){
			if((int)(Math.random()*10) > 8)
				destination = (int)(Math.random()*4);
			if(destination == 1 || destination == 0)
				xPos = xVPos;
			if(destination == 2 || destination == 3)
				yPos = yVPos;
			interval = (int)(Math.random()*300);
		}

		// the graphical border of the tank
		E1 = new Rectangle(xPos - SIZE, yPos - SIZE, 25, 25);

		// the virtual border of the tank
		int a = (xPos - 10)/25;
		int b = (xPos - 10)%25;
		if(b < 7)
			b = 0;
		if(b > 18)
			b = 25;
		if((b < 19 && b > 6) || xPos < 17 || xPos > 492)
			b = 13;
		xVPos = a*25 + b + 10;
		int c = (yPos - 10)/25;
		int d = (yPos - 10)%25;
		if(d < 7)
			d = 0;
		if(d > 18)
			d = 25;
		if((d < 19 && d > 6) || yPos < 17 || yPos > 492)
			d = 13;
		yVPos = c*25 + d + 10;
		EV1 =  new Rectangle(xVPos - SIZE, yVPos - SIZE, 25, 25);
	}

//========================================= other help methods ===============================
	public int getImageNo(){
		int ImageNo = destination;
		if(flashing && falshingTime%10 > 4)
			ImageNo = destination + 4;
		return ImageNo;
	}

	public int getDirection(){
		return destination;
	}

	public Rectangle getE1(){
		return E1;
	}

	public Rectangle getEV1(){
		return EV1;
	}

	public int getxPos(){
		return xPos;
	}

	public int getyPos(){
		return yPos;
	}

	public int getxVPos(){
		return xVPos;
	}

	public int getyVPos(){
		return yVPos;
	}

	public void flashing(){
		flashing = true;
	}

	public boolean isFlashing(){
		return flashing;
	}

}

?? 快捷鍵說明

復制代碼 Ctrl + C
搜索代碼 Ctrl + F
全屏模式 F11
切換主題 Ctrl + Shift + D
顯示快捷鍵 ?
增大字號 Ctrl + =
減小字號 Ctrl + -
亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频
国产精品五月天| 天天综合日日夜夜精品| 久久品道一品道久久精品| 欧美日韩国产美| 欧美在线观看你懂的| av电影天堂一区二区在线| 国产成人精品综合在线观看| 国产成人无遮挡在线视频| 国产成人在线网站| 丰满亚洲少妇av| 波多野结衣91| 在线观看亚洲精品| 欧美乱妇20p| 日韩免费性生活视频播放| 欧美成人a∨高清免费观看| 欧美一区二区视频观看视频| 日韩一区二区视频在线观看| 亚洲精品在线一区二区| 久久久99精品免费观看不卡| 国产清纯在线一区二区www| 国产精品区一区二区三| 日韩美女精品在线| 亚洲一区二区三区精品在线| 午夜不卡av免费| 老司机精品视频导航| 国产精品2024| 91蝌蚪porny成人天涯| 精品视频在线免费看| 日韩一区二区三区视频| 久久久久9999亚洲精品| 亚洲特黄一级片| 婷婷成人综合网| 国产一区美女在线| 成人国产精品免费| 欧美日韩在线观看一区二区 | 日韩高清不卡在线| 久久国产麻豆精品| 成人av在线播放网址| 91福利视频在线| 欧美成人免费网站| 国产精品夫妻自拍| 亚洲成人资源网| 国产成人精品免费一区二区| 色哟哟一区二区三区| 777亚洲妇女| 国产欧美日韩在线| 亚洲第一搞黄网站| 国产麻豆精品久久一二三| 91片黄在线观看| 日韩欧美电影一区| 亚洲伦理在线免费看| 麻豆一区二区三区| 91免费视频观看| 日韩亚洲欧美一区| 中文字幕一区在线观看| 日韩vs国产vs欧美| 91色porny在线视频| 欧美一区中文字幕| 一区在线观看免费| 精品亚洲成a人| 欧美在线观看一区二区| 国产亚洲精品精华液| 五月婷婷综合网| 99久久精品免费看国产| 欧美成人精品3d动漫h| 亚洲一区二区3| 暴力调教一区二区三区| 欧美一级生活片| 亚洲综合色噜噜狠狠| 国产成人av电影在线| 欧美日韩国产首页| 亚洲欧美一区二区久久| 国产中文字幕精品| 欧美精品 日韩| 伊人性伊人情综合网| 丁香亚洲综合激情啪啪综合| 欧美一区二区美女| 亚洲成人av一区二区| 欧美专区日韩专区| 亚洲一区二区三区四区五区黄 | 综合久久给合久久狠狠狠97色 | 国产成人精品三级麻豆| 欧美日韩国产美| 精品久久久久香蕉网| 国产精品1区2区3区| 欧美精品色一区二区三区| 精品久久一区二区| 日韩成人av影视| 欧美精品一区二区三区四区| 经典三级一区二区| 欧美不卡一二三| 日韩欧美亚洲一区二区| 亚洲高清不卡在线观看| 一本到三区不卡视频| 国产女人aaa级久久久级 | 男女男精品视频网| 欧美影片第一页| 亚洲精品videosex极品| 不卡影院免费观看| 欧美国产欧美综合| 国产一区二区不卡| 精品国产一区二区三区av性色| 午夜国产精品影院在线观看| 欧美日韩精品系列| 亚洲a一区二区| 91麻豆精品国产91久久久久久| 亚洲国产精品久久不卡毛片| 在线视频你懂得一区| 亚洲一区二区三区四区五区中文| 在线视频国产一区| 亚洲图片激情小说| 色先锋aa成人| 亚洲国产视频在线| 精品污污网站免费看| 日韩综合一区二区| 欧美一区二区日韩| 激情小说亚洲一区| 国产午夜久久久久| 成人av在线播放网站| 一区二区三区电影在线播| 欧美日韩黄色一区二区| 蜜臂av日日欢夜夜爽一区| ww久久中文字幕| 99re热视频这里只精品 | 成人app下载| 成人免费在线视频观看| 日本韩国视频一区二区| 亚洲精品国产无套在线观| 粉嫩欧美一区二区三区高清影视 | 麻豆专区一区二区三区四区五区| 精品粉嫩超白一线天av| 国产69精品久久久久777| 亚洲啪啪综合av一区二区三区| 欧美曰成人黄网| 蜜桃视频一区二区三区在线观看| 亚洲精品在线电影| 成人的网站免费观看| 一二三区精品视频| 日韩美女主播在线视频一区二区三区| 国产一区二区美女诱惑| 亚洲欧美激情一区二区| 欧美丰满少妇xxxbbb| 国产自产视频一区二区三区| 国产精品免费免费| 欧美日韩国产综合草草| 国产成人激情av| 亚洲一区二区三区国产| 久久久久久久久久美女| 91国偷自产一区二区开放时间 | 欧美日韩国产首页在线观看| 国内精品久久久久影院一蜜桃| 国产精品久久久99| 欧美精品少妇一区二区三区| 风间由美性色一区二区三区| 午夜久久电影网| 国产欧美视频一区二区三区| 懂色av一区二区在线播放| 欧美视频在线一区二区三区 | 韩国中文字幕2020精品| 日本午夜精品视频在线观看 | www久久久久| 精品久久久久久久一区二区蜜臀| 欧美激情一区二区三区四区| 一区二区欧美在线观看| 欧美高清视频一二三区| 成人一区二区三区| 日韩精品欧美精品| 亚洲视频资源在线| 精品国一区二区三区| 色欧美乱欧美15图片| 国产乱码精品一区二区三| 亚洲国产成人av好男人在线观看| 国产无一区二区| 欧美一卡在线观看| 色吊一区二区三区| 国产成人在线视频免费播放| 日韩 欧美一区二区三区| 亚洲欧美欧美一区二区三区| 久久久av毛片精品| 91麻豆精品国产91久久久资源速度 | 亚洲成人综合视频| 国产精品动漫网站| 国产亚洲欧美色| 欧美变态凌虐bdsm| 欧美猛男gaygay网站| 色综合欧美在线| fc2成人免费人成在线观看播放| 久久99日本精品| 日本不卡123| 偷拍日韩校园综合在线| 亚洲综合免费观看高清完整版| 国产精品国产三级国产普通话99| 欧美精品一区二区三区一线天视频| 6080日韩午夜伦伦午夜伦| 在线视频观看一区| 一本色道久久综合亚洲91 | 久久精品水蜜桃av综合天堂| 日韩视频在线你懂得| 欧美一区二区三区小说| 91精品国产91久久久久久最新毛片 |