/**
*
*/
package com.leng.role;
import java.awt.Graphics;
import java.awt.Image;
import java.awt.Rectangle;
import com.leng.frame.battleGame;
/**
* @author 黄昏的阳光
* 2013-8-31
*/
public abstract class Monster {
/**角色的图片*/
protected Image img;
/**x坐标*/
protected int X;
/**y坐标*/
protected int Y;
/**宽*/
protected int width;
/**高*/
protected int height;
/**速度*/
protected int speed;
/**碰撞区域*/
protected Rectangle rect;
/**
* 初始化角色属性
* */
public Monster(int x,int y,int width,int height,int speed) {
this.X=x;
this.Y=y;
this.width=width;
this.height=height;
this.speed=speed;
this.rect=new Rectangle(this.X,this.Y,this.width,this.height);
}
/**绘制自己的方法**/
public void drawMYself(Graphics memoryGraphics){
memoryGraphics.drawImage(this.img, this.X, this.Y, this.width, this.height,null);
this.setRect();
this.move();
this.removeThis();
}
/**
* 让角色的碰撞区域和角色重合
*/
public void setRect(){
this.rect.x=this.X;
this.rect.y=this.Y;
this.rect.width=this.width;
this.rect.height=this.height;
}
/**
* 移动方法
*
*/
public abstract void move();
/**
* 移除自身的方法 角色超出屏幕 自动移除
*/
public void removeThis(){
if(X<-100 || X>700||Y<-200 || Y>700){
battleGame.list.remove(this);
}
}
}
最近下载更多
微信网友_6550471470403584 LV1
2023年7月6日
2017143155 LV12
2023年6月27日
yangyanlong LV1
2023年5月19日
1739332236 LV1
2023年2月23日
冯不二 LV1
2023年2月13日
可是不知道么 LV23
2021年11月29日
thinkerkkk LV2
2021年6月22日
ldx1234 LV4
2021年5月22日
benbosn LV15
2021年5月5日
躁 LV1
2021年4月14日
最近浏览更多
yanqinwu LV3
5月6日
鬼屋报道 LV3
2024年6月1日
ClydeSon LV5
2023年12月28日
1112WHQ LV7
2023年11月3日
jiemomo LV12
2023年10月19日
微信网友_6568795145506816 LV1
2023年7月19日
微信网友_6550471470403584 LV1
2023年7月6日
2017143155 LV12
2023年6月26日
微信网友_6500694620852224
2023年6月1日
暂无贡献等级
SILKYYY
2023年5月25日
暂无贡献等级

