pl.java

来自「用j2me做的空战游戏.多npc,碰撞,特效,道具都有!推荐下载」· Java 代码 · 共 86 行

JAVA
86
字号
import java.io.IOException;

import javax.microedition.lcdui.Graphics;
import javax.microedition.lcdui.Image;

public class PL 
{
	Image im;
	int x,y,m,hp;
	public PL()
	{
		hp=1;
		x = 84;
		y = 175;
		try {
			im = Image.createImage( "/player.png");
		} catch (IOException e) {
			// TODO 自动生成 catch 块
			e.printStackTrace();
		}
		m = 0;
	}
	public void render(Graphics g,boolean l,boolean r)
	{
		if (l == true)
		{
			Tools.paintImage( g,im,x,y,0,0,16,27);
		}
		else if (r == true)
		{
			Tools.paintImage( g,im,x,y,41,0,16,27);
		}
		else
		{
			Tools.paintImage( g,im,x,y,16,0,25,27);
		}
	}
	public void upData(boolean u,boolean d,boolean l,boolean r)
	{
		if (m == 0)
		{
			if (u == true)
			{
				y-=5;
				if (y < 0)
				{
					y += 5;
				}
			}
			if (d == true)
			{
				y+=5;
				if (y >188)
				{
					y -= 5;
				}
			}
			
			if (l == true)
			{
				x-=5;
				if (x < 0)
				{
					x += 5;
				}
			}
			
			if (r == true)
			{
				x+=5;
				if (x > 160)
				{
					x -= 5;
				}
			}
		}
		
		else 
		{
			y -=5;
			m--;
		}
	}
	
}

⌨️ 快捷键说明

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