import javax.microedition.lcdui.Graphics;
import javax.microedition.lcdui.game.GameCanvas;
import javax.microedition.lcdui.game.LayerManager;
public class Fight extends GameCanvas
implements Runnable
{
RPGGameCanvas rpgc = null;
public static Thread FightThread = null;
public static boolean isOver = true;
private boolean isAttack;
private boolean isMagicAttack;
private boolean isMagicAttackState;
private boolean isMagicState;
private boolean isProp;
private boolean isRecovery;
private boolean isBuy;
private boolean bGongFu[] = new boolean[4];
private boolean isSequece;
private boolean isMDie[] = new boolean[3];
private boolean isMDied[] = new boolean[3];
private boolean PlayMDiedOver[] = new boolean[3]; //死亡效果播放完毕
private boolean isFightOver;
private boolean FightOver; //人物打完一个回合
private boolean MFightOver[] = new boolean[3]; //怪物打完一个回合
private boolean MFighting[] = new boolean[3];
private boolean FightCanvasOver;
public Graphics g;
private short STATE; //攻击选择(游戏主线程switch选择)
private final short ATTACK = 1;
private final short MAGICATTACK = 2;
private final short PROP = 3;
private final short RECOVERY = 4;
private final short BUY = 5;
private final short FIGHT_OVER = 6;
private final short MONSTER_FIGHT = 7;
private short isState; //游戏战斗选择如状态
private short MagicState = 1; //游戏魔法选择
short i = 0;
short i2 = 0;
short i3 = 0;
short j = 0;
short step = 0;
private short Monster_State = 0;
private final short Monster1 = 1;
private final short Monster2 = 2;
private final short Monster3 = 3;
private String GongFu[] = new String[4];
private LayerManager lm = new LayerManager();
protected Fight(boolean arg0,RPGGameCanvas rpgc)
{
super(arg0);
RPGGameCanvas.mhp[0] = 100;
RPGGameCanvas.mhp[1] = 100;
RPGGameCanvas.mhp[2] = 100;
this.rpgc = rpgc;
GongFu[0] = "黯然销魂";
GongFu[1] = "万剑归宗";
GongFu[2] = "如来神掌";
GongFu[3] = "鸿哥群秒";
g = getGraphics();
STATE = 0;
isState = 1;
setFullScreenMode(true);
FightThread = new Thread(this);
FightThread.start();
}
public void run()
{
while(isOver)
{
switch(STATE)
{
case ATTACK: // '\001'
Hero_Attack();
Select();
lm.remove(LoadGame.loadimagesprite.spfHero);
isAttack = false; //打完还原
STATE = 0;
isState = 1;
break;
case MAGICATTACK: // '\002'
Hero_MagicAttack();
Select();
MagicState = 1;
isMagicState = false;
isMagicAttackState = false; //选择怪物攻击
STATE = 0;
isState = 1;
isMagicAttack = false;
break;
case PROP: // '\003'
isProp = true;
break;
case RECOVERY: // '\004'
isRecovery = true;
break;
case BUY: // '\005'
isBuy = true;
break;
case FIGHT_OVER:
FightOver();
if(LoadGame.isMusic){
if(LoadGame.loadmusic.play.getState() == 300){
LoadGame.loadmusic.play.close();
LoadGame.loadmusic.PlayBg_1();
}
}
break;
case MONSTER_FIGHT:
MonsterAttack();
break;
default:
initFight();
Select();
if(isMDied[0]&&isMDied[1]&&isMDied[2]&&LoadGame.loadimagesprite.sMonsterDied[0].getFrame()==0){
STATE = FIGHT_OVER;
if(LoadGame.isMusic){
LoadGame.loadmusic.play.close();
LoadGame.loadmusic.PlayShengLi();
}
}
if(FightOver){
STATE = MONSTER_FIGHT;
}
if(isMDied[0]&&!PlayMDiedOver[0]){
LoadGame.loadimagesprite.sMonsterDied[0].setPosition(26, 88);
lm.append(LoadGame.loadimagesprite.sMonsterDied[0]);
LoadGame.loadimagesprite.sMonsterDied[0].nextFrame();
if(LoadGame.loadimagesprite.sMonsterDied[0].getFrame()==2)
{
lm.remove(LoadGame.loadimagesprite.sMonsterDied[0]);
LoadGame.loadimagesprite.sMonsterDied[0].setFrame(0);
PlayMDiedOver[0] = true;
}
}
if(isMDied[1]&&!PlayMDiedOver[1]){
LoadGame.loadimagesprite.sMonsterDied[1].setPosition(44, 120);
lm.append(LoadGame.loadimagesprite.sMonsterDied[1]);
LoadGame.loadimagesprite.sMonsterDied[1].nextFrame();
if(LoadGame.loadimagesprite.sMonsterDied[1].getFrame()==2)
{
lm.remove(LoadGame.loadimagesprite.sMonsterDied[1]);
LoadGame.loadimagesprite.sMonsterDied[0].setFrame(0);
PlayMDiedOver[1] = true;
}
}
if(isMDied[2]&&!PlayMDiedOver[2]){
LoadGame.loadimagesprite.sMonsterDied[2].setPosition(26, 160);
lm.append(LoadGame.loadimagesprite.sMonsterDied[2]);
LoadGame.loadimagesprite.sMonsterDied[2].nextFrame();
if(LoadGame.loadimagesprite.sMonsterDied[2].getFrame()==2)
{
lm.remove(LoadGame.loadimagesprite.sMonsterDied[2]);
LoadGame.loadimagesprite.sMonsterDied[0].setFrame(0);
PlayMDiedOver[2] = true;
}
}
if(isMDie[0]&&isMDie[1]&&isMDie[2]){
isMDie[0] = false;
isMDie[1] = false;
isMDie[2] = false;
if(isFightOver){
if(bGongFu[0])
bGongFu[0] = false;
if(bGongFu[1])
bGongFu[1] = false;
if(bGongFu[2])
bGongFu[2] = false;
if(bGongFu[3])
bGongFu[3] = false;
}
}else if(isMDie[0]){
isMDie[0] = false;
FightOver = true;
if(isFightOver){
if(bGongFu[0])
bGongFu[0] = false;
else if(bGongFu[1])
bGongFu[1] = false;
else if(bGongFu[2])
bGongFu[2] = false;
else if(bGongFu[3])
bGongFu[3] = false;
}
}else if(isMDie[1]){
isMDie[1] = false;
FightOver = true;
if(isFightOver){
if(bGongFu[0])
bGongFu[0] = false;
else if(bGongFu[1])
bGongFu[1] = false;
else if(bGongFu[2])
bGongFu[2] = false;
else if(bGongFu[3])
bGongFu[3] = false;
}
}else if(isMDie[2]){
isMDie[2] = false;
FightOver = true;
if(isFightOver){
if(bGongFu[0])
bGongFu[0] = false;
else if(bGongFu[1])
bGongFu[1] = false;
else if(bGongFu[2])
bGongFu[2] = false;
else if(bGongFu[3])
bGongFu[3] = false;
}
}
if(isAttack||isMagicAttackState)
{
if(j==3)
j = 0;
j++;
}
if(isFightOver)
{
if(bGongFu[3]){
i = 3;
i2 = 3;
没有合适的资源?快使用搜索试试~ 我知道了~
古代传说 (RPG游戏)源代码
共125个文件
png:88个
class:16个
java:8个
4星 · 超过85%的资源 需积分: 10 191 下载量 173 浏览量
2008-10-28
12:23:53
上传
评论
收藏 894KB RAR 举报
温馨提示
这是我做的第一个RPG游戏,没有盛情,不过基本上的可以对人物进行对话,人物表情,各种场景的切换,和怪物战斗.... 大家要是觉得还行的话就拿去研究吧! 只要将工程导入Eclipse就可以了!分辨率240*320
资源推荐
资源详情
资源评论
收起资源包目录
古代传说 (RPG游戏)源代码 (125个子文件)
Fight.class 19KB
Fight.class 17KB
RPGGameCanvas.class 16KB
RPGGameCanvas.class 14KB
Map.class 12KB
Map.class 12KB
LoadGame.class 10KB
LoadShop.class 9KB
LoadGame.class 9KB
LoadShop.class 9KB
LoadImageSprite.class 7KB
LoadImageSprite.class 7KB
LoadMusic.class 2KB
LoadMusic.class 1KB
Midlet.class 1KB
Midlet.class 1KB
.classpath 242B
Thumbs.db 120KB
Thumbs.db 120KB
.eclipseme 256B
古代传说.jad 247B
古代传说.jad 222B
古代传说.jar 298KB
Fight.java 36KB
RPGGameCanvas.java 20KB
LoadShop.java 13KB
LoadGame.java 11KB
LoadImageSprite.java 10KB
Map.java 8KB
LoadMusic.java 1KB
Midlet.java 991B
017.mid 10KB
017.mid 10KB
002.mid 2KB
002.mid 2KB
dragon.png 45KB
dragon.png 45KB
Menu.png 34KB
Menu.png 34KB
backgroup3.png 22KB
backgroup3.png 22KB
shenglibg.png 19KB
shenglibg.png 19KB
Shop.png 13KB
Shop.png 13KB
imgBg.png 8KB
imgBg.png 8KB
ui1.png 7KB
ui1.png 7KB
HelpDiaLog.png 4KB
HelpDiaLog.png 4KB
battleface.png 3KB
battleface.png 3KB
ui.png 2KB
ui.png 2KB
touxiang.png 2KB
touxiang.png 2KB
Animation09001.png 2KB
Animation09001.png 2KB
fight02002.png 2KB
fight02002.png 2KB
imgHero.png 2KB
imgHero.png 2KB
fight02001.png 1KB
fight02001.png 1KB
biaoqing.png 889B
biaoqing.png 889B
Animation05003.png 850B
Animation05003.png 850B
smallsr.png 835B
smallsr.png 835B
Animation05001.png 809B
Animation05001.png 809B
feng.png 771B
feng.png 771B
MonsterDied.png 681B
MonsterDied.png 681B
uiwenzi1.png 653B
uiwenzi1.png 653B
liang.png 648B
liang.png 648B
menuB4.png 544B
menuB4.png 544B
menuB3.png 526B
menuB5.png 526B
menuB3.png 526B
menuB5.png 526B
menuB1.png 516B
menuB1.png 516B
menuB2.png 507B
menuB2.png 507B
MIDlet-1.png 489B
MIDlet-1.png 489B
cateran3.png 480B
cateran3.png 480B
qiu.png 465B
qiu.png 465B
cateran5.png 459B
cateran5.png 459B
cateran9.png 412B
共 125 条
- 1
- 2
资源评论
- 屌丝会有逆袭日2013-02-13有点问题 说实话
- wangqiao27292011-12-03小白问题,,,为什么我导入完了全是错误~~~
- 冬泉雪石2017-11-03真的不错啊
- java850999243wapcpp2014-02-11参考下代码 挺不错的
- deli_zk2015-11-14可以参考 不错
FS-Leehom
- 粉丝: 99
- 资源: 21
上传资源 快速赚钱
- 我的内容管理 展开
- 我的资源 快来上传第一个资源
- 我的收益 登录查看自己的收益
- 我的积分 登录查看自己的积分
- 我的C币 登录后查看C币余额
- 我的收藏
- 我的下载
- 下载帮助
最新资源
资源上传下载、课程学习等过程中有任何疑问或建议,欢迎提出宝贵意见哦~我们会及时处理!
点击此处反馈
安全验证
文档复制为VIP权益,开通VIP直接复制
信息提交成功