import java.io.ByteArrayInputStream;
import java.io.ByteArrayOutputStream;
import java.io.DataInputStream;
import java.io.DataOutputStream;
import java.io.IOException;
import java.util.Random;
import java.util.Timer;
import java.util.TimerTask;
import java.util.Vector;
import javax.microedition.lcdui.*;
import javax.microedition.midlet.*;
import javax.microedition.rms.*;
import Fish.GameScreen.moveTask;
public class Fish extends MIDlet implements CommandListener{
private GameScreen gameScreen;
private StartScreen startScreen;
private List list;
private Command Yes,Exit;
private String selected;
private RecordStore rs=null; //record***************
private String STORE_NAME="Shit~",name,winner;
private int bestScore;
private Form form,intrForm;
private TextBox tb;
private Command yes,OK;
private boolean running;
public Fish() throws Exception{
String[] choices={"Start","Record","Introduction","leftGame"};
list=new List("---Fishing---",List.IMPLICIT,choices,null);
Yes=new Command("Yes",Command.OK,2);
Exit=new Command("Exit",Command.EXIT,1);
list.addCommand(Exit);
list.addCommand(Yes);
list.setCommandListener(this);
form=new Form("BEST RCORE");
tb=new TextBox("Enter the name:","",8,TextField.ANY);
yes=new Command("Yes",Command.OK,2);
OK = new Command("OK",Command.EXIT,1);
form.addCommand(OK);
form.setCommandListener(this);
tb.addCommand(yes);
tb.setCommandListener(this);
intrForm=new Form("introduction");
intrForm.append("左右键或4,6键控制钓鱼,大鱼20分,小鱼30分,屎-15分,拿到祝福正在上升的泥土会下降小小");
intrForm.addCommand(OK);
intrForm.setCommandListener(this);
}
public void commandAction(Command command,Displayable displayable)
{
if(command==List.SELECT_COMMAND || command==Yes)
{
selected=list.getString(list.getSelectedIndex());
if(selected.equals("Start"))
{
running=true; //初始化所有数据
activateGameScreen();
}
if(selected.equals("Record"))
{
try //***************Load***************************
{
form.deleteAll();
rs=RecordStore.openRecordStore(STORE_NAME,false);
ByteArrayInputStream byteInputStream =new ByteArrayInputStream(rs.getRecord(1));
DataInputStream dataInputStream=new DataInputStream(byteInputStream);
bestScore=dataInputStream.readInt();
winner=dataInputStream.readUTF();
form.append("最高分:"+bestScore+"/n玩家:"+winner); //记录中的最高分
dataInputStream.close();
byteInputStream.close();
}
catch(RecordStoreNotFoundException rse)
{} //*****************End Load***********************
catch (RecordStoreFullException e) {}
catch (RecordStoreException e) {}
catch (IOException e) {}
Display.getDisplay(this).setCurrent(form);
}
if(selected.equals("Introduction"))
{
Display.getDisplay(this).setCurrent(intrForm);
}
if(selected.equals("leftGame"))
{
try {
destroyApp(false);
notifyDestroyed();
} catch (MIDletStateChangeException e) {
// TODO 自动生成 catch 块
e.printStackTrace();
}
}
}
if(command==Exit)
{
timer.cancel();
running=false;
Display.getDisplay(this).setCurrent(list);//startScreen
}
if(command==yes)
{
name=tb.getString();
try //**************Save********************
{
rs=RecordStore.openRecordStore(STORE_NAME,true);
// System.out.println("openRecord");
ByteArrayOutputStream byteOutputStream=new ByteArrayOutputStream();
DataOutputStream dataOutputStream=new DataOutputStream(byteOutputStream);
dataOutputStream.writeInt(score);
dataOutputStream.writeUTF(name);
form.deleteAll();
form.append("score:"+score+"/nname:"+name);
dataOutputStream.flush();
byte[] recordOut=byteOutputStream.toByteArray();
try
{
rs.setRecord(1,recordOut,0,recordOut.length);
}
catch(InvalidRecordIDException ir)
{
rs.addRecord(recordOut,0,recordOut.length);
}
dataOutputStream.close();
byteOutputStream.close();
}
catch(RecordStoreException rse)
{
} //***************End Save***********************
catch (IOException e) {
e.printStackTrace();
}
Display.getDisplay(this).setCurrent(form);
}
if(command==OK)
{
Display.getDisplay(this).setCurrent(list);
}
}
//********************************开始画面*********************************//
public class StartScreen extends Canvas implements Runnable
{
private Image ss;
public StartScreen()
{
try
{
ss=Image.createImage("/1.png");
}
catch(IOException e)
{}
offScreenBuffer=Image.createImage(getWidth(),getHeight());
}
private boolean running2=true;
protected void paint(Graphics graphics) {
rruunn();
graphics.drawImage(offScreenBuffer,getWidth()/2,getHeight()/2,Graphics.HCENTER|Graphics.VCENTER);
}
private void rruunn()
{
Graphics gr=offScreenBuffer.getGraphics();
gr.drawImage(ss,0,0,Graphics.LEFT|Graphics.TOP);
}
protected void keyPressed(int keyCode) //按键时
{
running2=false;
GameList();
}
public void run() {
while(running2)
{
repaint();
}
}
}
//******************************开始画面^完^******************************//
protected void startApp() throws MIDletStateChangeException { //**********显示3个界面**************
startScreen=new StartScreen();
Display.getDisplay(this).setCurrent(startScreen);
}
public void GameList()
{
Display.getDisplay(this).setCurrent(list);
}
public void activateGameScreen()
{
gameScreen=new GameScreen(this);
Display.getDisplay(this).setCurrent(gameScreen);
timer.schedule(task,100,100); //隔X秒调用一次Gold,Shit,Diamond随机出现
running=true;
gameScreen.addCommand(Exit);
gameScreen.setCommandListener(this);
}
public void gameOver() //*********GmaeOver***************//
{
timer.cancel();
running=false;
try //***************Load***************************
{
form.deleteAll();
rs=RecordStore.openRecordStore(STORE_NAME,false);
ByteArrayInputStream byteInputStream =new ByteArrayInputStream(rs.getRecord(1));
DataInputStream dataInputStream=new DataInputStream(byteInputStream);
bestScore=dataInputStream.readInt();
winner=dataInputStream.readUTF();
form.append("最高分:"+bestScore+"/n玩家:"+winner); //记录中的最高分
dataInputStream.close();
byteInputStream.close();
}
catch(RecordStoreNotFoundException rse) //无记录时写新的记录
{
Display.getDisplay(this).setCurrent(tb);
} //*****************End Load***********************
catch (RecordStoreFullException e) {}
catch (RecordStoreException e) {}
catch (IOException e) {}
if(bestScore<score) //现有分数比记录分数高
{
Display.getDisplay(this).setCurrent(tb);
}
else //现有记录比得分高
{
Display.getDisplay(this).setCurrent(form);
}
}
public void close()
{
try
{
destroyApp(true);
}
catch(MIDletStateChangeException e)
{}
}
//*******************************游戏主程序***********************************//
private Image offScreenBuffer;
private static int statusLineHeight=10;
private int laneHeight=0;
private static final int topMargin=3;
private Timer timer;
private moveTask task;
private int soilHeight;
private int changetime; //设置Gold,Shit,Diamond 3个角色嘅变化时间
private int linex1, liney1; //设置两条直线嘅数据
private int linex1change=1,liney1change=1;
private int linex2,liney2;
private int linex2change,liney2change;
private boolean line1Press,line2Press;
private int linex1P,liney1P,linex2P,liney2P;
private int line1state,line2state; //line1状态 1为正在伸长,0为缩短,3为移动中
private int score,g1,d1,s1,g2,d2,s2; //得分
private int zfX,zfY;
private Image goldpic; //图像定义
private Image shitpic;
private Image diamondpic;
private Image soilpic,water;
private Image hook1,hook2;
private Image zhufu;
private Image leftboat,rightboat;
public class GameScreen extends Canvas implements Runnable
{
private Fish theMidlet;
private Vector actorList;
private GoldActor gold[]=new GoldActor[5]; //定义数组放图像,各类对象
private ShitActor shit[]=new ShitActor[6];
private DiamondActor diamond[]=new DiamondActor[3];
private SoilActor soil;
private Line1Actor line1;
private ZhufuActor zf;
public GameScreen(Fish midlet) {
theMidlet=midlet;
Thread t=new Thread(this);
timer=new Timer();
task=new moveTask();
t.start();
linex1=getWidth()/2-30; liney1=40; //设置两条直线嘅数据 gameScreen.getWidth()/2-30
linex1change=-1;liney1change=-1;
linex2=getWidth()/2+30;liney2=40; //gameScreen.getWidth()/2+30
linex2change=1;liney2change=-1;
line1Press=false;line2Press=false;
line1state=3;line2state=3; //line1状态 1为正在伸长,0为缩短,3为移动中
score=0;g1=0;d1=0;s1=0;g2=0;d2=0;s2=0; //得分
zfX=getWidth()+20;zfY=getHeight()*2/3; //gameScreen.getWidth() gameScreen.getHeight()/3
soilHeight=getHeight(); //gameScreen.getWidth()
changetime=0;
initResources();
try //导入图像
{
goldpic=Image.createImage("/fish1.png");
shitpic=Image.createImage("/shit.png");
diamondpic=Image.createImage("/fish2.png");
soilpic=Image.createImage("/soil.png");
hook1=Image.createImage("/hook.png");
hook2=Image.createImage("/hook.png");
// water=Image.createImage("/water.png");
zhufu=Image.createImage("/zhufu.png");
leftboat=Image.createImage("/leftboat1.png");
rightboat=Image.createImage("/rightboat1.png");
}
catch(IOException ioe)
{
System.out.print("Shit!!!!!!!!!!!!/n");
}
}
private void initResources()
{
offScreenBuffer=Image.createImage(getWidth(),getHeight());
int heightMinusStatus=getHeight()-statusLineHeight;
laneHeight=((heightMinusStatus)/9);
actorList=new Vector();
Tools xy=new Tools();
for(int i=0;i<5;i++) //增加角色
{
actorList.addElement(gold[i]=new GoldActor(this,xy.getRand(0,getWidth()),xy.getRand(getLaneHeight()*4,getHeight())));
}
for(int i=0;i<6;i++)
{
actorList.addElement(shit[i]=new ShitActor(this,xy.getRand(0,getWidth()),xy.getRand(getLaneHeight()*4,getHeight())));
}
for(int i=0;i<3;i++)
{
actorList.addElement(diamond[i]=new DiamondActor(this,xy.getRand(0,getWidth()),xy.getRand(getLaneHeight()*4,getHeight())));
}
actorList.addElement(soil=new SoilActor(this,getWidth()/2,getHeight()));
actorList.addElement(line1=new Line1Actor(this,getWidth()-30,liney1,getWidth()));
actorList.addElement(zf=new ZhufuActor(this,getWidth(),zfY));
}
protected void paint(Graphics graphics) {
renderWorld();
graphics.drawImage(offScreenBuffer,0,0,Graphics.LEFT|Graphics.TOP);
}
private void renderWorld()
{
Graphics osg=offScreenBuffer.getGraphics();
int y=0;
//osg.drawImage(water,getWidth()/2,37,Graphics.HCENTER|Graphics.TOP);//画水
osg.setColor(0x0081b2fc); //计分
y+=(laneHeight)+topMargin;
osg.fillRect(0,0,getWidth(),y);
osg.setColor(0x0041bfa); //得分分隔两条线
osg.drawLine(0,y-2,getWidth(),y-2);
osg.setColor(0x0041bfa);
osg.drawLine(0,y-1,getWidth(),y-1);
osg.setColor(0x00f9f588); //矿工站立块
osg.fillRect(0,y,getWidth(),laneHeight);
osg.setColor(0x006d7afc); //水第一
osg.fillRect(0,y+=laneHeight,getWidth(),laneHeight);
osg.setColor(0x004b5cfa); //水第2
osg.fillRect(0,y+=laneHeight,getWidth(),laneHeight);
osg.setColor(0x00293df9); //水第3
osg.fillRect(0,y+=laneHeight,getWidth(),laneHeight);
osg.setColor(0x00263afb); //水第4
osg.fillRect(0,y+=laneHeight,getWidth(),laneHeight);
osg.setColor(0x001228fb); //水第5
osg.fillRect(0,y+=laneHeight,getWidth(),laneHeight);
osg.setColor(0x000016e9); //水第6
osg.fillRect(0,y+=laneHeight,getWidth(),getHeight());
// osg.setStrokeStyle(Graphics.DOTTED);
// osg.setColor(0x00464714);
// y+=laneHeight; osg.drawLine(0,y,getWidth(),y);
osg.setColor(0xffffffff);
osg.setFont(Font.getFont(Font.FACE_SYSTEM,Font.STYLE_PLAIN,Font.SIZE_MEDIUM));//设置字体大细
osg.drawString("score:"+score,0,0,Graphics.LEFT|Graphics.TOP);//得分
for(int i=0;i<actorList.size();i++)
{
Actor a=(Actor)actorList.elementAt(i);
a.render(osg);
}
osg.drawLine(getWidth()/2,40,linex2,liney2);//*****line2***
osg.drawLine(getWidth()/2+2,40,linex2,liney2);
osg.drawImage(leftboat,getWidth()/2-35,5,Graphics.LEFT|Graphics.TOP);
osg.drawImage(rightboat,getWidth()/2,5,Graphics.LEFT|Graphics.TOP);
osg.drawImage(hook1,linex1-5,liney1,Graphics.LEFT|Graphics.TOP);
osg.drawImage(hook2,linex2-5,liney2,Graphics.LEFT|Graphics.TOP);
}
public int getLaneHeight()
{
return laneHeight; //屏幕高度-10 除以9,得出街道宽度
}
//***********************************付予角色坐标***************************************//
class moveTask extends TimerTask //Timer有用嘅一个类,作用于Gold,Shit,Diamond
{
public void run()
{
GoldPosition();
}
}
protected void GoldPosition() //随机附Gold,shit,diamond坐标
{
Tools xy=new Tools();
changetime+=1;
if(changetime%100==0) //设置Gold,Shit,Diamond 3个角色的变化时间(%后(*10)为秒数)
{
for(int i=0;i<5;i++)
{
gold[i].setX(xy.getRand(0,getWidth()));
gold[i].setY(xy.getRand(70,soilHeight));
}
for(int i=0;i<6;i++)
{
shit[i].setX(xy.getRand(0,getWidth()));
shit[i].setY(xy.getRand(70,soilHeight));
}
for(int i=0;i<3;i++)
{
diamond[i].setX(xy.getRand(0,getWidth()));
diamond[i].setY(xy.getRand(70,soilHeight));
}
}
if(zfY<=65) //设祝福坐标
{
zf.setX(-20);
}
else
{
zf.setX(zfX-=2);
zf.setY(zfY);
}
if(changetime%200==0)
{
zfX=getWidth()+30;
zfY=(40+soilHeight)/2;
}
if(changetime%8==0)
{
soil.setY(soilHeight -=1); //控制Soil运动
if(soilHeight<=65)
{
try
{
soilpic=Image.createImage("/gameover.png"); //&&&&&&&&&&&&&&Game Over&&&&&&&&&&&&
}
catch(IOException e)
{}
running=false;
if(changetime%40==0)
{
gameOver();
}
}
}
if(linex1==getWidth()/2-30 || linex1==getWidth()/2) //控制直线Line1运动
{
linex1change=linex1change*(-1); //改变方向
liney1change*=(-1);
}
if(line1Press==false)
{
if(liney1<40) //限定line1唔会出现係土地上,同line2范围内
{
liney1=40;
linex1=getWidth()/2-30;
}
if(linex1>getWidth()/2)
{
linex1=getWidth()/2;
liney1=70;
}
line1.setX(linex1+=linex1change);
line1.setY(liney1+=liney1change);
}
if(line1Press==true)
{
try
{
leftboat=Image.createImage("/leftboat2.png");
}
catch(IOException e)
{}
if(line1state==1) //根据Line1碰撞条件改入面嘅内容(E+1定要用 and(&&),因为linex1<=90同下面缩短->
{ //<-嘅条件造成死循环,之后可以将linex1<=90改成碰撞条件) && linex1<=90
line1.setX(linex1-=(getWidth()/2-linex1P)*2/3); //line1 X 伸长速度,随X坐标增大而减少(由中心X坐标-当时坐标得出)
line1.setY(liney1+=(liney1P-40)*2/3); //line1 Y 伸长速度,随Y坐标增大而增大 *0.4
if(linex1<=0) //line1唔准超出屏幕左边
{
linex1=0;
}
for(int i=0;i<5;i++) //检测有无碰撞
{
if(gold[i].isIntersectingRect(linex1+5,liney1+5)==true)
{
line1state=0;
try
{
hook1=Image.createImage("/fish1.png");
}
catch(IOException e)
{}
gold[i].setX(-50); //将被拿到嘅角色坐标移出Graphics
g1=20;
break;
}
}
for(int i=0;i<6;i++) //检测有无碰撞
{
if(shit[i].isIntersectingRect(linex1,liney1)==true)
{
line1state=0;
try
{
hook1=Image.createImage("/shit.png");
}
catch(IOException e)
{}
shit[i].setX(-50); //将被拿到嘅角色坐标移出Graphics
s1=-15;
break;
}
}
for(int i=0;i<3;i++) //检测有无碰撞
{
if(diamond[i].isIntersectingRect(linex1,liney1)==true)
{
line1state=0;
try
{
hook1=Image.createImage("/fish2.png");
}
catch(IOException e)
{}
diamond[i].setX(-50); //将被拿到嘅角色坐标移出Graphics
d1=30;
break;
}
}
if(zf.isIntersectingRect(linex1,liney1)==true)
{
line1state=0;
try
{
hook1=Image.createImage("/zhufu.png");
}
catch(IOException e)
{}
zfX=-50; //将被拿到嘅角色坐标移出Graphics
soilHeight+=20;
}
}
if(line1state==0 || linex1<=0 || liney1>=soilHeight||liney1>=getHeight()-3) //liney1>=soilHeight &&
{
line1state=0;
line1.setX(linex1+=(getWidth()/2-linex1P)*2/3);//缩 ((90-linex1P)-g-d-s)
line1.setY(liney1-=(liney1P-40)*2/3);//(liney1P-40)+g+s+d)
}
if(liney1<=liney1P) // || liney1<=liney1P
{
line1state=3; //将line1的状态设为3,令佢变为移动中
line1.setX(linex1=linex1P);
line1.setY(liney1=liney1P);
line1Press=false;
try
{
hook1=Image.createImage("/hook.png");
leftboat=Image.createImage("/leftboat1.png");
}
catch(IOException e)
{}
score+=g1+d1+s1;
g1=0;d1=0;s1=0;
}
}
//******************************line2 start***************************
if(linex2==getWidth()/2+30 || linex2==getWidth()/2) //控制直线Line2运动
{
linex2change=linex2change*(-1);
liney2change*=(-1);
}
if(line2Press==false)
{
if(liney2<40) //限定line1唔会出现係土地上,同line2范围内
{
liney2=40;
linex2=getWidth()/2+30;
}
if(linex2<=getWidth()/2)
{
linex2=getWidth()/2;
liney2=70;
}
linex2+=linex2change;
liney2+=liney2change;
}
if(line2Press==true)
{
try
{
rightboat=Image.createImage("/rightboat2.png");
}
catch(IOException e)
{}
if(line2state==1)
{
linex2+=(linex2P-getWidth()/2)*2/3; //伸
liney2+=(liney2P-40)*2/3;
for(int i=0;i<5;i++) //检测有无碰撞
{
if(gold[i].isIntersectingRect(linex2+5,liney2+5)==true)
{
line2state=0;
try
{
hook2=Image.createImage("/fish1.png");
}
catch(IOException e)
{}
gold[i].setX(-50); //将被拿到嘅角色坐标移出Graphics
g2=20;
break;
}
}
for(int i=0;i<6;i++) //检测有无碰撞
{
if(shit[i].isIntersectingRect(linex2,liney2)==true)
{
line2state=0;
try
{
hook2=Image.createImage("/shit.png");
}
catch(IOException e)
{}
shit[i].setX(-50); //将被拿到嘅角色坐标移出Graphics
s2=-15;
break;
}
}
for(int i=0;i<3;i++) //检测有无碰撞
{
if(diamond[i].isIntersectingRect(linex2,liney2)==true)
{
line2state=0;
try
{
hook2=Image.createImage("/fish2.png");
}
catch(IOException e)
{}
diamond[i].setX(-50); //将被拿到嘅角色坐标移出Graphics
d2=30;
break;
}
}
if(zf.isIntersectingRect(linex2,liney2)==true)
{
line2state=0;
try
{
hook2=Image.createImage("/zhufu.png");
}
catch(IOException e)
{}
zfX=-50; //将被拿到嘅角色坐标移出Graphics
soilHeight+=20;
}
}
if(line2state==0 || linex2>=getWidth()-5 || liney2>=soilHeight ||liney2>=getHeight()-3) //liney1>=soilHeight &&
{
line2state=0;
linex2-=(linex2P-getWidth()/2)*2/3; //缩
liney2-=(liney2P-40)*2/3;
}
if(linex2<=linex2P) // || liney1<=liney1P
{
line2state=3; //将line2的状态设为3,令佢变为移动中
linex2=linex2P;
liney2=liney2P;
line2Press=false;
try
{
hook2=Image.createImage("/hook.png");
rightboat=Image.createImage("/rightboat1.png");
}
catch(IOException e)
{}
score+=g2+d2+s2;
g2=0;d2=0;s2=0;
}
}
//********************************line2 end*******************************
}
protected void keyPressed(int keyCode) //按键时
{
switch (getGameAction(keyCode))
{
case LEFT:
if(line1state==3 && liney1>40 && linex1<getWidth()/2)
{
line1Press=true;
line1state=1;
linex1P=linex1;
liney1P=liney1;
}
break;
case RIGHT:
if(line2state==3 && liney2>40 && linex2>getWidth()/2)
{
line2Press=true;
line2state=1;
linex2P=linex2;
liney2P=liney2;
}
break;
case KEY_NUM4:
if(line1state==3 && liney1>40 && linex1<getWidth()/2)
{
line1Press=true;
line1state=1;
linex1P=linex1;
liney1P=liney1;
}
break;
case KEY_NUM6:
if(line2state==3 && liney2>40 && linex2>getWidth()/2)
{
line2Press=true;
line2state=1;
linex2P=linex2;
liney2P=liney2;
}
break;
}
}
public void run() { //run
while(running)
{
repaint();
}
theMidlet.gameOver();
}
}
public final class Tools //产生随机数
{
private Random randomizer =new Random();
public int getRand(int min,int max)
{
int r=Math.abs(randomizer.nextInt());
return (r%((max-min+1)))+min;
}
}
//***************************角色部份*************************************//
abstract public class Actor //类Actor
{
protected GameScreen gameScreen;
private int x,y;
public Actor(GameScreen gsArg,int xArg,int yArg)
{
gameScreen=gsArg;
x=xArg;
y=yArg;
}
public void cycle(long deltaMS){}
public void render(Graphics g) {}
public int getActorWidth() //Actor宽度==高度
{
return getActorWidth();
}
public int getActorHeight(){ return getActorHeight();}
public int getX()
{return x;}
public void setX(int newX)
{
x=newX;
if(x<0)
x=-30;//gameScreen.getWidth();
if(x>gameScreen.getWidth())
x=-50;
}
public int getY()
{return y;}
public void setY(int newY)
{
y=newY;
}
public boolean isIntersectingRect(int lx,int ly)//碰撞
{
if(lx<getX()-2 || lx>getX()+getActorWidth()+3||ly<getY()||ly>getY()+getActorHeight())
return false;
return true;
}
}
public class GoldActor extends Actor //定义类Gold
{
public GoldActor(GameScreen gsArg,int xArg, int yArg)
{
super(gsArg,xArg,yArg);
}
public void render(Graphics graphics)
{
graphics.drawImage(goldpic,getX(),getY(),Graphics.LEFT|Graphics.TOP);
}
public int getActorWidth() //Actor宽度,高度
{
return 16;
}
public int getActorHeight()
{ return 16;}
}
public class ShitActor extends Actor //定义类Shit
{
public ShitActor(GameScreen gsArg,int xArg, int yArg)
{
super(gsArg,xArg,yArg);
}
public void render(Graphics graphics)
{
graphics.drawImage(shitpic,getX(),getY(),Graphics.LEFT|Graphics.TOP);
}
public int getActorWidth() //Actor宽度,高度
{
return 18;
}
public int getActorHeight()
{ return 18;}
}
public class DiamondActor extends Actor //定义类Diamond
{
public DiamondActor(GameScreen gsArg,int xArg, int yArg)
{
super(gsArg,xArg,yArg);
}
public void render(Graphics graphics)
{
graphics.drawImage(diamondpic,getX(),getY(),Graphics.LEFT|Graphics.TOP);
}
public int getActorWidth() //Actor宽度,高度
{
return 18;
}
public int getActorHeight()
{ return 16;}
}
public class SoilActor extends Actor //定义类Soil
{
public SoilActor(GameScreen gsArg,int xArg, int yArg)
{
super(gsArg,xArg,yArg);
}
public void render(Graphics graphics)
{
graphics.drawImage(soilpic,getX(),getY(),Graphics.HCENTER|Graphics.TOP);
}
}
public class Line1Actor extends Actor //定义类Line1
{
int xx;
public Line1Actor(GameScreen gsArg,int xArg, int yArg,int x)
{
super(gsArg,xArg,yArg);
this.xx=x;
}
public void render(Graphics graphics)
{
graphics.drawLine(xx/2-2,40,getX(),getY());
graphics.drawLine(xx/2,40,getX(),getY());
}
}
public class ZhufuActor extends Actor //定义类Zhufu
{
public ZhufuActor(GameScreen gsArg,int xArg, int yArg)
{
super(gsArg,xArg,yArg);
}
public void render(Graphics graphics)
{
graphics.drawImage(zhufu,getX(),getY(),Graphics.LEFT|Graphics.TOP);
}
public int getActorWidth() //Actor宽度,高度
{
return 12;
}
public int getActorHeight()
{ return 12;}
}
protected void pauseApp() {
}
protected void destroyApp(boolean arg0) throws MIDletStateChangeException {
}
}