huabu1.java

来自「木乃伊 游戏原代码 木乃伊 游戏原代码」· Java 代码 · 共 679 行 · 第 1/2 页

JAVA
679
字号
					isWalk =true;
			}
			keep = false;
			Thread th = new Thread(this);
			th.start();
		} else if (gameKey ==Canvas.DOWN) {
			der = 2;
			if (qiang[guan][y][x] % 10 == 0) {
					y++;
					isWalk =true;
			}
			keep = false;
			Thread th = new Thread(this);
			th.start();
		} else if (gameKey ==Canvas.UP) {
			der = 0;
			if (qiang[guan][y][x] %1000/100 == 0) {
					y--;
					isWalk =true;
			}
			keep = false;
			Thread th = new Thread(this);
			th.start();
			}
		}
	}
	private void mnyWalk(){
		boolean iswalk = false;
		if(x1>x&&y1>y){
			derm=3;
			if (qiang[guan][y1][x1] / 1000 == 0) {
				x1--;
				iswalk = true;
			}else {
				derm=0;
				if(qiang[guan][y1][x1] % 1000 / 100 == 0){
					y1--;
					iswalk = true;
				}
			}
		}else if(x1<x&&y1>y){
			derm=1;
			if (qiang[guan][y1][x1]%100/10 == 0) {
				x1++;
				iswalk = true;
			}else {
				derm=0;
				if(qiang[guan][y1][x1] % 1000 / 100 == 0){
					y1--;
					iswalk = true;
				}
			}
		}else if(x1>x&&y1<y){
			derm=3;
			if (qiang[guan][y1][x1] / 1000 == 0) {
				x1--;
				iswalk = true;
			}else {
				derm=2;
				if(qiang[guan][y1][x1] % 10 == 0){
					y1++;
					iswalk = true;
				}
			}
		}else if(x1<x&&y1<y){
			derm=1;
			if (qiang[guan][y1][x1] % 100/10 == 0) {
				x1++;
				iswalk = true;
			}else {
				derm=2;
				if(qiang[guan][y1][x1] % 10 == 0){
					y1++;
					iswalk = true;
				}
			}
		}else if(x1>x&&y1==y){
			derm=3;
			if (qiang[guan][y1][x1] /1000 == 0) {
				x1--;
				iswalk = true;
			}
		}else if(x1<x&&y1==y){
			derm=1;
			if (qiang[guan][y1][x1] % 100/10 == 0) {
				x1++;
				iswalk = true;
			}
		}else if(x1==x&&y1>y){
			derm=0;
			if (qiang[guan][y1][x1]%1000/100== 0) {
				y1--;
				iswalk = true;
				}
		}else if(x1==x&&y1<y){
			derm=2;
			if (qiang[guan][y1][x1]%10== 0) {
				
				y1++;
				iswalk = true;
			}
		}
		if(iswalk){
			for(int i = 0;i<3;i++){
				mnyIndex = i;
				repaint();
				try {
					Thread.sleep(100);
				} catch (Exception e) {
					// TODO: handle exception
					e.printStackTrace();
				}
			}
		}
	}
	public void run(){
		
		if(isWalk){
			for(int i=0;i<3;i++){
				renIndex =i;
				repaint();
				try {
					Thread.sleep(100);
				} catch (Exception e) {
					// TODO: handle exception
				}
			}
			isWalk = false;
		}
		if(guan == 0 && y == -1){
			Alert alt = new Alert("");
			try {
				Image guan2 = Image.createImage("/No_2.png");
				alt.setImage(guan2);
				
			} catch (Exception e) {
				// TODO: handle exception
				System.out.println(e);
			}
			alt.setTimeout(1500);
			guan=1;
			x = 2;
			y = 2;
			x1 = 0;
			y1 = 0;
			der = 1;
			derm = 2;
			renIndex = 2;
			mnyIndex = 2;
			dearIndex = 2;
			isWalk = false;
			alive = true;
			keep = true;
			//leve21 = new HuaBu2(display,ming1);
			display.setCurrent(alt,this);
			return;
		}
		if(guan == 1 && y == -1){
			Alert alt = new Alert("");
			try {
				Image guan2 = Image.createImage("/No_3.png");
				alt.setImage(guan2);
				
			} catch (Exception e) {
				// TODO: handle exception
			}
			alt.setTimeout(1500);
			guan=2;
			x = 1;
			y = 1;
			x1 =1;
			y1 = 3;
			der = 0;
			derm = 2;
			renIndex=2;
			mnyIndex=2;
			dearIndex=2;
			isWalk= false;
			alive= true;
			keep=true;
			
			//leve21 = new HuaBu2(display,ming1);
			display.setCurrent(alt,this);
			return;
		}
		if(guan==2&&y == 6){
			Alert alt = new Alert("");
			try {
				Image guanvictry = Image.createImage("");
				alt.setImage(guanvictry);
				
			} catch (Exception e) {
				// TODO: handle exception
			}
			alt.setTimeout(200);
			
			leveover = new HuaBuover(display);
			display.setCurrent(alt,leveover);
			return;
		}
		
		mnyWalk();
		mnyWalk();
		if(guan==0&&x1==x&&y1==y){
			alive = false;
			derm = 4;
			
			for(int i=0;i<3;i++){
				dearIndex =i;
				repaint();
				try {
					Thread.sleep(300);
				} catch (Exception e) {
					// TODO: handle exception
				}
			}
			try {
				Thread.sleep(900);
			} catch (Exception e) {
				// TODO: handle exception
			}
			x = 5;
			y = 1;
			x1 =1;
			y1 = 5;
			der = 2;
			derm = 0;
			renIndex=2;
			mnyIndex=2;
			dearIndex=2;
			isWalk= false;
			alive= true;
			ming1++;
			if(ming1==4){
				Alert alt = new Alert("");
				try {
					Image gameover = Image.createImage("/youdead.png");
					alt.setImage(gameover);
				} catch (Exception e) {
				// TODO: handle exception
				}
				alt.setTimeout(2500);
				menu = new start(display);
				display.setCurrent(alt,menu);
			}
		}
		if(guan==1&&x1==x&&y1==y){
			alive = false;
			derm = 4;
			
			for(int i=0;i<3;i++){
				dearIndex =i;
				repaint();
				try {
					Thread.sleep(300);
				} catch (Exception e) {
					// TODO: handle exception
				}
			}
			try {
				Thread.sleep(900);
			} catch (Exception e) {
				// TODO: handle exception
			}
			x = 2;
			y = 2;
			x1 = 0;
			y1 = 0;
			der = 1;
			derm = 2;
			renIndex=2;
			mnyIndex=2;
			dearIndex=2;
			isWalk= false;
			alive= true;
			ming1++;
			if(ming1==4){
				Alert alt = new Alert("");
				try {
					Image gameover = Image.createImage("/youdead.png");
					alt.setImage(gameover);
				
				} catch (Exception e) {
				// TODO: handle exception
				}
				alt.setTimeout(2500);
				menu = new start(display);
				display.setCurrent(alt,menu);
			}
		}
		if(guan==2&&x1==x&&y1==y){
			alive = false;
			derm = 4;
			
			for(int i=0;i<3;i++){
				dearIndex =i;
				repaint();
				try {
					Thread.sleep(300);
				} catch (Exception e) {
					// TODO: handle exception
				}
			}
			try {
				Thread.sleep(900);
			} catch (Exception e) {
				// TODO: handle exception
			}
			x = 1;
			y = 1;
			x1 =1;
			y1 = 3;
			der = 0;
			derm = 2;
			renIndex=2;
			mnyIndex=2;
			dearIndex=2;
			isWalk= false;
			alive= true;
			ming1++;
			if(ming1==4){
				Alert alt = new Alert("");
				try {
					Image gameover = Image.createImage("/youdead.png");
					alt.setImage(gameover);
				
				} catch (Exception e) {
				// TODO: handle exception
				}
				alt.setTimeout(2500);
				menu = new start(display);
				display.setCurrent(alt,menu);
			}
		}
		keep = true;
		repaint();	
	}
}

⌨️ 快捷键说明

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