老文章档案 · 2003 年

贪吃蛇的算法分析(5)

破解教程 · 算法分析 · 2003-09-19 · 作者:James 人气: · 出处:赢政天下整理收藏)

WormMain类

最主要的类,继承自MIDlet父类并实现了CommandListener接口。

l protected void startApp()

实现MIDlet父类的方法,当开始程序时首先执行这个函数

// 显示画板

Display.getDisplay(this).setCurrent(theGame);

try {

// 开始游戏线程

Thread myThread = new Thread(theGame);

myThread.start();

} catch (Error e) {

destroyApp(false);

notifyDestroyed(); }

l public void commandAction(Command c, Displayable d)

接受并处理用户输入事件

// 重新开始

if (c == restartCmd) {

theGame.restart();

};

// 改变难度等级

if (c == levelCmd) {

Item[] levelItem = {

new Gauge("Level", true, 9, theGame.getLevel())

};

Form f = new Form("Change Level", levelItem);

f.addCommand(OKCmd);

f.addCommand(cancelCmd);

f.setCommandListener(this);

Display.getDisplay(this).setCurrent(f);

};

// 离开游戏

if (c == exitCmd) {

destroyApp(false);

notifyDestroyed();

};

// 开始游戏

if (c == startCmd) {

theGame.removeCommand(startCmd);

theGame.addCommand(restartCmd);

theGame.restart();

};

// 确定

if (c == OKCmd) {

Form f = (Form)d;

Gauge g = (Gauge)f.get(0);

theGame.setLevel(g.getValue());

Display.getDisplay(this).setCurrent(theGame);

};

// 取消

if (c == cancelCmd) {

Display.getDisplay(this).setCurrent(theGame);

};

// 打开音效

if (c == audioOnCmd) {

/* 打开音效 */

theGame.createAudioPlayer();

theGame.removeCommand(audioOnCmd);

theGame.addCommand(audioOffCmd);

};

// 关闭音效

if (c == audioOffCmd) {

/* 关闭音效 */

theGame.destroyAudioPlayer();

theGame.removeCommand(audioOffCmd);

theGame.addCommand(audioOnCmd);

}

(出处:赢政天下整理收藏)

相关文章:

·语音界面2.0算法分析及注册机源码!

·侠客系统修改器1.21破解手记--算法分析

·中文拨号上网计时计费器 V4.12注册算法分析

·ClockWise 3.22e注册码算法分析

·CoolClock V1.02注册算法分析

·Directory Scanner v1.5 注册算法分析

·Disk Chief 1.2 简单注册算法分析

·EffeTech HTTP Sniffer 3.2注册算法分析

·eLib2.01算法分析

·EZ MP3 Recorder 1.15 注册算法分析

相关软件:

→ 特别推荐

→ 热点TOP10

我为人人《《==》》人人为我

关于我们 |

帮助(?)

| 广告服务 |

版权声明 |

商业合作 |

发展历程 |

加盟我们 |

联系我们

Copyright © 1999-2003

winzheng.com All Rights Reserved.

繁体版:由华琦数码技术提供

Powered

by:MeSky.Net

2003-2004 年,宽带刚刚普及,下载站的文章区是许多人学电脑的第一课堂。
🕰 → 🤖 从那时到现在

当年一篇教程能让一台电脑焕然一新;今天的效率工具换成了 AI。 想知道当下最可靠的 AI 模型怎么选?看 赢政指数——我们用了 28 年的选软件严谨,现在用来评测大模型。

档案性质声明:本页为赢政天下(1998-2011)老文章的历史档案复原, 内容反映当年发表时的原貌——包括当年的技术表述、软件版本与观点,部分方法在今天已不适用或不合规,仅作互联网历史记录与研究用途, 不提供任何形式的下载。原始数据经由公共网络存档(Internet Archive)复原。发现问题请联系我们
← 返回老文章档案 · 软件史档案馆 · 赢政天下站史