📄 gamecanvas.java
字号:
else if( ((soft1Key&& rowIndex==1 && iMenu==false) || KeyFire) && gameData[19] == 0 && count == 0 )
{
if( gameMode == 0 )
{
// 从支点向跳跃转换
SetSoftLabel("回主界面","攀登模式");
gameMode = 1;
gameData[30] = 2;
}
else if( gameMode == 1 )
{
// 从跳跃向支点转换
SetSoftLabel("回主界面","跳跃模式");
gameMode = 0;
gameData[30] = 2;
}
}
else if(soft2Key) iMenu=false;//iMenu控制菜单的显示
// 动画片的计算
if( count2 == 1 || count2 == 2 )
{
count2++;
gameData[2] = 0;
}
// 支点判定
if( gameMode == 0 && count > 1 )
gameData[30] = catchHold();
else if( gameMode == 1 && gameData[19] == 0 && count == 2 )
gameData[30] = jumpAction();
// 时间计算
if( timeSet != 0 && ifPhone == false && usedTime < 180000 )
usedTime += 1000/sysData[7];
// 游戏超过判定
//gameData[19]控制跳跃
if( usedTime >= 180000 )
{
usedTime = 180000;
gameState = 8;
gameData[30] = 3;
isMove = 0;
gameData[19] = 0;
// sound.Play(5,1);
SetSoftLabel("回主界面","");
}
// 跳跃
if( gameData[19] == 1 )
jumpAnimation();
// 是 0 以下高度一 0 表示就为0
if( pHeight <= 0 )
pHeight = 0;
// 到各路线终点地点的高度不表示的
else if( pHeight >= gameData[6]*1000 && degree != 0 )
pHeight = gameData[6]*1000;
// 落下判定
if( gMax1 <= 0 )
{
gameData[21] = 1+gameData[19];
gameData[19] = 0;
gameState = 7;
gameData[28]++;
count = 30;
}
if( usedTime > 0 && gameState != 8
&& (leftHand == 0 || rightHand == 0) )
{
// 极限量减少
if( usedTime%15 == 0 && sysData[4] == 0 )
gMax1-= 4+rValue+15/((5-degree)*(4-gameData[17]/3));
// 限度恢复MAX值减少
if( usedTime%(100-degree*5) == 0 && sysData[4] == 0 )
gMax2--;
}
// 现在的高度
gameData[7] = pHeight/1000;
// 游戏过关判定
if( degree != 0 && gameData[19] == 0
&& gameData[7] >= gameData[6] )
{
// 完美判定
if( gameData[28] == 0 )
{
aArray[degree-1] = 1;
SetRecord( 4+degree-1, aArray[gameData[4-1]] );
}
// 最好的时间判定
if( usedTime < Score[degree-1] && BestScore == 0 )
{
Score[degree-1] = usedTime;
SetRecord( 8+degree-1, Score[degree-1]);
BestScore = 1;
}
// 音乐演奏 正常过关是 SND_GOAL ,不错误和最好的时间是 SND_BESTTIM
/* if( aArray[degree-1] == 1 || BestScore == 1 )
sound.Play(4,1);
else
sound.Play(3,1);*/
gameData[19] = 0;
isMove = 0;
gameState = 9;
}
gameData[2]++;
break;
}
// 落下
case 7:
{
if( KeyFire && count > 45 )
{
gameState = 5;
gameData[9] = 0;
gameData[30] = 3;
usedTime+=10000;
count = 0;
}
// 软件按键处理
if( soft1Key )
backTitle();
// 落下时动画
if( gameData[21] > 0 )
{
// 摇动手
if( leftHand < 6 )
leftHand+=2;
else if( leftHand > 2 )
leftHand-=2;
if( rightHand > 2 )
rightHand-=2;
else if( rightHand < 6 )
rightHand+=2;
// 摇动脚
if( leftFoot == 0 )
leftFoot+=2;
else if( leftFoot == 2 )
leftFoot-=2;
if( rightFoot == 0 )
rightFoot+=2;
else if( rightFoot == 2 )
rightFoot-=2;
if( pMove != 0 && gameData[15] < 100-10*(gameData[21]/2) )
{
gameData[15]+=10;
pHeight-=500;
}
else if( pMove == 0 && gameData[15] < 80-10*(gameData[21]/2) )
{
gameData[15]+=10;
pHeight-=500;
}
else
{
gMax1 = 120;
gMax2 = 120;
if( pMove == 0 )
gameData[15] = 80;
else
gameData[15] = 100;
gameData[21] = 0;
gameData[14] = gameData[14]/10*10+9;
if( gameData[14] > 10 )
leftHand = 0;
else
leftHand = 2;
rightHand = 0;
gameData[16] = 0;
gameData[19] = 0;
isMove = 0;
count = 32;
}
gameData[30] = 2;
}
// 进行落下的动画片计数器
if( gameState == 7 )
count++;
break;
}
// 游戏过关
case 9:
{
// 回到难度级别选择界面
if( soft1Key )
KeyFire = true;
if( KeyFire )
{
SetSoftLabel("回主界面","");
// sound.Play(1,2);
InitGame();
gameState = 3;
gameData[30] = 3;
}
// 追加以路线选择能选择的路线
if( degree0 == degree-1 && degree0 < 3 )
{
degree0++;
SetRecord( 3, degree0 );
}
break;
}
// 游戏超过
case 8:
{
if( KeyFire )
{
SetSoftLabel("回主界面","");
// sound.Play(1,2);
InitGame();
gameState = 3;
gameData[30] = 3;
}
// 软件按键处理
if( soft1Key )
backTitle();
break;
}
// 路线选择
case 3:
{
// 以左右按键选择路线
if( soft1Key )KeyFire=true;
if( soft2Key )backTitle();
if( KeyRight && degree < degree0+1 )
{
if( degree < 4 )
degree++;
gameData[30] = 3;
}
if( KeyLeft && degree > 0 )
{
degree--;
gameData[30] = 3;
}
// 去下一个场面
if( KeyFire )
{
gameData[7] = 0;
gameState = 0;
gameData[30] = 0;
}
// 软件按键处理
// 路线的高度组合
if( degree == 0 )
gameData[6] = 0;
else
gameData[6] = 15*degree;//20*(game[GAME_LEVEL]-1)+10;
break;
}
// 初始化
case 0:
{
// 路线安排
makeCource();
// 游戏数据初始化
InitGame();
// 终点位置安排
if( degree == 1 )
route[363] = 999;//cource[11*GOAL_BEGINNER] = 999;
else if( degree == 2 )
route[693] = 999;//cource[11*GOAL_MIDDLE] = 999;
else if( degree == 3 )
route[1023] = 999;//cource[11*GOAL_UPPER] = 999;
else if( degree == 4 )
route[1353] = 999;//cource[11*GOAL_BEST] = 999;
// 去下一个场面
gameState = 5;
gameData[30] = 3;
// 音乐再现
// sound.Play( 2, 2);
// 音乐再现
SetSoftLabel("回主界面","跳跃模式");
gameMode = 0;
System.gc();
break;
}
// 回主界面画面
case 2:
{
// 以左右按键选择菜单
if( KeyRight && gMenu < 3 )
{
gMenu++;
gameData[30] = 3;
}
if( KeyLeft && gMenu > 0 )
{
gMenu--;
gameData[30] = 3;
}
// 去下一个场面
// 软件按键处理
// gameState = 13;
if( soft1Key ){KeyFire=true;}// 进入(开始)游戏,原来是退出游戏的
if( KeyFire )
{
if( gMenu == 0 )
{
gameState = 3;
SetSoftLabel("回主界面","");
cImage[60] = null;
cImage[61] = null;
cImage[62] = null;
cImage[63] = null;
cImage[64] = null;
try
{
for(int i=49;i>0;i--)
cImage[i] = Image.createImage( "/" + i + ".png" );
}
catch(Exception e)
{
}
}
else if( gMenu == 1 )
{
gameState = 11;
gState = 1;
SetSoftLabel("回主界面","");
}
else if(gMenu ==2)
{
gameState = 10;
SetSoftLabel("回主界面","发送");
}
else if(gMenu ==3)
{
App.Exit();
}
gameData[30] = 3;
// 音乐演奏
// sound.Play( 1, 2);
}
// 想要接受按键输入
count = 0;
//repaint();
//serviceRepaints();
break;
}
// 操作说明(帮助)
case 11:
{
// 以左右按键送说明句子
if( KeyLeft && gState > 1 )
gState--;
if( KeyRight && gState < 6 )
gState++;
// 软件按键处理
if( soft1Key ==true || soft2Key ==true)
{gameState=2;gMenu=0;}
break;
}
// 积分排行榜
case 10:
{
// 软件按键处理
if( soft1Key ==true || soft2Key ==true)
{gameState=2;gMenu=0;}
//backTitle();
break;
}
// 证据认处理及high score发送处理
case 12:
{
// 决定按键发送消息的
if( soft1Key && gState == 0 )
{
gState = 1;
SetSoftLabel("","");
}
// 发送中
else if( gState == 1 )
{
gState = 2;
SetSoftLabel("继续","");
}
// 认证完成通知
else if( soft1Key && gState == 2 )
{
// 去回主界面画面
gameState = 2;
gameData[30] = 3;
// 音乐再现
//sound.Play( 0, 2);
SetSoftLabel("开始","");
}
// 再入
else if( soft1Key && gState == 3 )
{
// 浏览器启动
// nowCorp.Browser( nowCorp.CHARGE_URL );
// 浏览器发动 Appli 结束
gameState = 13;
}
// 通讯错误
else if( soft1Key && gState == 4 )
{
// Appli 结束
gameState = 13;
}
// 比分发送
else if( gState == 5 )
{
//("比分发送处理");
// boolean bRes = nowCorp.Send( GetSendParam() );
try { Thread.sleep( 500 ); }
catch( Throwable t ) {}
}
// 比分发送完成
else if( gState == 6 )
{
// 决定按键的处理
if( soft1Key )
{
gState = 9;
SetSoftLabel("确认","返回");
}
}
// 通讯错误或者没有high score
else if( gState == 7 || gState == 8 )
{
// 软件按键2处理
if( soft2Key )
{
gameState = 10;
// sound.Play( 1, 2 );
SetSoftLabel("回主界面","发送");
}
}
// 排列次序确认
else if( gState == 9 )
{
// 软件按键 1 的处理
if( soft1Key )
{
// 浏览器起动
// nowCorp.Browser( nowCorp.RANKING_URL );
// 浏览器启动废除回来到发送前画面
gameState = 10;
// sound.Play( 1, 2 );
SetSoftLabel("回主界面","发送");
}
// 软件按键 2 的处理
if( soft2Key )
{
gameState = 10;
// sound.Play( 1, 2 );
//SetSoftLabel("回主界面","发送");
}
}
break;
}
}
//----------------------------------------------------------------------
// FPS 调整试验
//----------------------------------------------------------------------
//key flag的初始化每(绘画一回)
//-----------------------------------
KeyUp =false;//全部推倒
KeyDown =false;
KeyLeft =false;
KeyRight =false;
KeyFire =false;
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -