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

谁能给我一个手机游戏的源代码啊,第1张

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

先给你看看主要的类吧

package Game;

import DreamBubbleMidlet;

import javaioIOException;

import javautilEnumeration;

import javautilHashtable;

import javaxmicroeditionlcduiGraphics;

import javaxmicroeditionlcduiImage;

import javaxmicroeditionlcduigameGameCanvas;

import javaxmicroeditionlcduigameLayerManager;

import javaxmicroeditionlcduigameSprite;

public class Game extends GameCanvas implements Runnable {

protected DreamBubbleMidlet dreamBubbleMidlet;

protected Graphics g;

protected Image loadingImage;

protected Image pauseImage;

protected Image cursorImage;

protected Image jackStateImage;

protected Image johnStateImage;

protected Image numberImage;

protected Sprite cursor;

protected Sprite number;

protected LayerManager cursorManager;

protected LayerManager numberManager;

protected Hashtable bombTable;

protected Map map;

protected LayerManager gameLayerManager;

protected Role player;

protected Sprite playerGhost;

protected int screenWidth;

protected int screenHeight;

protected int delay = 50;

protected int[][] bornPlace;

protected int chooseIndex;

protected int stageIndex = 1;

protected int gameClock;

protected int loadPercent;

protected boolean isPause;

protected boolean isEnd;

protected boolean isPlaying;

protected boolean isLoading;

protected Thread mainThread;

public Game(DreamBubbleMidlet dreamBubbleMidlet) {

super(false);

thissetFullScreenMode(true);

thisdreamBubbleMidlet = dreamBubbleMidlet;

thisscreenWidth = thisgetWidth();

thisscreenHeight = thisgetHeight();

try {

thisloadingImage = ImagecreateImage("/Game/Loadingpng");

thispauseImage = ImagecreateImage("/Game/Pausepng");

thiscursorImage = ImagecreateImage("/Game/Cursorpng");

thisjackStateImage = ImagecreateImage("/State/JackStatepng");

thisjohnStateImage = ImagecreateImage("/State/JohnStatepng");

thisnumberImage = ImagecreateImage("/State/Numberpng");

} catch (IOException e) {

eprintStackTrace();

}

thisg = thisgetGraphics();

}

public void loadStage(int stage) {

thisisEnd = false;

thisisPause = false;

thisisPlaying = false;

thisgameLayerManager = new LayerManager();

thiscursorManager = new LayerManager();

thisnumberManager = new LayerManager();

thisbombTable = new Hashtable();

thiscursor = new Sprite(thiscursorImage, 32, 32);

thisnumber = new Sprite(thisnumberImage, 12, 10);

thisloadPercent = 20;

sleep();

loadMap(stage);

thisloadPercent = 40;

sleep();

loadPlayer();

thisloadPercent = 60;

sleep();

thisgameLayerManagerappend(mapgetBombLayer());

thisgameLayerManagerappend(mapgetBuildLayer());

thisgameLayerManagerappend(mapgetToolLayer());

thisgameLayerManagerappend(mapgetFloorLayer());

thisgameLayerManagersetViewWindow(0, -5, screenWidth,

GlobalMAP_HEIGHT + 5);

thiscursorManagerappend(cursor);

thisnumberManagerappend(number);

thisloadPercent = 80;

sleep();

thisloadPercent = 100;

sleep();

isPlaying = true;

}

public void run() {

while (!isEnd) {

long beginTime = SystemcurrentTimeMillis();

thisdrawScreen();

long endTime = SystemcurrentTimeMillis();

if (endTime - beginTime < thisdelay) {

try {

Threadsleep(thisdelay - (endTime - beginTime));

} catch (InterruptedException e) {

eprintStackTrace();

}

}

}

}

public void loadMap(int stage) {

switch (stage) {

case 0:

thismap = new Map(GlobalMAP_BLOCK);

thisbornPlace = GlobalMAP_BLOCK_BORNPLACE;

break;

case 1:

thismap = new Map(GlobalMAP_FACTORY);

thisbornPlace = GlobalMAP_FACTORY_BORNPLACE;

break;

case 2:

thismap = new Map(GlobalMAP_FOREST);

thisbornPlace = GlobalMAP_FOREST_BORNPLACE;

break;

case 3:

thismap = new Map(GlobalMAP_PIRATE);

thisbornPlace = GlobalMAP_PIRATE_BORNPLACE;

break;

case 4:

thismap = new Map(GlobalMAP_FAUBOURG);

thisbornPlace = GlobalMAP_FAUBOURG_BORNPLACE;

break;

}

}

public void loadPlayer() {

thisplayer = SingleGameRolecreateSingleGameRole(this, GlobalJACK,

thisbornPlace[0][0], thisbornPlace[0][1]);

thisgameLayerManagerappend(player);

try {

thisplayerGhost = new Sprite(ImagecreateImage("/Character/Jackpng"),

thisplayerwidth, thisplayerheight);

thisgameLayerManagerappend(playerGhost);

} catch (IOException e) {

// TODO Auto-generated catch block

eprintStackTrace();

}

}

public void playerUpdate() {

if(!thisplayerisAlive)

thisplayerGhostsetVisible(false);

thisplayerGhostsetFrame(thisplayergetFrame());

thisplayerupdateRole();

}

public void bombUpdate() {

Enumeration enu = thisbombTablekeys();

while (enuhasMoreElements()) {

String key = (String) enunextElement();

Bomb bomb = (Bomb) (bombTableget(key));

if (bombisvisable) {

bombupdate();

} else {

bombTableremove(key);

bomb = null;

}

}

}

public void mapUpdate() {

thismapupdate();

}

public void drawScreen() {

if (gameClock < 10000)

gameClock++;

else

gameClock = 0;

if (!thisisLoading) {

if (!isPause) {

thisoperate();

thisbombUpdate();

thisplayerUpdate();

thismapUpdate();

gsetColor(0x000000);

gfillRect(0, 0, getWidth(), getHeight());

thisdrawState();

gameLayerManagerpaint(g, 0, thisscreenHeight

- GlobalMAP_HEIGHT - 5);

} else {

thisdrawPauseFrame();

}

} else {

thisdrawLoadingFrame();

}

thisflushGraphics();

}

public void drawFailScreen() {

}

public void drawState() {

if (thisplayertype == GlobalJACK) {

gdrawImage(jackStateImage, 60, 5, GraphicsTOP | GraphicsLEFT);

}

if (thisplayertype == GlobalJOHN) {

gdrawImage(johnStateImage, 60, 5, GraphicsTOP | GraphicsLEFT);

}

thisnumbersetFrame(thisplayerbombNums);

thisnumberManagerpaint(g, 101, 15);

thisnumbersetFrame(thisplayerspeed);

thisnumberManagerpaint(g, 133, 15);

thisnumbersetFrame(thisplayerpower);

thisnumberManagerpaint(g, 165, 15);

}

protected void drawPauseFrame() {

gsetColor(0x000000);

gfillRect(0, 0, getWidth(), getHeight());

thisdrawState();

if (gameClock % 5 == 0)

thiscursorsetFrame((thiscursorgetFrame() + 1) % 4);

thisgameLayerManagerpaint(g, 0, thisscreenHeight - GlobalMAP_HEIGHT

- 5);

thiscursorManagerpaint(g, screenWidth / 2 - pauseImagegetWidth() / 2

- 32, screenHeight / 2 - pauseImagegetHeight() / 2

+ thischooseIndex 33 + 24);

gdrawImage(pauseImage, screenWidth / 2, screenHeight / 2,

GraphicsHCENTER | GraphicsVCENTER);

}

protected void drawLoadingFrame() {

gsetColor(66, 70, 246);

gfillRect(0, 0, screenWidth, screenHeight);

gdrawImage(loadingImage, screenWidth / 2, 2 screenHeight / 5,

GraphicsHCENTER | GraphicsVCENTER);

gsetColor(0, 255, 0);

gfillRect((screenWidth - 120) / 2, 2 screenHeight / 3,

(thisloadPercent 120) / 100, 10);

gsetColor(255, 0, 0);

gdrawRect((screenWidth - 120) / 2, 2 screenHeight / 3, 120, 10);

}

public void showMe() {

new Loading(thisstageIndex);

if (thismainThread == null) {

mainThread = new Thread(this);

mainThreadstart();

}

thisdreamBubbleMidletshow(this);

}

public void operate() {

int keyStates = getKeyStates();

thisplayerGhostsetPosition(thisplayerxCoodinate, thisplayeryCoodinate);

if ((keyStates & DOWN_PRESSED) != 0) {

thisplayerwalk(GlobalSOUTH);

} else {

if ((keyStates & UP_PRESSED) != 0) {

thisplayerwalk(GlobalNORTH);

} else {

if ((keyStates & RIGHT_PRESSED) != 0) {

thisplayerwalk(GlobalEAST);

} else {

if ((keyStates & LEFT_PRESSED) != 0) {

thisplayerwalk(GlobalWEST);

}

}

}

}

}

protected void keyPressed(int key) {

if (!thisisPlaying)

return;

if (!thisisPause && key == -7) {// 右键

thischooseIndex = 0;

thispauseGame();

return;

}

if (key == 35) {// #键

thisnextStage();

return;

}

if (key == 42) {// 键

thispreStage();

return;

}

if (thisisPause) {

switch (key) {

case -1:

case -3:

if (thischooseIndex == 0)

thischooseIndex = 2;

else

thischooseIndex = (thischooseIndex - 1) % 3;

break;

case -2:

case -4:

thischooseIndex = (thischooseIndex + 1) % 3;

break;

case -5:// 确认键

case -6:// 左软键

switch (chooseIndex) {

case 0:

thiscontinueGame();

break;

case 1:

thisrestart();

break;

case 2:

thisendGame();

break;

}

break;

default:

break;

}

} else {

switch (key) {

case 53:

case -5:// 确认键

thisplayersetBomb(thisplayergetRow(), thisplayergetCol());

break;

}

}

}

public void restart() {

new Loading(thisstageIndex);

}

public void continueGame() {

thisisPause = false;

thisplayerplay();

}

public void pauseGame() {

thisisPause = true;

thisplayerstop();

}

public void endGame() {

thisisEnd = true;

thismainThread = null;

Systemgc();

try {

Threadsleep(500);

} catch (InterruptedException e) {

// TODO Auto-generated catch block

eprintStackTrace();

}

thisdreamBubbleMidletmenushowMe();

}

public void nextStage() {

if (thisstageIndex < 4) {

thisstageIndex++;

}

new Loading(thisstageIndex);

}

public void preStage() {

if (thisstageIndex > 0) {

thisstageIndex--;

}

new Loading(thisstageIndex);

}

class Loading implements Runnable {

private Thread innerThread;

private int stageIndex;

public Loading(int stageIndex) {

thisstageIndex = stageIndex;

innerThread = new Thread(this);

innerThreadstart();

}

public void run() {

isLoading = true;

loadPercent = 0;

Systemgc();

loadStage(stageIndex);

isLoading = false;

}

}

public void sleep() {

try {

Threadsleep(100);

} catch (InterruptedException e) {

// TODO Auto-generated catch block

eprintStackTrace();

}

}

}

