import java.io.IOException;
import javax.microedition.lcdui.Displayable;
import javax.microedition.lcdui.Font;
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;
import javax.microedition.lcdui.game.TiledLayer;
//////////////////////////////////////////////
//游戏类
// 游戏场景,游戏过程;
///////////////////////////////////////////////
public class MyGame extends GameCanvas
implements Runnable
{
static boolean musicON = true;
public static int stage,score,GetXue,GetShengming;
public static LayerManager lm;
public static GameSpringe
sprock,spDownRock, //石头
spjiguan,spjiguan1,spjiguan2, //机关
spzhangai, //障碍
splouti,splouti1,splouti2, //楼梯
spmen, //门
spjian,spjian1,spjian2,spjian3,//箭
spgunR1,spgunR2,spgunD1, //棍
spxin, //心
spbaozhang,spbaozhang1; //宝藏
public static GameOgre
spguai,spguai1,spguai2,spguai3,spguai4; //怪
public static GamePlayer player;
public static PlayMusic pp;
public static TiledLayer tlqiang;
private TiledLayer tlbeijing;
private Image map,caidan,beijing;
private Image tou,xue,shengming;
public static Sprite spxue,sptou,spshengming;
public static boolean isL,isR,isD,isU,isOK,isDown,isJump,isUandD;
//游戏画面
public static Displayable instance;
private boolean isKey,isEndGame,islose,flag,isMOV;
public static boolean ispause,isTime;
private int i;
private int mapqiang2[][]= {
{ 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 0, 0,
2, 2 },
{ 2, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0 },
{ 2, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0 },
{ 2, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0 },
{ 2, 0, 0, 0, 0, 0, 0, 0, 0, 0, 2, 2, 2, 2, 2, 2,
2, 2 },
{ 2, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,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, 0, 0, 0, 0, 0, 0, 0, 0, 0, 4, 4, 0, 0,
0, 4 },
{ 4, 4, 4, 4, 4, 4, 0, 0, 0, 0, 0, 0, 4, 4, 4, 4,
4, 4 }
};
private int mapbeijing2[][] = {
{ 1, 1, 1, 1, 1, 1 },
{ 3, 3, 3, 3, 3, 3 },
{ 3, 4, 3, 3, 3, 3 },
{ 3, 3, 3, 3, 3, 3 },
{ 3, 3, 3, 3, 3, 3 },
{ 3, 3, 3, 3, 4, 3 },
{ 3, 3, 3, 3, 3, 3 }
};
private int mapbeijing3 [][] = {
{ 1, 1, 1, 1, 1, 1 },
{ 3, 2, 3, 3, 3, 3 },
{ 3, 3, 3, 3, 3, 3 },
{ 4, 4, 4, 4, 4, 4 },
{ 3, 3, 3, 3, 3, 3 },
{ 3, 3, 3, 3, 3, 3 },
{ 3, 3, 3, 3, 3, 3 }
};
private int mapbeijing4[][]= {
{ 1, 2, 1, 2, 1, 2 },
{ 1, 2, 1, 2, 1, 2 },
{ 1, 2, 1, 2, 1, 2 },
{ 1, 2, 1, 2, 1, 2 },
{ 1, 2, 1, 2, 1, 2 },
{ 1, 2, 1, 2, 1, 2 },
{ 1, 2, 1, 2, 1, 2 }
};
long StartGameTime = 0;
long EedGameTime = 0;
long em = 0,mm = 0;
//创建并得到一个游戏画面的对象
synchronized public static Displayable getInstance()
{
instance = null;
if(instance == null)
instance = new MyGame();
return instance;
}
protected MyGame()
{
super(false);
setFullScreenMode(true);
stage = 2;
score = 0;
GetXue = 2;
i = 1;
GetShengming = 3;
isUandD = false;
isL = true;
isR = true;
isU = false;
isD = false;
isDown = true;
isJump = false;
isOK = false;
isKey = false;
islose = false;
isEndGame = false;
flag = true;
ispause = false;
isTime = true;
isMOV = true;
try
{
caidan = Image.createImage("/res/caidan.png");
}
catch(Exception e)
{}
Thread t = new Thread(this);
t.start();
}
protected void initGame()
{
switch (stage)
{
case 2:
isOK = false;
tlbeijing = null;
lm = null;
tlqiang = null;
pp = null;
splouti = null;
spjian = null;
spjian1 = null;
spjian2 = null;
beijing = null;
spguai = null;
spDownRock = null;
spmen = null;
spjiguan = null;
spgunR1 = null;
spgunR2 = null;
spgunD1 = null;
play
没有合适的资源?快使用搜索试试~ 我知道了~
基于java的游戏沙丘城堡源代码.zip
共108个文件
class:46个
png:39个
java:15个
1.该资源内容由用户上传,如若侵权请联系客服进行举报
2.虚拟产品一经售出概不退款(资源遇到问题,请及时私信上传者)
2.虚拟产品一经售出概不退款(资源遇到问题,请及时私信上传者)
版权申诉
0 下载量 199 浏览量
2023-05-28
00:13:04
上传
评论
收藏 312KB ZIP 举报
温馨提示
基于java的游戏沙丘城堡源代码.zip
资源推荐
资源详情
资源评论
收起资源包目录
基于java的游戏沙丘城堡源代码.zip (108个子文件)
l.class 36KB
MyGame.class 29KB
MyGame.class 27KB
GamePlayer.class 6KB
GamePlayer.class 6KB
m.class 5KB
GameSpringe.class 5KB
GameName.class 4KB
GameSpringe.class 4KB
GameOgre.class 4KB
GameName.class 4KB
GameOgre.class 3KB
MyMenu.class 3KB
MyRms.class 3KB
f.class 3KB
MyMenu.class 3KB
a.class 3KB
MyRms.class 3KB
k.class 3KB
e.class 3KB
MyCommand.class 3KB
i.class 3KB
MyCommand.class 2KB
MySet.class 2KB
GameMIDlet.class 2KB
MySet.class 2KB
GameMIDlet.class 2KB
PlayMusic.class 2KB
b.class 2KB
MyHelp.class 2KB
PlayMusic.class 2KB
MyHelp.class 2KB
MyAbout.class 2KB
GameMenu.class 2KB
MyAbout.class 2KB
g.class 2KB
GameMenu.class 2KB
GameRMS.class 2KB
h.class 2KB
GameRMS.class 1KB
n.class 1KB
BackgroupImage.class 1KB
j.class 1KB
BackgroupImage.class 1KB
d.class 1KB
c.class 954B
SQMB_SON_K700C.jad 308B
SQMB_SON_K700C.jar 134KB
MyGame.java 46KB
GamePlayer.java 8KB
GameSpringe.java 7KB
GameOgre.java 6KB
MyMenu.java 3KB
GameName.java 3KB
GameMIDlet.java 3KB
MyRms.java 2KB
MySet.java 2KB
MyCommand.java 2KB
GameMenu.java 2KB
MyHelp.java 2KB
MyAbout.java 2KB
PlayMusic.java 1KB
GameRMS.java 992B
MANIFEST.MF 222B
game1.mid 8KB
gamestart.mid 5KB
game4.mid 5KB
menu.png 15KB
louti80.png 4KB
baozhang.png 3KB
newgame1.png 3KB
count1.png 3KB
yaoshi.png 3KB
help1.png 3KB
shitou.png 3KB
about1.png 3KB
gun.png 3KB
zhangai.png 2KB
daobing.png 2KB
gongbing.png 1KB
xiaobing.png 1KB
kubing.png 1KB
play.png 1KB
map.png 695B
shengming.png 640B
louti40.png 592B
mymenu.png 538B
setSound.png 423B
tou.png 403B
icon.png 346B
men.png 325B
xiaozhangai.png 317B
xue.png 264B
jiguan.png 251B
next.png 242B
ok.png 226B
jian.png 221B
back.png 219B
caidan.png 206B
xin.png 201B
共 108 条
- 1
- 2
资源评论
易小侠
- 粉丝: 6490
- 资源: 9万+
上传资源 快速赚钱
- 我的内容管理 展开
- 我的资源 快来上传第一个资源
- 我的收益 登录查看自己的收益
- 我的积分 登录查看自己的积分
- 我的C币 登录后查看C币余额
- 我的收藏
- 我的下载
- 下载帮助
安全验证
文档复制为VIP权益,开通VIP直接复制
信息提交成功