package com.zte;
import java.awt.Graphics;
import javax.swing.ImageIcon;
public class Fish {
public int x;//横坐标
public int y;//纵坐标
public int imgNum = 0;//当前显示的图片下标
public ImageIcon imgs[];//鱼的图片
public boolean isCatch = false;//是否被捕
boolean isMove = true;
public ImageIcon[] imgsCatch;
public int road=0;//移动路线
public int step = 2;//移动的速度
public int timeThread = 30;
FishPanel panel;
public static int right_to_left = 1;
public static int up_to_buttom = 2;
public static int left_to_right = 3;
public int money;//每种鱼获得的金币
public int hp;//血量
public Fish(FishPanel panel){
this.panel = panel;
}
//画鱼的图片
public void drawFish(Graphics g) {
if(isCatch){
g.drawImage(imgsCatch[imgNum%2].getImage(), x, y,panel);
}else{
g.drawImage(imgs[imgNum%10].getImage(), x, y,panel);
}
}
//鱼游动
public void move(){
//如果没被捕
if(!isCatch){
switch(road){
case 1:
x = x-step;
if(x<-imgs[imgNum].getIconWidth()){
panel.fishs.remove(this);
}
break;
case 2:
y = y + step;
if(y>panel.getHeight()){
panel.fishs.remove(this);
}
break;
case 3:
x = x+step;
if(x>panel.getWidth()){
panel.fishs.remove(this);
}
break;
}
}else{//抓住就移除
panel.fishs.remove(this);
}
imgNum++;
if(imgNum>=imgs.length && !isCatch){
imgNum = 0;
}
if(imgNum>=imgsCatch.length && isCatch){
imgNum = 0;
}
panel.repaint();
}
}
最近下载更多
最近浏览更多
llqq114 LV10
7月30日
微信网友_7550620088864768 LV1
6月12日
Mitsune LV1
5月26日
long123_356 LV8
5月24日
dengjing LV5
2月5日
linyintan
2024年11月13日
暂无贡献等级
rs2222
2024年11月12日
暂无贡献等级
1661950467 LV2
2024年10月12日
微信网友_7077219745763328
2024年7月12日
暂无贡献等级
puppyoo LV1
2024年7月1日