这个是游戏主体类

下面是游戏的人物类

package Game;

import javaxmicroeditionlcduiImage;

import javaxmicroeditionlcduigameSprite;

public abstract class Role extends Sprite {

/

人物的基本属性

/

protected int type;

protected int xCoodinate;

protected int yCoodinate;

protected int row;

protected int col;

protected int width;

protected int height;

protected int speed;

protected int status;

protected boolean isCanOperate = false;

protected boolean isAlive = true;

/

人物放置炸d的基本属性

/

protected int power;

protected int bombNums;

protected int characterClock = 0;

protected int deadTime = 0;

protected Game game;

protected Role(Image image, int width, int Height, Game game) {

super(image, width, Height);

thisgame = game;

}

/

人物拾起道具

@param tool

/

public abstract void pickupTool(int tool);

/

碰撞检测以及坐标的改变,如果对行走条件有特殊需求,既可以在这里写自己的条件

@param direction

/

public abstract void collisionCheck(int direction);

public void updateRole() {

if (thischaracterClock < 10000) {

thischaracterClock++;

} else {

thischaracterClock = 100;

}

int row = thisgetRow();

int col = thisgetCol();

if (thisisAlive) {

int tool = thisgamemapgetToolLayer()getCell(col, row);

if (tool > 0) {

thispickupTool(tool);

thisgamemapgetToolLayer()setCell(col, row, 0);

}

if (thisgamemaphasFeature(row, col, GlobalDEADLY)) {

thisisAlive = false;

return;

}

if (thisstatus == GlobalBORN

&& thischaracterClock > GlobalBORN_TIME) {

thisstatus = GlobalSOUTH;

thissetFrame(GlobalSOUTH 6);

thisisCanOperate = true;

}

if (thisstatus == GlobalBORN) {

if (thischaracterClock % 2 == 0)

thissetFrame(GlobalBORN 6 + (thisgetFrame() - 1) % 4);

return;

}

} else {

thisisCanOperate = false;

if (thisdeadTime <= 20) {

thisdeadTime++;

} else {

thisdeadTime = 100;

thissetVisible(false);

return;

}

if (thischaracterClock % 2 == 0) {

if (thisgetFrame() < GlobalDEAD 6) {

thissetFrame(GlobalDEAD 6);

} else {

if (thisgetFrame() < 29) {

thissetFrame(thisgetFrame() + 1);

} else {

if (thischaracterClock % 4 == 0) {

thissetFrame(29);

thissetVisible(true);

} else {

thissetVisible(false);

}

}

}

}

}

}

public void walk(int direction) {

if (!isAlive)

return;

if (!isCanOperate)

return;

if(direction==9) return;

thiscollisionCheck(direction);

if (thischaracterClock % 2 == 0) {

if (thisstatus == direction) {

thissetFrame(thisstatus 6 + (thisgetFrame() + 1) % 6);

} else {

thisstatus = direction;

thissetFrame(thisstatus 6);

}

}

thissetPosition(xCoodinate, yCoodinate);

}

public void stop() {

thisisCanOperate = false;

}

public void play() {

thisisCanOperate = true;

}

public abstract void setBomb(int row, int col);

public void increaseBomb() {

if (thisbombNums < GlobalMAX_BOMB_NUMBER)

thisbombNums++;

}

public int getRow() {

return getRow(getBottomY(yCoodinate) - GlobalMAP_CELL / 2);

}

public int getCol() {

return getCol(xCoodinate + GlobalMAP_CELL / 2);

}

protected int getBottomY(int y) {

return y + thisheight - 1;

}

protected int getRightX(int x) {

return x + GlobalMAP_CELL - 1;

}

protected int getPreY(int y) {

return getBottomY(y) + 1 - GlobalMAP_CELL;

}

protected int getRow(int x) {

return x / GlobalMAP_CELL;

}

protected int getCol(int y) {

return y / GlobalMAP_CELL;

}

}

