📄 samkokgame.java
字号:
startLevel = 60;
levelFinish = 0;
for(int x = 0; x < maxMonster; x++)
{
monsterX[x] = monsterTempX[x];
monsterY[x] = monsterTempY[x];
monsterT[x] = monsterTempT[x];
monsterHP[x] = getMonsterHP(monsterT[x]);
if(monsterT[x] <= 8 || monsterT[x] >= 21)
monsterM[x] = -1;
else
monsterM[x] = 1;
monsterF[x] = getMonsterFrame(monsterT[x]);
monsterS[x] = 0;
monsterAddX[x] = 0;
monsterAddY[x] = 0;
}
for(int x = maxMonster; x < maxMonster + 5; x++)
{
monsterTempY[x] = monsterY[x] = 0;
monsterTempT[x] = monsterT[x] = 0;
monsterHP[x] = 0;
monsterM[x] = -1;
monsterF[x] = 0;
}
if(restart)
{
gameMode = 11;
playerLifeOn = 0;
playerAddHP();
} else
{
playerLifeOn = 20;
}
playerX = plx;
playerY = ply;
playerAddX = 0;
playerAddY = 0;
playerTempJump = playerJump = playerFight = playerAtt = false;
playerMode = 1;
playerFrameStep = 0;
saPlayer.effect = 0;
specialCombo = 0;
specialType[0] = 0;
specialType[1] = 0;
specialType[2] = 0;
if(playerType > 0)
specialType[playerType - 1] = -1;
frameStep = 0;
playerNextMode = 0;
bossStageFinish = 0;
startStage = 0;
playerDie = 0;
GenCurMap();
if(mapNumber % 10 == 5)
if(mapNumber == 15)
bossHP = 0;
else
if(bossHP < bossMaxHP >> 1)
bossHP = (short)(bossMaxHP >> 1);
}
private void initLevel(int level)
{
curLevel = level;
startLevel = 60;
levelFinish = 0;
mapCode = null;
monsterX = null;
monsterY = null;
monsterT = null;
monsterTempX = null;
monsterTempY = null;
monsterTempT = null;
monsterHP = null;
monsterM = null;
monsterAddX = null;
monsterAddY = null;
monsterF = null;
monsterS = null;
bossStage = false;
mapNumber = nextMap[curLevel];
if(nextMap[level] == 50)
{
gameMode = 0;
running = false;
clearData();
SeReg.Save("load.dat", "0");
titleGame = new TitleGame(parent, this);
titleGame.setTitleMode(90);
parent.setDisplayable(titleGame);
} else
{
loadMap(nextMap[level]);
getStageName(curLevel + 1);
StringBuffer str = new StringBuffer("");
str.append("1" + playerType + playerLife);
str.append("" + (100 + maxWeaponMode));
str.append("" + (100 + weaponMode));
str.append("" + (10 + curLevel));
SeReg.Save("load.dat", "" + str);
str = null;
gameMode = 11;
saPlayer.effect = 0;
playerAddX = 0;
playerAddY = 0;
playerTempJump = playerJump = playerFight = playerAtt = false;
playerMode = 1;
playerFrameStep = 0;
playerLifeOn = 0;
specialCombo = 0;
frameStep = 0;
playerNextMode = 0;
bossStageFinish = 0;
startStage = 0;
playerDie = 0;
bossLifeOn = 0;
bossHP = 0;
mapNumber = nextMap[level];
if(mapNumber % 10 == 5)
{
bossStage = true;
switch(mapNumber)
{
case 15: // '\017'
playerX = 0;
playerY = 64;
bossHP = 0;
bossType = 0;
break;
case 25: // '\031'
bossMaxHP = bossHP = 150;
bossType = 6;
break;
case 35: // '#'
bossMaxHP = bossHP = 200;
bossType = 5;
break;
case 45: // '-'
bossMaxHP = bossHP = 200;
bossType = 7;
break;
}
} else
{
specialType[0] = 0;
specialType[1] = 0;
specialType[2] = 0;
if(playerType > 0)
specialType[playerType - 1] = -1;
}
playerAddHP();
data = null;
encode = null;
}
}
private void loadMap(int mapNum)
{
mapNumber = mapNum;
encode = new SecondLoadEncodeData();
mapData = encode.LoadToByteArray("/data/m" + mapNum);
encode = null;
if(mapNum % 5 == 0)
mapSizeX = 11;
else
mapSizeX = (short)(mapData[0] << 3);
mapSizeY = (short)(mapData[1] << 3);
maxMonster = mapData[2];
int ptr = 3;
monsterX = new short[maxMonster + 5];
monsterY = new short[maxMonster + 5];
monsterT = new byte[maxMonster + 5];
monsterTempX = new short[maxMonster + 5];
monsterTempY = new short[maxMonster + 5];
monsterTempT = new byte[maxMonster + 5];
monsterHP = new byte[maxMonster + 5];
monsterM = new byte[maxMonster + 5];
monsterAddX = new byte[maxMonster + 5];
monsterAddY = new byte[maxMonster + 5];
monsterF = new byte[maxMonster + 5];
monsterS = new byte[maxMonster + 5];
if(maxMonster > 0)
{
for(int x = 0; x < maxMonster; x++)
{
int tempInt = mapData[ptr];
if(tempInt < 0)
tempInt += 256;
monsterTempX[x] = monsterX[x] = (short)(tempInt << 4);
tempInt = mapData[ptr + 1];
if(tempInt < 0)
tempInt += 256;
tempInt++;
monsterTempY[x] = monsterY[x] = (short)(tempInt << 4);
monsterTempT[x] = monsterT[x] = mapData[ptr + 2];
monsterHP[x] = getMonsterHP(monsterT[x]);
if(monsterTempT[x] <= 8 || monsterTempT[x] >= 21)
monsterM[x] = -1;
else
monsterM[x] = 1;
monsterF[x] = getMonsterFrame(monsterT[x]);
ptr += 3;
}
}
mapCode = new byte[mapSizeY][mapSizeX];
for(int y = 0; y < mapSizeY; y++)
{
for(int x = 0; x < mapSizeX; x++)
mapCode[y][x] = mapData[y * mapSizeX + x + ptr];
}
mapData = null;
for(int x = maxMonster; x < maxMonster + 5; x++)
{
monsterTempY[x] = monsterY[x] = 0;
monsterTempT[x] = monsterT[x] = 0;
monsterHP[x] = 0;
monsterM[x] = -1;
monsterF[x] = 0;
}
for(int x = 0; x < 20; x++)
characterOrder[x] = 0;
playerX = 0;
playerY = 96;
GenCurMap();
}
private void GenCurMap()
{
curMapX = 80 - playerX;
if(curMapX > 0)
curMapX = 0;
else
if(curMapX < -((mapSizeX << 4) - 176))
curMapX = -((mapSizeX << 4) - 176);
sBlockX = Math.abs(curMapX) >> 4;
eBlockX = sBlockX + 12;
if(eBlockX > mapSizeX)
eBlockX = mapSizeX;
}
private byte getMonsterFrame(int type)
{
int value;
if(type == 0)
value = 0;
else
if(type <= 6)
value = type * 2 - 1;
else
if(type <= 8)
value = 1;
else
if(type <= 20)
value = type - 7;
else
if(type <= 22)
value = type - 19;
else
if(type <= 26)
value = type - 21;
else
if(type <= 28)
value = type - 23;
else
if(type == 29)
value = 0;
else
if(type == 30 || type == 32)
value = 2;
else
if(type == 31)
value = 1;
else
if(type == 50)
value = 9;
else
value = 0;
return (byte)value;
}
private byte getMonsterHP(int type)
{
int value;
switch(type)
{
case 1: // '\001'
value = 2;
break;
case 2: // '\002'
value = 3;
break;
case 3: // '\003'
value = 5;
break;
case 4: // '\004'
value = 8;
break;
case 5: // '\005'
value = 10;
break;
case 6: // '\006'
value = 7;
break;
case 7: // '\007'
value = 10;
break;
case 8: // '\b'
value = 14;
break;
case 25: // '\031'
case 26: // '\032'
case 27: // '\033'
case 28: // '\034'
case 30: // '\036'
case 32: // ' '
value = 1;
break;
case 50: // '2'
value = 100;
break;
case 9: // '\t'
case 10: // '\n'
case 11: // '\013'
case 12: // '\f'
case 13: // '\r'
case 14: // '\016'
case 15: // '\017'
case 16: // '\020'
case 17: // '\021'
case 18: // '\022'
case 19: // '\023'
case 20: // '\024'
case 21: // '\025'
case 22: // '\026'
case 23: // '\027'
case 24: // '\030'
case 29: // '\035'
case 31: // '\037'
case 33: // '!'
case 34: // '"'
case 35: // '#'
case 36: // '$'
case 37: // '%'
case 38: // '&'
case 39: // '\''
case 40: // '('
case 41: // ')'
case 42: // '*'
case 43: // '+'
case 44: // ','
case 45: // '-'
case 46: // '.'
case 47: // '/'
case 48: // '0'
case 49: // '1'
default:
value = 0;
break;
}
return (byte)value;
}
private boolean chon(int x1, int y1, int w1, int h1, int x2, int y2, int w2,
int h2)
{
return x1 < x2 + w2 && x1 + w1 > x2 && y1 < y2 + h2 && y1 + h1 > y2;
}
private int checkFloor(int x, int y, int start, int addY)
{
int end = 24 - start;
if(y >= 128 || y < 0)
return -1;
if(x < 0)
return -2;
if(x + end >= mapSizeX << 4)
return 2;
int x1 = x + start >> 4;
int x2 = x + end >> 4;
int y1 = y >> 4;
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -