谁能给我一个手机游戏的源代码?

这个地址也有,不过我直接给你,比较好。

让我先给你看看主要的类。

包游戏;

导入DreamBubbleMidlet

导入Java . io . io exception;

导入Java . util . enumeration;

导入Java . util . hashtable;

导入javax . micro edition . LC dui . graphics;

导入javax . micro edition . LC dui . image;

导入javax . micro edition . LC dui . game . game canvas;

导入javax . micro edition . lcdui . game . layer manager;

导入javax . micro edition . LC dui . game . sprite;

公共类游戏扩展GameCanvas实现Runnable {

受保护的DreamBubbleMidlet;

受保护的图形g;

受保护的图像加载图像;

受保护的图像pauseImage

受保护图像cursorImage

受保护的图像jackStateImage

受保护的图像johnStateImage

受保护的图像编号图像;

受保护的精灵光标;

受保护的精灵编号;

受保护层管理器cursorManager

受保护的层管理器编号管理器;

受保护的哈希表bombTable

受保护的地图地图;

受保护的层管理器gameLayerManager

受保护的角色扮演者;

受保护的Sprite playerGhost

受保护的int屏幕宽度;

受保护的int屏幕高度;

受保护的int延迟= 50;

受保护的int[][]born place;

protected int chooseIndex

protected int stage index = 1;

受保护的int游戏时钟;

受保护的int loadPercent

受保护的布尔值isPause

受保护的布尔isEnd

受保护的布尔值正在显示;

受保护的布尔isLoading

受保护的线程主线程;

公共游戏(DreamBubbleMidlet DreamBubbleMidlet){

超(假);

this . setfullscreenmode(true);

this . dreamBubbleMidlet = dreamBubbleMidlet;

this . screen width = this . getwidth();

this . screen height = this . get height();

尝试{

this . loading image = image . create image("/Game/loading . png ");

this . pause image = image . create image("/Game/pause . png ");

this . cursor image = image . create image("/Game/cursor . png ");

this . jackstateimage = image . create image("/State/jackstate . png ");

this . johnstate image = image . create image("/State/johnstate . png ");

this . number image = image . create image("/State/number . png ");

} catch (IOException e) {

e . printstacktrace();

}

this . g = this . get graphics();

}

公共void loadStage(中间阶段){

this.isEnd = false

this.isPause = false

this.isPlaying = false

this . gamelayermanager = new layer manager();

this . cursor manager = new layer manager();

this . number manager = new layer manager();

this . bomb table = new Hashtable();

this . cursor = new Sprite(this . cursor image,32,32);

this . number = new Sprite(this . number image,12,10);

this.loadPercent = 20

睡眠();

负载图(阶段);

this.loadPercent = 40

睡眠();

load player();

this.loadPercent = 60

睡眠();

this . gamelayermanager . append(map . get bomblayer());

this . gamelayermanager . append(map . getbuildlayer());

this . gamelayermanager . append(map . get tool layer());

this . gamelayermanager . append(map . getfloorlayer());

this . gamelayermanager . setview window(0,-5,屏幕宽度,

全球。MAP _ HEIGHT+5);

this . cursor manager . append(cursor);

this.numberManager.append(数字);

this.loadPercent = 80

睡眠();

this . load percent = 100;

睡眠();

isPlaying = true

}

公共无效运行(){

而(!isEnd) {

long begin time = system . current time millis();

this . draw screen();

long end time = system . current time millis();

if(end time-begin time & lt;this.delay) {

尝试{

thread . sleep(this . delay-(end time-begin time));

} catch (InterruptedException e) {

e . printstacktrace();

}

}

}

}

公共空装载图(中间阶段){

开关(阶段){

案例0:

this.map =新地图(全局。MAP _ BLOCK);

this.bornPlace = Global。MAP _ BLOCK _ BORNPLACE

打破;

案例1:

this.map =新地图(全局。地图_工厂);

this.bornPlace = Global。MAP _ FACTORY _ BORNPLACE

打破;

案例二:

this.map =新地图(全局。MAP _ FOREST);

this.bornPlace = Global。MAP _ FOREST _ BORNPLACE

打破;

案例三:

this.map =新地图(全局。地图_海盗);

this.bornPlace = Global。MAP _ PIRATE _ BORNPLACE

打破;

案例4:

this.map =新地图(全局。地图_郊区);

this.bornPlace = Global。MAP _ FAUBOURG _ BORNPLACE

打破;

}

}

public void loadPlayer() {

this . player = singlegamerole . createsinglegamerole(this,Global。杰克,

this.bornPlace[0][0],this . born place[0][1]);

this . gamelayermanager . append(player);

尝试{

this . player ghost = new Sprite(image . create image("/Character/jack . png "),

this.player.width,this . player . height);

this . gamelayermanager . append(player ghost);

} catch (IOException e) {

// TODO自动生成的catch块

e . printstacktrace();

}

}

public void playerUpdate() {

如果(!this.player.isAlive)

this . playerghost . set visible(false);

this . player host . set frame(this . player . get frame());

this . player . updaterole();

}

public void bombUpdate() {

enumeration enu = this . bomb table . keys();

while (enu.hasMoreElements()) {

String key =(String)enu . nextelement();

Bomb Bomb =(Bomb)(Bomb table . get(key));

if (bomb.isvisable) {

bomb . update();

}否则{

bombTable.remove(键);

炸弹=空;

}

}

}

public void mapUpdate() {

this . map . update();

}

公共void drawScreen() {

if(game clock & lt;10000)

game clock++;

其他

game clock = 0;

如果(!this.isLoading) {

如果(!isPause) {

this . operate();

this . bombupdate();

this . player update();

this . map update();

g . set color(0x 000000);

g.fillRect(0,0,getWidth(),getHeight());

this . drawstate();

gameLayerManager.paint(g,0,this.screenHeight

-全球。MAP _ HEIGHT-5);

}否则{

this . drawpauseframe();

}

}否则{

this . drawloadingframe();

}

this . flush graphics();

}

public void drawFailScreen() {

}

公共void drawState() {

if (this.player.type == Global。杰克){

g.drawImage(jackStateImage,60,5,图形。顶部|图形。左);

}

if (this.player.type == Global。约翰){

g.drawImage(johnStateImage,60,5,图形。顶部|图形。左);

}

this . number . set frame(this . player . bombnums);

this.numberManager.paint(g,101,15);

this . number . set frame(this . player . speed);

this.numberManager.paint(g,133,15);

this . number . set frame(this . player . power);

this.numberManager.paint(g,165,15);

}

受保护的void drawPauseFrame() {

g . set color(0x 000000);

g.fillRect(0,0,getWidth(),getHeight());

this . draw state();

if(游戏时钟% 5 == 0)

this . cursor . set frame((this . cursor . get frame()+1)% 4);

this.gameLayerManager.paint(g,0,this.screenHeight - Global。地图_高度

- 5);

this.cursorManager.paint(g,screen width/2-pause image . getwidth()/2

- 32,screen height/2-pause image . getheight()/2

+this . choose index * 33+24);

g.drawImage(pauseImage,screenWidth / 2,screenHeight / 2,

图形。HCENTER |图形。VCENTER);

}

受保护的void drawLoadingFrame() {

g.setColor(66,70,246);

g.fillRect(0,0,屏幕宽度,屏幕高度);

g.drawImage(loadingImage,screenWidth / 2,2 * screenHeight / 5

图形。HCENTER |图形。VCENTER);

g.setColor(0,255,0);

g.fillRect((屏幕宽度- 120) / 2,2 *屏幕高度/ 3,

(this . load percent * 120)/100,10);

g.setColor(255,0,0);

g.drawRect((屏幕宽度- 120) / 2,2 *屏幕高度/ 3,120,10);

}

public void showMe() {

新加载(this . stage index);

if (this.mainThread == null) {

mainThread =新线程(this);

main thread . start();

}

this . dreambubblemidlet . show(this);

}

公共void operate() {

int key States = getkey States();

this . player host . set position(this . player . xcoodinate,this . player . ycoodinate);

if((key States & amp;向下_按下)!= 0) {

this.player.walk(全局。南);

}否则{

if((key States & amp;UP_PRESSED)!= 0) {

this.player.walk(全局。北);

}否则{

if((key States & amp;右_按)!= 0) {

this.player.walk(全局。东);

}否则{

if((key States & amp;左_按)!= 0) {

this.player.walk(全局。西);

}

}

}

}

}

受保护的void按键(int key) {

如果(!这是在播放)

返回;

如果(!这是原因。& ampKey == -7) {//右键

this . choose index = 0;

this . pausegame();

返回;

}

If (key == 35) {// # key

this . next stage();

返回;

}

If (key == 42) {// * key

this . prestage();

返回;

}

如果(这是暂停){

开关(钥匙){

案例-1:

案例三:

if (this.chooseIndex == 0)

this . choose index = 2;

其他

this . choose index =(this . choose index-1)% 3;

打破;

案例二:

案例4:

this . choose index =(this . choose index+1)% 3;

打破;

案例5://确认键

案例6://左软键

开关(选择索引){

案例0:

this . continue game();

打破;

案例1:

this . restart();

打破;

案例二:

this . endgame();

打破;

}

打破;

默认值:

打破;

}

}否则{

开关(钥匙){

案例53:

案例5://确认键

this . player . setbomb(this . player . getrow()、this . player . getcol());

打破;

}

}

}

公共void restart() {

新加载(this . stage index);

}

公共void continueGame() {

this.isPause = false

this . player . play();

}

public void pauseGame() {

this.isPause = true

this . player . stop();

}

公共void endGame() {

this.isEnd = true

this.mainThread = null

system . GC();

尝试{

thread . sleep(500);

} catch (InterruptedException e) {

// TODO自动生成的catch块

e . printstacktrace();

}

this . dreambubblemidlet . menu . show me();

}

public void nextStage() {

if(this . stage index & lt;4) {

this . stage index++;

}

新加载(this . stage index);

}

public void preStage() {

if(this . stage index & gt;0) {

this . stage index-;

}

新加载(this . stage index);

}

类加载实现Runnable {

私有线程innerThread

private int stageIndex

公共加载(中间阶段索引){

this . stage index = stage index;

innerThread =新线程(this);

innerthread . start();

}

公共无效运行(){

isLoading = true

load percent = 0;

system . GC();

loadStage(stage index);

isLoading = false

}

}

公共无效睡眠(){

尝试{

thread . sleep(100);

} catch (InterruptedException e) {

// TODO自动生成的catch块

e . printstacktrace();

}

}

}

这是游戏科目课。

以下是游戏中的人物

包游戏;

导入javax . micro edition . LC dui . image;

导入javax . micro edition . LC dui . game . sprite;

公共抽象类角色扩展Sprite {

/**

*角色的基本属性

*/

受保护的int类型;

受保护的int xCoodinate

受保护的int yCoodinate

受保护的int行;

受保护的int col

受保护的int宽度;

受保护的int高度;

受保护的int速度;

受保护的int状态;

protected boolean iscan operate = false;

protected boolean isAlive = true

/**

*放置炸弹的人的基本属性

*/

受保护的int电源;

受保护的内部炸弹;

protected int character clock = 0;

protected int dead time = 0;

受保护的游戏游戏;

受保护的角色(图像图像,int宽度,int高度,游戏游戏){

超级(图像、宽度、高度);

this.game =游戏;

}

/**

*人物拿起道具。

* @param工具

*/

公共抽象void picku tool(int工具);

/**

*碰撞检测和坐标改变。如果对行走条件有特殊要求,可以在这里写下自己的条件。

* @参数方向

*/

公共抽象void collision check(int direction);

公共void updateRole() {

if(this . character clock & lt;10000) {

this . character clock++;

}否则{

this . character clock = 100;

}

int row = this . getrow();

int col = this . getcol();

if (this.isAlive) {

int tool = this . game . map . get tool layer()。getCell(col,row);

if(tool & gt;0) {

this.pickupTool(工具);

this.game.map.getToolLayer()。setCell(col,row,0);

}

if(this . game . map . has feature(row,col,Global。致命的){

this.isAlive = false

返回;

}

if (this.status == Global。出生的

& amp& ampthis.characterClock & gt全球。出生时间){

this.status =全局。南;

this.setFrame(全局。南* 6);

this.isCanOperate = true

}

if (this.status == Global。出生){

if (this.characterClock % 2 == 0)

this.setFrame(全局。BORN * 6+(this . get frame()-1)% 4);

返回;

}

}否则{

this.isCanOperate = false

if(this . dead time & lt;= 20) {

this . dead time++;

}否则{

this . dead time = 100;

this . set visible(false);

返回;

}

if (this.characterClock % 2 == 0) {

if(this . get frame()& lt;全球。死亡* 6) {

this.setFrame(全局。死* 6);

}否则{

if(this . get frame()& lt;29) {

this . set frame(this . get frame()+1);

}否则{

if (this.characterClock % 4 == 0) {

this . set frame(29);

this . set visible(true);

}否则{

this . set visible(false);

}

}

}

}

}

}

公共空走(内部方向){

如果(!isAlive)

返回;

如果(!isCanOperate)

返回;

if(direction==9)返回;

this.collisionCheck(方向);

if (this.characterClock % 2 == 0) {

if (this.status == direction) {

this . set frame(this . status * 6+(this . get frame()+1)% 6);

}否则{

this.status =方向;

this . set frame(this . status * 6);

}

}

this.setPosition(xCoodinate,yCoodinate);

}

公共无效站点(){

this.isCanOperate = false

}

公共void play() {

this.isCanOperate = true

}

公共抽象void setBomb(int row,int col);

public void increaseBomb() {

if(this . bombnums & lt;全球。最大炸弹数量)

this . bombnums++;

}

public int getRow() {

返回getRow(getBottomY(yCoodinate)-Global。MAP _ CELL/2);

}

public int getCol() {

返回getCol(xCoodinate + Global。MAP _ CELL/2);

}

protected int getBottomY(int y) {

返回y+this . height-1;

}

protected int getRightX(int x) {

返回x +全局。MAP _ CELL-1;

}

protected int getPreY(int y) {

返回getBottomY(y) + 1 -全局。MAP _ CELL

}

protected int getRow(int x) {

返回x /全局。MAP _ CELL

}

protected int getCol(int y) {

返回y /全局。MAP _ CELL

}

}

我的QQ是609419340。

如果你不明白,可以随时问我,也可以到时候发给你