我的QQ是609419340

看不明白的可以随时来问我哦,还可以当时传给你撒

制作微信小程序游戏类,不懂代码的话可以找家小程序开发公司来帮你完成。如果想要找到一家比较有实力的小程序开发公司,可以从以下方面考虑:

1、适合自己的,根据你的功能需求寻找合适的,目前已经有很多现成的模板可以直接用,既能满足要求又可以不用定制开发少花钱。

2、看小程序的功能是否丰富,要知道做小程序是第一步,后面利用各种活动推广去发展你的用户才是最重要的,所以一个小程序的营销插件决定了你以后推广的力度。

3、小程序装修是否支持自定义装修,有些小程序装修风格比较单一,只能按照模板装修,相对于自定义拖拽式装修就单调很多。

4、产品是否成熟稳定,有没有经过市场检验,是否在持续升级中。

5、售后服务是否跟得上,后面你们肯定会遇到一些自己解决不了的这样那样的问题,需要技术售后支持,如果服务跟不上只会耽误你们的工作进程。

6、价格合理、性价比高。

以上就是关于谁能给我一个手机游戏的源代码啊全部的内容,包括:谁能给我一个手机游戏的源代码啊、微信小程序游戏怎么制作还有源代码怎么弄、等相关内容解答,如果想了解更多相关内容,可以关注我们,你们的支持是我们更新的动力!

欢迎分享,转载请注明来源:内存溢出

原文地址: http://outofmemory.cn/zz/9286475.html

(0)
打赏 微信扫一扫 微信扫一扫 支付宝扫一扫 支付宝扫一扫
上一篇 2023-04-26
下一篇 2023-04-26

发表评论

登录后才能评论

评论列表(0条)

保存