手游源码网免费源码(谁有手机安卓游戏的源代码)

:暂无数据 2026-09-27 21:10:01 :1

手游源码网免费源码(谁有手机安卓游戏的源代码)

今天给各位分享谁有手机安卓游戏的源代码的知识,其中也会对谁有手机安卓游戏的源代码进行解释,如果能碰巧解决你现在面临的问题,别忘了关注本站,现在开始吧!

本文目录

谁有手机安卓游戏的源代码

百度搜“游戏源码-Android
ligotop”,
ligotop这个网站有很多安卓源码,包括游戏源码。

在哪些网站中可以获得scratch游戏源码

爱给网。进入爱给网站后点击,游戏,再点击游戏源码,可以看到游戏源码栏目,然后再点击scratch分类,这样就能找到游戏源码了。

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

这个地址也有,不过直接给你吧,这样比较好
先给你看看主要的类吧
package Game;
import DreamBubbleMidlet;
import java.io.IOException;
import java.util.Enumeration;
import java.util.Hashtable;
import javax.microedition.lcdui.Graphics;
import javax.microedition.lcdui.Image;
import javax.microedition.lcdui.game.GameCanvas;
import javax.microedition.lcdui.game.LayerManager;
import javax.microedition.lcdui.game.Sprite;
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);
this.setFullScreenMode(true);
this.dreamBubbleMidlet = dreamBubbleMidlet;
this.screenWidth = this.getWidth();
this.screenHeight = this.getHeight();
try {
this.loadingImage = Image.createImage("/Game/Loading.png");
this.pauseImage = Image.createImage("/Game/Pause.png");
this.cursorImage = Image.createImage("/Game/Cursor.png");
this.jackStateImage = Image.createImage("/State/JackState.png");
this.johnStateImage = Image.createImage("/State/JohnState.png");
this.numberImage = Image.createImage("/State/Number.png");
} catch (IOException e) {
e.printStackTrace();
}
this.g = this.getGraphics();
}
public void loadStage(int stage) {
this.isEnd = false;
this.isPause = false;
this.isPlaying = false;
this.gameLayerManager = new LayerManager();
this.cursorManager = new LayerManager();
this.numberManager = new LayerManager();
this.bombTable = new Hashtable();
this.cursor = new Sprite(this.cursorImage, 32, 32);
this.number = new Sprite(this.numberImage, 12, 10);
this.loadPercent = 20;
sleep();
loadMap(stage);
this.loadPercent = 40;
sleep();
loadPlayer();
this.loadPercent = 60;
sleep();
this.gameLayerManager.append(map.getBombLayer());
this.gameLayerManager.append(map.getBuildLayer());
this.gameLayerManager.append(map.getToolLayer());
this.gameLayerManager.append(map.getFloorLayer());
this.gameLayerManager.setViewWindow(0, -5, screenWidth,
Global.MAP_HEIGHT + 5);
this.cursorManager.append(cursor);
this.numberManager.append(number);
this.loadPercent = 80;
sleep();
this.loadPercent = 100;
sleep();
isPlaying = true;
}
public void run() {
while (!isEnd) {
long beginTime = System.currentTimeMillis();
this.drawScreen();
long endTime = System.currentTimeMillis();
if (endTime - beginTime 《 this.delay) {
try {
Thread.sleep(this.delay - (endTime - beginTime));
} catch (InterruptedException e) {
e.printStackTrace();
}
}
}
}
public void loadMap(int stage) {
switch (stage) {
case 0:
this.map = new Map(Global.MAP_BLOCK);
this.bornPlace = Global.MAP_BLOCK_BORNPLACE;
break;
case 1:
this.map = new Map(Global.MAP_FACTORY);
this.bornPlace = Global.MAP_FACTORY_BORNPLACE;
break;
case 2:
this.map = new Map(Global.MAP_FOREST);
this.bornPlace = Global.MAP_FOREST_BORNPLACE;
break;
case 3:
this.map = new Map(Global.MAP_PIRATE);
this.bornPlace = Global.MAP_PIRATE_BORNPLACE;
break;
case 4:
this.map = new Map(Global.MAP_FAUBOURG);
this.bornPlace = Global.MAP_FAUBOURG_BORNPLACE;
break;
}
}
public void loadPlayer() {
this.player = SingleGameRole.createSingleGameRole(this, Global.JACK,
this.bornPlace);
this.gameLayerManager.append(player);
try {
this.playerGhost = new Sprite(Image.createImage("/Character/Jack.png"),
this.player.width, this.player.height);
this.gameLayerManager.append(playerGhost);
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
public void playerUpdate() {
if(!this.player.isAlive)
this.playerGhost.setVisible(false);
this.playerGhost.setFrame(this.player.getFrame());
this.player.updateRole();
}
public void bombUpdate() {
Enumeration enu = this.bombTable.keys();
while (enu.hasMoreElements()) {
String key = (String) enu.nextElement();
Bomb bomb = (Bomb) (bombTable.get(key));
if (bomb.isvisable) {
bomb.update();
} else {
bombTable.remove(key);
bomb = null;
}
}
}
public void mapUpdate() {
this.map.update();
}
public void drawScreen() {
if (gameClock 《 10000)
gameClock++;
else
gameClock = 0;
if (!this.isLoading) {
if (!isPause) {
this.operate();
this.bombUpdate();
this.playerUpdate();
this.mapUpdate();
g.setColor(0x000000);
g.fillRect(0, 0, getWidth(), getHeight());
this.drawState();
gameLayerManager.paint(g, 0, this.screenHeight
- Global.MAP_HEIGHT - 5);
} else {
this.drawPauseFrame();
}
} else {
this.drawLoadingFrame();
}
this.flushGraphics();
}
public void drawFailScreen() {
}
public void drawState() {
if (this.player.type == Global.JACK) {
g.drawImage(jackStateImage, 60, 5, Graphics.TOP | Graphics.LEFT);
}
if (this.player.type == Global.JOHN) {
g.drawImage(johnStateImage, 60, 5, Graphics.TOP | Graphics.LEFT);
}
this.number.setFrame(this.player.bombNums);
this.numberManager.paint(g, 101, 15);
this.number.setFrame(this.player.speed);
this.numberManager.paint(g, 133, 15);
this.number.setFrame(this.player.power);
this.numberManager.paint(g, 165, 15);
}
protected void drawPauseFrame() {
g.setColor(0x000000);
g.fillRect(0, 0, getWidth(), getHeight());
this.drawState();
if (gameClock % 5 == 0)
this.cursor.setFrame((this.cursor.getFrame() + 1) % 4);
this.gameLayerManager.paint(g, 0, this.screenHeight - Global.MAP_HEIGHT
- 5);
this.cursorManager.paint(g, screenWidth / 2 - pauseImage.getWidth() / 2
- 32, screenHeight / 2 - pauseImage.getHeight() / 2
+ this.chooseIndex * 33 + 24);
g.drawImage(pauseImage, screenWidth / 2, screenHeight / 2,
Graphics.HCENTER | Graphics.VCENTER);
}
protected void drawLoadingFrame() {
g.setColor(66, 70, 246);
g.fillRect(0, 0, screenWidth, screenHeight);
g.drawImage(loadingImage, screenWidth / 2, 2 * screenHeight / 5,
Graphics.HCENTER | Graphics.VCENTER);
g.setColor(0, 255, 0);
g.fillRect((screenWidth - 120) / 2, 2 * screenHeight / 3,
(this.loadPercent * 120) / 100, 10);
g.setColor(255, 0, 0);
g.drawRect((screenWidth - 120) / 2, 2 * screenHeight / 3, 120, 10);
}
public void showMe() {
new Loading(this.stageIndex);
if (this.mainThread == null) {
mainThread = new Thread(this);
mainThread.start();
}
this.dreamBubbleMidlet.show(this);
}
public void operate() {
int keyStates = getKeyStates();
this.playerGhost.setPosition(this.player.xCoodinate, this.player.yCoodinate);
if ((keyStates & DOWN_PRESSED) != 0) {
this.player.walk(Global.SOUTH);
} else {
if ((keyStates & UP_PRESSED) != 0) {
this.player.walk(Global.NORTH);
} else {
if ((keyStates & RIGHT_PRESSED) != 0) {
this.player.walk(Global.EAST);
} else {
if ((keyStates & LEFT_PRESSED) != 0) {
this.player.walk(Global.WEST);
}
}
}
}
}
protected void keyPressed(int key) {
if (!this.isPlaying)
return;
if (!this.isPause && key == -7) {// 右键
this.chooseIndex = 0;
this.pauseGame();
return;
}
if (key == 35) {// #键
this.nextStage();
return;
}
if (key == 42) {// *键
this.preStage();
return;
}
if (this.isPause) {
switch (key) {
case -1:
case -3:
if (this.chooseIndex == 0)
this.chooseIndex = 2;
else
this.chooseIndex = (this.chooseIndex - 1) % 3;
break;
case -2:
case -4:
this.chooseIndex = (this.chooseIndex + 1) % 3;
break;
case -5:// 确认键
case -6:// 左软键
switch (chooseIndex) {
case 0:
this.continueGame();
break;
case 1:
this.restart();
break;
case 2:
this.endGame();
break;
}
break;
default:
break;
}
} else {
switch (key) {
case 53:
case -5:// 确认键
this.player.setBomb(this.player.getRow(), this.player.getCol());
break;
}
}
}
public void restart() {
new Loading(this.stageIndex);
}
public void continueGame() {
this.isPause = false;
this.player.play();
}
public void pauseGame() {
this.isPause = true;
this.player.stop();
}
public void endGame() {
this.isEnd = true;
this.mainThread = null;
System.gc();
try {
Thread.sleep(500);
} catch (InterruptedException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
this.dreamBubbleMidlet.menu.showMe();
}
public void nextStage() {
if (this.stageIndex 《 4) {
this.stageIndex++;
}
new Loading(this.stageIndex);
}
public void preStage() {
if (this.stageIndex 》 0) {
this.stageIndex--;
}
new Loading(this.stageIndex);
}
class Loading implements Runnable {
private Thread innerThread;
private int stageIndex;
public Loading(int stageIndex) {
this.stageIndex = stageIndex;
innerThread = new Thread(this);
innerThread.start();
}
public void run() {
isLoading = true;
loadPercent = 0;
System.gc();
loadStage(stageIndex);
isLoading = false;
}
}
public void sleep() {
try {
Thread.sleep(100);
} catch (InterruptedException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
}
这个是游戏主体类
下面是游戏的人物类
package Game;
import javax.microedition.lcdui.Image;
import javax.microedition.lcdui.game.Sprite;
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;
/**
* 人物放置炸弹的基本属性
*/
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);
this.game = game;
}
/**
* 人物拾起道具
* @param tool
*/
public abstract void pickupTool(int tool);
/**
* 碰撞检测以及坐标的改变,如果对行走条件有特殊需求,既可以在这里写自己的条件
* @param direction
*/
public abstract void collisionCheck(int direction);

public void updateRole() {
if (this.characterClock 《 10000) {
this.characterClock++;
} else {
this.characterClock = 100;
}
int row = this.getRow();
int col = this.getCol();
if (this.isAlive) {

int tool = this.game.map.getToolLayer().getCell(col, row);

if (tool 》 0) {
this.pickupTool(tool);
this.game.map.getToolLayer().setCell(col, row, 0);
}
if (this.game.map.hasFeature(row, col, Global.DEADLY)) {
this.isAlive = false;
return;
}
if (this.status == Global.BORN
&& this.characterClock 》 Global.BORN_TIME) {
this.status = Global.SOUTH;
this.setFrame(Global.SOUTH * 6);
this.isCanOperate = true;
}
if (this.status == Global.BORN) {
if (this.characterClock % 2 == 0)
this.setFrame(Global.BORN * 6 + (this.getFrame() - 1) % 4);
return;
}

} else {
this.isCanOperate = false;
if (this.deadTime 《= 20) {
this.deadTime++;
} else {
this.deadTime = 100;
this.setVisible(false);
return;
}
if (this.characterClock % 2 == 0) {
if (this.getFrame() 《 Global.DEAD * 6) {
this.setFrame(Global.DEAD * 6);
} else {
if (this.getFrame() 《 29) {
this.setFrame(this.getFrame() + 1);
} else {
if (this.characterClock % 4 == 0) {
this.setFrame(29);
this.setVisible(true);
} else {
this.setVisible(false);
}
}
}
}
}
}

public void walk(int direction) {
if (!isAlive)
return;
if (!isCanOperate)
return;
if(direction==9) return;
this.collisionCheck(direction);

if (this.characterClock % 2 == 0) {
if (this.status == direction) {
this.setFrame(this.status * 6 + (this.getFrame() + 1) % 6);
} else {
this.status = direction;
this.setFrame(this.status * 6);
}
}
this.setPosition(xCoodinate, yCoodinate);
}
public void stop() {
this.isCanOperate = false;
}
public void play() {
this.isCanOperate = true;
}
public abstract void setBomb(int row, int col);
public void increaseBomb() {
if (this.bombNums 《 Global.MAX_BOMB_NUMBER)
this.bombNums++;
}
public int getRow() {
return getRow(getBottomY(yCoodinate) - Global.MAP_CELL / 2);
}
public int getCol() {
return getCol(xCoodinate + Global.MAP_CELL / 2);
}
protected int getBottomY(int y) {
return y + this.height - 1;
}
protected int getRightX(int x) {
return x + Global.MAP_CELL - 1;
}
protected int getPreY(int y) {
return getBottomY(y) + 1 - Global.MAP_CELL;
}
protected int getRow(int x) {
return x / Global.MAP_CELL;
}
protected int getCol(int y) {
return y / Global.MAP_CELL;
}
}
我的QQ是609419340
看不明白的可以随时来问我哦,还可以当时传给你撒

关于手游源码网免费源码和谁有手机安卓游戏的源代码的介绍到此就结束了,不知道你从中找到你需要的信息了吗 ?如果你还想了解更多这方面的信息,记得收藏关注本站。

手游源码网免费源码(谁有手机安卓游戏的源代码)

本文编辑:admin

更多文章:


网页特效懒人之家(网页怎么做鼠标移到图片就显示文字)

网页特效懒人之家(网页怎么做鼠标移到图片就显示文字)

各位老铁们好,相信很多人对网页特效懒人之家都不是特别的了解,因此呢,今天就来为大家分享下关于网页特效懒人之家以及网页怎么做鼠标移到图片就显示文字的问题知识,还望可以帮助大家,解决大家的一些困惑,下面一起来看看吧!

2026年10月23日 06:20

威斯布鲁克交易最新消息(火箭正式完成了什么交易)

威斯布鲁克交易最新消息(火箭正式完成了什么交易)

各位老铁们好,相信很多人对威斯布鲁克交易最新消息都不是特别的了解,因此呢,今天就来为大家分享下关于威斯布鲁克交易最新消息以及火箭正式完成了什么交易的问题知识,还望可以帮助大家,解决大家的一些困惑,下面一起来看看吧!

2026年10月23日 05:30

csvwrite函数(matlab保存csv遇到的问题)

csvwrite函数(matlab保存csv遇到的问题)

“csvwrite函数”相关信息最新大全有哪些,这是大家都非常关心的,接下来就一起看看csvwrite函数(matlab保存csv遇到的问题)!

2026年10月23日 04:30

jquery动态添加表格行(如何通过jquery动态给表格添加一行)

jquery动态添加表格行(如何通过jquery动态给表格添加一行)

其实jquery动态添加表格行的问题并不复杂,但是又很多的朋友都不太了解如何通过jquery动态给表格添加一行,因此呢,今天小编就来为大家分享jquery动态添加表格行的一些知识,希望可以帮助到大家,下面我们一起来看看这个问题的分析吧!

2026年10月23日 00:30

cmake命令行参数(CMake (三)cmake 在工程中的用法)

cmake命令行参数(CMake (三)cmake 在工程中的用法)

本篇文章给大家谈谈cmake命令行参数,以及CMake (三)cmake 在工程中的用法对应的知识点,希望对各位有所帮助,不要忘了收藏本站喔。

2026年10月23日 00:00

游戏代码翻译器下载(求游戏实时翻译软件)

游戏代码翻译器下载(求游戏实时翻译软件)

“游戏代码翻译器下载”相关信息最新大全有哪些,这是大家都非常关心的,接下来就一起看看游戏代码翻译器下载(求游戏实时翻译软件)!

2026年10月22日 23:50

linux数据备份命令(Linux系统下常用的数据备份方法有哪些)

linux数据备份命令(Linux系统下常用的数据备份方法有哪些)

大家好,今天小编来为大家解答以下的问题,关于linux数据备份命令,Linux系统下常用的数据备份方法有哪些这个很多人还不知道,现在让我们一起来看看吧!

2026年10月22日 23:20

小程序开发平台开源(有哪些快速开发平台或者零代码开发平台)

小程序开发平台开源(有哪些快速开发平台或者零代码开发平台)

大家好,如果您还对小程序开发平台开源不太了解,没有关系,今天就由本站为大家分享小程序开发平台开源的知识,包括有哪些快速开发平台或者零代码开发平台的问题都会给大家分析到,还望可以解决大家的问题,下面我们就开始吧!

2026年10月22日 23:10

executequery返回值(ExecuteQuery(sql)的返回值)

executequery返回值(ExecuteQuery(sql)的返回值)

大家好,executequery返回值相信很多的网友都不是很明白,包括ExecuteQuery(sql)的返回值也是一样,不过没有关系,接下来就来为大家分享关于executequery返回值和ExecuteQuery(sql)的返回值的一些

2026年10月22日 23:00

web个性布局模板(FrontPage简明教程:网页布局)

web个性布局模板(FrontPage简明教程:网页布局)

各位老铁们,大家好,今天由我来为大家分享web个性布局模板,以及FrontPage简明教程:网页布局的相关问题知识,希望对大家有所帮助。如果可以帮助到大家,还望关注收藏下本站,您的支持是我们最大的动力,谢谢大家了哈,下面我们开始吧!

2026年10月22日 22:50

最近更新

seo优化培训海瑶,新手怎么选课程?
2026-10-23 06:40:15 浏览:0
debate名词(debate的用法及搭配)
2026-10-23 06:40:02 浏览:0
河源谷歌seo如何收费,到底贵不贵?
2026-10-23 06:36:14 浏览:0
热门文章

wait for you杨和苏(大家听下(wait for you)这首英文歌的开头那段音乐)
2026-06-13 16:20:04 浏览:26
刷关键字排名怎么操作最有效?
2026-09-14 20:02:13 浏览:20
标签列表