⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 enemy.java

📁 这是本人及团队成员用j2me开发的手机游戏《骑士荣耀》
💻 JAVA
📖 第 1 页 / 共 2 页
字号:
package rpg_demo_P;

import javax.microedition.lcdui.Graphics;
import javax.microedition.lcdui.Image;
import javax.microedition.lcdui.game.Sprite;
import java.lang.String;

                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                      
public class Enemy extends Sprite
{
	public String name;                       //名字
	public int lev;                           //等级
	public int attack;                        //攻击
	public int fy;                            //防御
	public int hp,hp_max;                         //生命
	public int speed;                         //速度
	public int nx,ny;                         //坐标
	public int  w_Frame,h_Frame;              //切割长高							
	public int TimeNum ;				      //形为的延时控制
	public int JustF[];                       //插入帧
	private int zt;                           //状态
	private int i;
	private final static int ENEMY_STOP=0;    //     ┓
	private final static int ENEMY_UP=1;      //     │
	private final static int ENEMY_DOWN=2;    //     │
	private final static int ENEMY_LEFT=3;    //     │
	private final static int ENEMY_RIGHT=4;   //	    }索引		
	private final static int ATTACK_UP=5;     //     │
	private final static int ATTACK_DOWN=6;   //     │
	private final static int ATTACK_LEFT=7;   //     │
	private final static int ATTACK_RIGHT=8;  //     ┛
	
	
	
	public Enemy(Image img,int w_Frame,int h_Frame,int lev,int attack,int fy,int hp,int speed,int nx,int ny,String name)
	{  //构造函数
		super(img,w_Frame,h_Frame);
		this.w_Frame=w_Frame;
		this.h_Frame=h_Frame;
		this.name=name;
		this.lev=lev;
		this.attack=attack;
		this.fy=fy;
		this.hp=hp_max=hp;
		this.nx=nx;
		this.ny=ny;
		this.speed=speed;
		this.setPosition(this.nx, this.ny);
	}
	
        

	
										
	public  void Enemy_HURT(int hero_attack)                    //被攻击时数据修改
	{            
			
		hp=hp-hero_attack+fy;
	}
	
		
		
		
	public void Enemy_WALK(int[] Frame)                         //Enemy的行走动作
	{              
		if(this.JustF != Frame)				                   //设定帧动画
		{
			this.JustF = Frame;
			this.setFrameSequence(this.JustF);
		}     
		   
		this.nextFrame();
	}
		
		
		
				
	public void Enemy_ATTACK(int[] Frame)                           //Enemy攻击动作
	{            
		if(this.JustF != Frame)								        //设定帧动画
		{
			this.JustF = Frame;
			this.setFrameSequence(this.JustF);
			
		}
		
		else this.nextFrame();
		
		if(this.getFrame()==0){
			if(i++%3==0)
			Player_RPG.hp=Player_RPG.hp-attack+Player_RPG.fy;
			if(i/3000==1)i=1;
		//System.out.println("Player_RPG.hp="+Player_RPG.hp);
		}
		
	}		                   
	
	
	
	public void DrawState(Graphics g,int nx,int ny,String name)       //血条

⌨️ 快捷键说明

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