首页>代码>java swing开发打飞机的小游戏源代码下载>/PlaneGame/src/com/leng/role/MyPlan.java
/**
 * 
 */
package com.leng.role;

import java.awt.Image;

import javax.swing.JOptionPane;

import com.leng.Util.Kbordlistener;
import com.leng.frame.battleGame;

/**
 * 我的灰机
 *@author 黄昏的阳光
 * 2013-8-31
 */
public class MyPlan extends Monster {
	/**灰机的图片*/
	public static Image  myplanImage;
	/**发子弹的计数器*/
	private int count;

	public MyPlan(int x, int y) {
		super(x, y, 30, 20, 6);
	}

	@Override
	public void move() {
		this.img=myplanImage;
		this.setDie();
		count++;
		if(count>30){
			count=0;
			battleGame.list.add(new MyBull(this.X+10, this.Y, 10));
		}
		
		
		if (Kbordlistener.isUp) {
			if (this.Y > 30) {
				this.Y -= this.speed;
			}
		}
		if (Kbordlistener.isDown) {
			if (this.Y < 560) {
				this.Y += this.speed;
			}
		}
		if (Kbordlistener.isLeft) {
			if (this.X > 0) {
				this.X -= this.speed;
			}
		}
		if (Kbordlistener.isRight) {
			if (this.X < 250) {
				this.X += this.speed;
			}
		}
		
	}
	/**判断是否和玩家相撞  如果相撞 打印出玩家得分 并且游戏结束*/
	private void setDie(){
		for(int i=0;i<battleGame.list.size();i++){
			  Monster m=battleGame.list.get(i);
			  if(m!=null){
				  if(m instanceof SuperMonster && this.rect.intersects(m.rect)){
					  JOptionPane.showMessageDialog(null, "游戏结束、得分:"+battleGame.pointer);
					  battleGame.isRun=false;
					  System.exit(0);
				  }
			  }
		}
	}

}
最近下载更多
微信网友_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日
最近浏览更多
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日
暂无贡献等级
SILKYYY 2023年5月25日
暂无贡献等级
yangyanlong  LV1 2023年5月19日
小安同学  LV7 2023年5月11日
顶部 客服 微信二维码 底部
>扫描二维码关注最代码为好友扫描二维码关注最代码为好友