【Java开源代码栏目提醒】:网学会员,鉴于大家对Java开源代码十分关注,论文会员在此为大家搜集整理了“MarioBrick.java”一文,供大家参考学习!
/**
* <p>Title: Mario</p>
* <p>Description:
* You cannot remove this copyright and notice.
* You cannot use this file any part without the express per
mission of the author.
* All Rights Reserved</p>
* <p>Copyright: lizhenpeng (c) 2004</p>
* <p>Company: LP&P</p>
* @author lizhenpeng
* @version 1.0.0
*/
package mario;
import lipeng.LPSprite;
import javax.microedition.lcdui.Graphics;
import lipeng.LPImageManage;
import lipeng.LPRect;
import java.io.DataInputStream;
import java.io.DataOutputStream;
import java.io.IOException;
public class MarioBrick extends LPSprite
{
public MarioBrick(int x,int y)
{
this.x = x;
this.y = y;
}
public void createGem(MarioGameManage gm)
{
}
}
class MarioBrickHidden extends MarioBrick
{
public MarioBrickHidden(int x,int y)
{
super(x,y);
isHidden = true;
}
public void reInit(int x,int y)
{
this.x = x;
this.y = y;
isHidden = true;
}
public void createGem(MarioGameManage gm)
{
if(isHidden)
{
isHidden=false;
gm.createGold(x,y);
if(++gm.goldNum==100)
{
gm.goldNum = 0;
}
if(gm.menu.isVolOn)
{
gm.beatPlayer.replay();
}
frameCnt=0;
}
}
}
class MarioGemHidden extends MarioBrick
{
public MarioGemHidden(int x,int y)
{
super(x,y);
isHidden =true;
}
public void reInit(int x,int y)
{
this.x=x;
this.y=y;
isHidden =true;
}
public void createGem(MarioGameManage gm)
{
if(isHidden)
{
isHidden=false;
gm.createGem(x,y);
frameCnt=0;
}
}
}
class MarioBrickGemHidden extends MarioBrick
{
private boolean hasUsed = false;
public MarioBrickGemHidden(int x,int y)
{
super(x,y);
isHidden = true;
}
public void reInit(int x,int y)
{
this.x = x;
this.y = y;
isHidden = true;
}
public void createGem(MarioGameManage gm)
{
if(isHidden)
{
if(!hasUsed)
{
isHidden=false;
gm.createGemPeople(x,y);
hasUsed = true;
frameCnt=0;
}
}
}
}
class MarioBrickGemQuestion extends MarioBrick
{
public MarioBrickGemQuestion(int x,int y)
{
super(x,y);
this.frameCnt = 3;
}
public void action()
{
if (frameCnt != 0)
{
if (++timeCnt % 3 == 0)
{
frameCnt = 5 - frameCnt;
}
}
}
public void reInit(int x,int y)
{
super.reInit(x,y);
frameCnt = 3;
}
public void createGem(MarioGameManage gm)
{
if(frameCnt!=0)
{
gm.createGem(x,y);
frameCnt = 0;
}
}
}
class MarioBrickGem extends MarioBrick
{
public MarioBrickGem(int x,int y)
{
super(x,y);
this.frameCnt = 1;
}
public void reInit(int x,int y)
{
super.reInit(x,y);
frameCnt = 1;
}
public void createGem(MarioGameManage gm)
{
if(frameCnt!=0)
{
gm.createGem(x,y);
frameCnt=0;
}
}
}
class MarioBrickGold extends MarioBrick
{
protected boolean beginCount;
public MarioBrickGold(int x,int y)
{
super(x,y);
this.frameCnt = 1;
beginCount = false;
}
public void action()
{
if (frameCnt != 0)
{
if (beginCount)
{
++timeCnt;
}
}
}
public void reInit(int x,int y)
{
this.x = x;
this.y = y;
beginCount = false;
frameCnt = 1;
timeCnt = 0;
}
public void createGem(MarioGameManage gm)
{
if(frameCnt!=0)
{
beginCount = true;
gm.createGold(x,y);
if(++gm.goldNum==100)
{
gm.goldNum=0;
}
if(gm.menu.isVolOn)
{
gm.beatPlayer.replay();
}
if(timeCnt >= 60)
{
frameCnt = 0;
}
}
}
public void writeData(DataOutputStream dos) throws IOException
{
super.writeData(dos);
dos.writeBoolean(beginCount);
}
public void readData(DataInputStream dis) throws IOException
{
super.readData(dis);
beginCount = dis.readBoolean();
}
}
class MarioBrickGoldQuestion extends MarioBrick
{
public MarioBrickGoldQuestion(int x,int y)
{
super(x,y);
frameCnt = 3;
}
public void reInit(int x,int y)
{
super.reInit(x,y);
frameCnt = 3;
}
public void action()
{
if (frameCnt != 0)
{
if (++timeCnt % 3 == 0)
{
frameCnt = 5 - frameCnt;
}
}
}
public void createGem(MarioGameManage gm)
{
if(frameCnt!=0)
{
gm.createGold(x,y);
frameCnt = 0;
if(++gm.goldNum==100)
{
gm.goldNum=0;
}
if(gm.menu.isVolOn)
{
gm.beatPlayer.replay();
}
}
}
}
class Mashroom extends LPSprite
{
private int growCnt;
private MarioGameManage gm;
private int dy;
private LPRect rect1 = new LPRect();
private LPRect rect2 = new LPRect();
private int xSpeed;
public void writeData(DataOutputStream dos) throws IOException
{
super.writeData(dos);
dos.writeInt(growCnt);
dos.writeInt(dy);
dos.writeInt(xSpeed);
}
public void readData(DataInputStream dis) throws IOException
{
super.readData(dis);
growCnt = dis.readInt();
dy = dis.readInt();
xSpeed = dis.readInt();
}
public Mashroom(MarioGameManage gm)
{
isHidden = true;
frameCnt = 6;
this.gm = gm;
rect1.dx = 16;
rect1.dy = 16;
rect2.dx = 16;
rect2.dy = 16;
}
public v