import javax.microedition.midlet.*;
import javax.microedition.lcdui.*;
import javax.microedition.rms.*;
import java.util.*;
import java.io.*;
public class escapeeMIDlet extends MIDlet implements Runnable
{
private static final String RS_NAME = "BESTTIME";
private MenuList menuList;
private escapeeCanvas myCanvas;
private boolean initDone = false;
private static final Random random = new Random();
private boolean hasBestTime = false;
private long bestTime;// 最好时间
public escapeeMIDlet()
{
}
public void startApp()
{
Displayable current = Display.getDisplay(this).getCurrent();
if (current == null)
{
// first time we've been called
Display.getDisplay(this).setCurrent(new SplashScreen(this));
}
else
{
if (current == myCanvas)
{
myCanvas.start(); // start its animation thread
}
Display.getDisplay(this).setCurrent(current);
}
}
public void pauseApp()
{
Displayable current = Display.getDisplay(this).getCurrent();
if (current == myCanvas)
{
myCanvas.stop(); // kill its animation thread
}
}
public void destroyApp(boolean unconditional)
{
if (myCanvas != null)
{
myCanvas.stop(); // kill its animation thread
}
}
private void quit()
{
destroyApp(false);
notifyDestroyed();
}
public void run()
{
init();
}
private synchronized void init()
{
if (!initDone)
{
readRecordStore();
SoundEffects.getInstance();
menuList = new MenuList(this);
myCanvas = new escapeeCanvas(this);
initDone = true;
}
}
void splashScreenPainted()
{
new Thread(this).start(); // start background initialization
}
void splashScreenDone()
{
init(); // if not already done
Display.getDisplay(this).setCurrent(menuList);
}
void menuListContinue()
{
Display.getDisplay(this).setCurrent(myCanvas);
myCanvas.start();
}
void menuListNewGame()
{
myCanvas.init();
Display.getDisplay(this).setCurrent(myCanvas);
myCanvas.start();
}
void menuListInstructions()
{
// create and discard a new Instructions screen each time, to
// avoid keeping heap memory for it when it's not in use
Display.getDisplay(this).setCurrent(new InstructionsScreen(this));
}
void menuListHighScore()
{
// create and discard a new High Score screen each time, to
// avoid keeping heap memory for it when it's not in use
Display.getDisplay(this).setCurrent(new HighScoreScreen(this));
}
void menuListQuit()
{
quit();
}
void GameCanvasMenu()
{
myCanvas.stop();
menuList.setGameActive(true);
Display.getDisplay(this).setCurrent(menuList);
}
void GameCanvasGameOver(long time,int BULLETS_NUM)
{
myCanvas.stop();
menuList.setGameActive(false);
Display.getDisplay(this).setCurrent(new GameOverScreen(this, time, BULLETS_NUM));
}
void gameOverDone()
{
Display.getDisplay(this).setCurrent(menuList);
}
void instructionsBack()
{
Display.getDisplay(this).setCurrent(menuList);
}
void highScoreBack()
{
Display.getDisplay(this).setCurrent(menuList);
}
// method needed by lots of classes, shared by putting it here
static Image createImage(String filename)
{
Image image = null;
try
{
image = Image.createImage(filename);
}
catch (java.io.IOException ex)
{
// just let return value be null
}
return image;
}
// only the MIDlet has access to the display, so put this method here
void flashBacklight(int millis)
{
Display.getDisplay(this).flashBacklight(millis);
}
// only the MIDlet has access to the display, so put this method here
void vibrate(int millis)
{
Display.getDisplay(this).vibrate(millis);
}
long getBestTime()
{
return hasBestTime ? bestTime : -1;
}
//****************************************
boolean checkBestTime(long time)
{
if (!hasBestTime || (time > bestTime))
{
hasBestTime = true;
bestTime = time;
writeRecordStore();
return true;
}
else
{
return false;
}
}
private void readRecordStore()
{
hasBestTime = false;
RecordStore rs = null;
ByteArrayInputStream bais = null;
DataInputStream dis = null;
try
{
rs = RecordStore.openRecordStore(RS_NAME, false);
byte[] data = rs.getRecord(1);
bais = new ByteArrayInputStream(data);
dis = new DataInputStream(bais);
bestTime = dis.readLong();
hasBestTime = true;
}
catch (IOException ex)
{
// hasBestTime will still be false
}
catch (RecordStoreException ex)
{
// hasBestTime will still be false
}
finally
{
if (dis != null)
{
try
{
dis.close();
}
catch (IOException ex)
{
// no error handling necessary here
}
}
if (bais != null)
{
try
{
bais.close();
}
catch (IOException ex)
{
// no error handling necessary here
}
}
if (rs != null)
{
try
{
rs.closeRecordStore();
}
catch (RecordStoreException ex)
{
// no error handling necessary here
}
}
}
}
// this will only be called when we have a best time
private void writeRecordStore()
{
RecordStore rs = null;
ByteArrayOutputStream baos = null;
DataOutputStream dos = null;
try
{
rs = RecordStore.openRecordStore(RS_NAME, true);
baos = new ByteArrayOutputStream();
dos = new DataOutputStream(baos);
dos.writeLong(bestTime);
byte[] data = baos.toByteArray();
if (rs.getNumRecords() == 0)
{
// new record store
rs.addRecord(data, 0, data.length);
}
else
{
// existing record store: will have one record, id 1
rs.setRecord(1, data, 0, data.length);
}
}
catch (IOException ex)
{
// just leave the best time unrecorded
}
catch (RecordStoreException ex)
{
// just leave the best time unrecorded
}
finally
{
if (dos != null)
{
try
{
dos.close();
}
catch (IOException ex)
{
// no error handling necessary here
}
}
if (baos != null)
{
try
{
baos.close();
}
catch (IOException ex)
{
// no error handling necessary here
}
}
if (rs != null)
没有合适的资源?快使用搜索试试~ 我知道了~
资源推荐
资源详情
资源评论
收起资源包目录
escapee.rar (95个子文件)
escapee
classes
HighScoreScreen.class 2KB
GameOverScreen.class 3KB
SoundEffects.class 2KB
SplashScreen.class 3KB
MenuList.class 2KB
fly
Font.class 2KB
escapeeCanvas.class 5KB
escapeeMIDlet.class 8KB
Escapee.class 2KB
InstructionsScreen.class 2KB
Bullets.class 3KB
GameOverScreen.jad 3KB
verified
classes
HighScoreScreen.class 2KB
GameOverScreen.class 3KB
SoundEffects.class 2KB
MANIFEST.MF 178B
Blast.wav 10KB
back_water.png 557B
SplashScreen.class 3KB
MenuList.class 2KB
escapeeCanvas.class 5KB
gameover.mid 103B
Escapee.png 504B
highscore.mid 115B
escapeeMIDlet.class 8KB
logo.png 474B
Escapee.class 2KB
gameover.png 447B
bullet.png 230B
splash.png 6KB
InstructionsScreen.class 2KB
Bullets.class 4KB
explosion.png 1KB
Thumbs.db 15KB
libs
res
Blast.wav 10KB
back_water.png 557B
gameover.mid 103B
Escapee.png 504B
highscore.mid 115B
logo.png 474B
gameover.png 447B
bullet.png 230B
splash.png 6KB
explosion.png 1KB
Thumbs.db 15KB
src
escapeeMIDlet.java 8KB
SoundEffects.java 2KB
SplashScreen.java 3KB
Escapee.java 2KB
escapeeCanvas.java 7KB
GameOverScreen.java 4KB
Bullets.java 4KB
HighScoreScreen.java 884B
MenuList.java 2KB
InstructionsScreen.java 974B
bin
HighScoreScreen.class 2KB
GameOverScreen.class 3KB
SoundEffects.class 2KB
MANIFEST.MF 178B
Blast.wav 10KB
back_water.png 557B
SplashScreen.class 3KB
MenuList.class 2KB
escapeeCanvas.class 5KB
gameover.mid 103B
Escapee.png 504B
highscore.mid 115B
escapeeMIDlet.class 6KB
logo.png 474B
Escapee.class 2KB
gameover.png 447B
bullet.png 230B
splash.png 6KB
InstructionsScreen.class 2KB
Bullets.class 3KB
escapee.jad 227B
explosion.png 1KB
Thumbs.db 15KB
.classpath 242B
project.properties 119B
.settings
org.eclipse.jdt.core.prefs 208B
.eclipseme 242B
tmpclasses
HighScoreScreen.class 2KB
GameOverScreen.class 3KB
SoundEffects.class 2KB
SplashScreen.class 3KB
MenuList.class 2KB
fly
Font.class 2KB
escapeeCanvas.class 5KB
escapeeMIDlet.class 6KB
Escapee.class 2KB
InstructionsScreen.class 2KB
Bullets.class 3KB
.project 539B
lib
escapee.jad 193B
tmplib
共 95 条
- 1
资源评论
- 流氓萝莉光环2012-12-20不是很会用
- czm15167064532013-05-02不是我想要的。没有太多的参考价值。
chen_pfizer
- 粉丝: 0
- 资源: 1
上传资源 快速赚钱
- 我的内容管理 展开
- 我的资源 快来上传第一个资源
- 我的收益 登录查看自己的收益
- 我的积分 登录查看自己的积分
- 我的C币 登录后查看C币余额
- 我的收藏
- 我的下载
- 下载帮助
最新资源
- mongodb数据库基本操作.pdf
- C#,布尔可满足性问题(Boolean Satisfiability Problem)算法与源代码
- C#,回文分割问题(Palindrome Partitioning Problem)算法与源代码
- C#,煎饼排序问题(Pancake Sorting Problem)算法与源代码
- C#,排列组合的堆生成法(Heap’s Algorithm for generating permutations)算法与源代码
- C#,老鼠迷宫问题的回溯法求解(Rat in a Maze)算法与源代码
- 6693eeb8d683458a07938615fba9e68f.apk
- C#,数值计算,解微分方程的龙格-库塔二阶方法与源代码
- C#,数值计算,用割线法(Secant Method)求方程根的算法与源代码
- C#,子集和问题(Subset Sum Problem)的算法与源代码
资源上传下载、课程学习等过程中有任何疑问或建议,欢迎提出宝贵意见哦~我们会及时处理!
点击此处反馈
安全验证
文档复制为VIP权益,开通VIP直接复制
信息提交成功