zd.java

来自「坦克大战类游戏实现坦克的基本功能控制坦克地图行走」· Java 代码 · 共 81 行

JAVA
81
字号
import javax.microedition.lcdui.Image;
import javax.microedition.lcdui.game.Sprite;

public class ZD extends Sprite 
{
	int m,v;
	public ZD(Image im,int w,int h)
	{
		super(im,w,h);
		
		v=15;
		this.setVisible(false);
	}
	public void create(int x,int y,int m1)
	{
		m=m1;
		this.setVisible(true);
		this.setPosition(x,y);
	}
	public void destroy()
	{
		this.setVisible(false);
	}
	public void move(BJ bj,MC mc)
	{
		if(this.isVisible()==true)
		{
			if(m==0)
			{
				this.move(0,-v);
				if(this.collidesWith(bj,true)==true)
				{
					destroy();
					for(int i1=0;i1<10;i1++)
					{
					mc.bao[i1].create(this.getX()-12,this.getY()-11);
					}
				}
			}
			if(m==1)
			{
				this.move(0,v);
				if(this.collidesWith(bj,true)==true)
				{
					destroy();
					for(int i1=0;i1<10;i1++)
					{
					mc.bao[i1].create(this.getX()-12,this.getY()-11);
					}
				}
			}
			if(m==2)
			{
				this.move(-v,0);
				if(this.collidesWith(bj,true)==true)
				{
					destroy();
					for(int i1=0;i1<10;i1++)
					{
					mc.bao[i1].create(this.getX()-12,this.getY()-11);
					}
				}
			}
			if(m==3)
			{
				this.move(v,0);
				if(this.collidesWith(bj,true)==true)
				{
					destroy();
					for(int i1=0;i1<10;i1++)
					{
					mc.bao[i1].create(this.getX()-12,this.getY()-11);
					}
				}
			}
		}
	}

	
}

⌨️ 快捷键说明

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