?? gamelogic.java.bak
字號:
M_iHPlay[1] = (M_Bomb[i][1] * 16);
M_Bomb[i][2] = (byte) kk;
M_iHPlay[2] = (M_Bomb[i][2] * 16);
M_Bomb[i][3] = bombset; // bomb live time
M_Bomb[i][4] = (byte) (M_iHPlay[4]);
break;
}
}
}
}
}
else
{ ///////////////////////////////////處理行走
oldmandirect = (byte) M_iHPlay[3];
// m_pathW=16-M_iHPlay[5]; //修改行走
m_pathW = 16 - M_iHPlay[5];
if (m_iKey == KEY_LEFT)
{ //<<----------
x = x - M_iHPlay[5];
// if (M_imapno[ (y) >> 4][ (x ) >> 4] !=1 && x-(((x)>>4)<<4)+16 < M_iHPlay[5])
// x = (((x)>>4)<<16)+16 ;
if (M_imapno[ (y) >> 4][ (x ) >> 4] == 1 &&
M_imapno[ (y + 16) >> 4][ (x) >> 4] == 1)
{
M_iHPlay[1] = x;
M_iHPlay[2] = y;
}
else if (M_imapno[ (y + M_iHPlay[5] + 2) / 16][x / 16] == 1 &&
M_imapno[ (y + m_pathW - 2) / 16][x / 16] == 1)
{
M_iHPlay[1] = x;
if ( (y & 0xf) <= 5)
{
k = 0;
}
else
{
k = 16;
}
M_iHPlay[2] = ( (y >> 4) << 4) + k;
}
x = x - M_iHPlay[5];
if (M_imapno[ (y) >> 4][ (x ) >> 4] !=1 && (M_iHPlay[1]-(((x)>>4)<<4)-16) < M_iHPlay[5])
{
System.out.println("fix move bug left");
M_iHPlay[1] = ( ( (x) >> 4) << 4) + 16;
}
i = 0;
}
else if (m_iKey == KEY_UP)
{ ////// up
y = y - M_iHPlay[5];
// if (M_imapno[ (y) >> 4][ (x ) >> 4] !=1 && y-(((y)>>4)<<4)+16 < M_iHPlay[5])
// y = (((y)>>4)<<16)+16 ;
if (M_imapno[y >> 4][ (x) >> 4] == 1 &&
M_imapno[y >> 4][ (x + 16) >> 4] == 1)
{
M_iHPlay[1] = x;
M_iHPlay[2] = y;
}
else if (M_imapno[ (y) >> 4][ (x + M_iHPlay[5] + 2) >> 4] == 1 &&
M_imapno[ (y) >> 4][ (x + m_pathW - 2) >> 4] == 1)
{ //修改
if ( (x & 0xf) <= 5)
{
k = 0;
}
else
{
k = 16;
}
M_iHPlay[1] = ( (x >> 4) << 4) + k;
M_iHPlay[2] = y;
}
y = y - M_iHPlay[5];
if (M_imapno[ (y) >> 4][ (x ) >> 4] !=1 && (M_iHPlay[2]-(((y)>>4)<<4)-16) < M_iHPlay[5])
{
System.out.println("fix move bug up");
M_iHPlay[2] = ( ( (y) >> 4) << 4) + 16;
}
i = 1;
}
else if (m_iKey == KEY_RIGHT)
{ ///---->
x = x + M_iHPlay[5];
// if (M_imapno[ (y) >> 4][ (x ) >> 4] !=1 && (((x)>>4)<<4) - (x+16) < M_iHPlay[5])
// x = (((x)>>4)<<16)-16 ;
if (M_imapno[y >> 4][x >> 4] == 3 &&M_imapno[y >> 4][(x+16) >> 4] == 1)
{
M_iHPlay[1] = x;
M_iHPlay[2] = y;
}
if (M_imapno[ (y) >> 4][ (x + m_pathW) >> 4] == 1 &&
M_imapno[ (y + 16) >> 4][ (x + m_pathW) >> 4] == 1)
{
M_iHPlay[1] = x;
M_iHPlay[2] = y;
}
else if (M_imapno[ (y + M_iHPlay[5] + 2) >> 4][ (x + m_pathW) >> 4] ==
1 &&
M_imapno[ (y + m_pathW - 2) >> 4][ (x + m_pathW) >> 4] == 1)
{
if ( (y & 0xf) <= 5)
{
k = 0;
}
else
{
k = 16;
}
M_iHPlay[1] = x;
M_iHPlay[2] = ( (y >> 4) << 4) + k;
}
/* x = x + M_iHPlay[5];
if (M_imapno[ (y) >> 4][ (x ) >> 4] !=1 && ((((x)>>4)<<4)-M_iHPlay[1]-16) < M_iHPlay[5])
{
System.out.println("fix move bug right");
M_iHPlay[1] = ( ( (x) >> 4) << 4) - 16;
} */
i = 2;
}
else if (m_iKey == KEY_DOWN)
{ ////// down
y = y + M_iHPlay[5];
// if (M_imapno[ (y) >> 4][ (x ) >> 4] !=1 && (((y)>>4)<<4) - (y+16) < M_iHPlay[5])
// y = (((y)>>4)<<16)-16;
if (M_imapno[y >> 4][x >> 4] == 3 && M_imapno[(y+16) >> 4][x >> 4] == 1)
{
M_iHPlay[1] = x;
M_iHPlay[2] = y;
}
if (M_imapno[ (y + m_pathW) >> 4][ (x) >> 4] == 1 &&
M_imapno[ (y + m_pathW) >> 4][ (x + 16) >> 4] == 1)
{
M_iHPlay[1] = x;
M_iHPlay[2] = y;
}
else if (M_imapno[ (y + m_pathW) >> 4][ (x + M_iHPlay[5] + 2) >> 4] ==
1 &&
M_imapno[ (y + m_pathW) >> 4][ (x + m_pathW - 2) >> 4] == 1)
{
if ( (x & 0xf) <= 5)
{
k = 0;
}
else
{
k = 16;
}
M_iHPlay[1] = ( (x >> 4) << 4) + k;
M_iHPlay[2] = y;
}
/* y = y - M_iHPlay[5];
if (M_imapno[ (y) >> 4][ (x ) >> 4] !=1 && ((((y)>>4)<<4)-M_iHPlay[2]-16) < M_iHPlay[5])
{
System.out.println("fix move bug down");
M_iHPlay[2] = ( ( (y) >> 4) << 4) - 16;
} */
i = 3;
}
M_iHPlay[3] = i;
}
}
//============================//
// Generate a random number //
//============================//
// private static int rand(int iRange) {
// return (m_rRandom.nextInt() & 65535) % iRange;
// }
//=================================//
// Combine variables to a string //
//=================================//
private static String GetRecordString() {
int i;
String sRecord = "";
sRecord = m_iTopScore + "/" +
m_bSoundOn + "/" +
m_bVibrateOn + "/" +
m_iPlayed + "/" +
"";
for (i = sRecord.length(); i < MAX_SAVELENGTH; i++)
{
sRecord += "*";
}
return sRecord;
}
//===============================//
// Extract string to variables //
//===============================//
private void ExtractString(String sRecord) {
int i, iLength, j;
String sResult;
String pData[];
// Initialize variables //
i = 0;
j = 0;
iLength = sRecord.length();
sResult = "";
pData = new String[MAX_SAVEDATA];
// Extract data to pData[] //
while (i < iLength)
{
if (sRecord.charAt(i) != '/')
{
sResult += sRecord.charAt(i);
}
else
{
pData[j] = sResult;
sResult = "";
j++;
}
i++;
}
// Restore values //
// Use
try
{
i = 0;
m_iTopScore = Integer.valueOf(pData[i++]).intValue();
if (pData[i++].equals("true"))
{
m_bSoundOn = true;
}
else
{
m_bSoundOn = false;
}
if (pData[i++].equals("true"))
{
m_bVibrateOn = true;
}
else
{
m_bVibrateOn = false;
}
m_iPlayed = (byte) (Integer.valueOf(pData[i++]).intValue());
}
catch (Exception e)
{}
}
//=========================//
// Change to a new stage //
//=========================//
//================//
// Change stage //
//================//
private void ChangeStage(int iNewStage) {
boolean bAddButton;
if (m_iStage == iNewStage)
{
return;
}
// Remove button //
switch (m_iStage)
{
case STAGE_MENU:
case STAGE_SETTING:
case STAGE_CLEAR:
case STAGE_QUIT:
removeCommand(m_pNext);
removeCommand(m_pBack);
break;
case STAGE_LEVEL:
case STAGE_GAME:
case STAGE_GAMEOVER:
case STAGE_HELP:
case STAGE_RANKL:
case STAGE_RANKW:
case STAGE_CREDIT:
removeCommand(m_pBack);
break;
case STAGE_RANK:
case STAGE_UPLOAD:
Display.getDisplay(m_pParent).setCurrent(this);
break;
}
// Add button //
bAddButton = false;
switch (iNewStage)
{
case STAGE_MENU:
m_pNext = new Command(TEXT_UI[40], Command.OK, 1);
m_pBack = new Command(TEXT_UI[41], Command.CANCEL, 1);
bAddButton = true;
break;
case STAGE_SETTING:
m_pNext = new Command(TEXT_UI[42], Command.OK, 1);
m_pBack = new Command(TEXT_UI[43], Command.CANCEL, 1);
bAddButton = true;
break;
case STAGE_LEVEL:
case STAGE_GAME:
case STAGE_HELP:
case STAGE_RANKL:
case STAGE_RANKW:
case STAGE_CREDIT:
m_pNext = null;
m_pBack = new Command(TEXT_UI[43], Command.CANCEL, 1);
bAddButton = true;
break;
case STAGE_GAMEOVER:
m_pNext = null;
m_pBack = new Command(TEXT_UI[44], Command.CANCEL, 1);
bAddButton = true;
break;
case STAGE_CLEAR:
m_pNext = new Command(TEXT_UI[44], Command.OK, 1);
m_pBack = new Command(TEXT_UI[43], Command.CANCEL, 1);
bAddButton = true;
break;
case STAGE_RANK:
m_iRankNo = GetRank(m_iScore);
m_pRank.UpdateUI(m_sName, m_sPhoneNo, m_iLevel, m_iScore, m_iRankNo);
Display.getDisplay(m_pParent).setCurrent(m_pRank);
break;
case STAGE_UPLOAD:
m_pRank.UpdateUI(m_sName, m_sPhoneNo, m_iLevel, m_iScore, 0);
Display.getDisplay(m_pParent).setCurrent(m_pRank);
break;
case STAGE_QUIT:
m_pNext = new Command(TEXT_UI[45], Command.OK, 1);
m_pBack = new Command(TEXT_UI[46], Command.CANCEL, 1);
bAddButton = true;
break;
}
if (bAddButton == true)
{
if (m_pNext != null)
{
addCommand(m_pNext);
}
if (m_pBack != null)
{
addCommand(m_pBack);
}
setCommandListener(this);
}
m_iStage = iNewStage;
m_bPaint = true;
m_iCounter = 0;
System.gc();
}
//==========================//
// Get free sprite object //
//==========================//
/**
private int[] findmynewtowards(int i)
{
int towards[]={0,0,0,0};
int x,y,k,l=0,m=0,n=0;
x=M_iCPlay[i][1]/m_mapTYPE_W;
y=M_iCPlay[i][2]/m_mapTYPE_H;
for(k=0;k<4;k++)
{
if(k==0)
{
m=x;
n=y-1;
}
else if(k==1)
{
m=x-1;
n=y;
}
else if(k==2)
{
m=x;
n=y+1;
}
else
{
m=x+1;
n=y;
}
if(M_imapno[m][n]==2)
{
l=l+1;
towards[l]=k;
}
}
towards[0]=l;
return towards;
}
/**/
// private int findmove(int i) {
// return 1;
// }
/* private Sprite GetFreeSprite() {
int i;
for (i = 0; i < MAX_SPRITE; i++)
{
if (m_pSprite[i].iType == TYPE_NULL)
{
return m_pSprite[i];
}
}
return null;
} */
//=====================//
// Main game process //
//=====================//
public void run() {
while( m_iStage!= -1)
{
Thread.yield();
lTimeStart = System.currentTimeMillis();
// Frame rate control //
repaint();
serviceRepaints();
WaitFrames(MAX_FRAME_WAIT);
}
m_pEffect.FreeAll();
m_pParent.QuitGame();
}
private final void WaitFrames(long lFrameWait) {
for (; System.currentTimeMillis() - lTimeStart < lFrameWait; Thread.yield())
{
;
}
}
//========================//
// Initialize variables //
//========================//
private void Flow_INIT() {
}
//===================================================//
// Logo screen: Load image from resource to memory //
//===================================================//
private void Flow_LOGO() {
}
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -