📄 maincanvas.java
字号:
break;
case 0: // '\0'
if(pCount < 0)
{
pState = 1;
pX = 56;
wantDir = 3;
mg.setColor(0, 0, 0);
mg.fillRect(39, 67, 34, 6);
}
break;
case 1: // '\001'
if((pX & 0x3) + (pY & 0x3) == 0)
{
int i1 = (pX >> 2) + 31 * (pY >> 2);
if(map[i1 + dPos[wantDir]] < 8)
pDir = wantDir;
else
if(map[i1 + dPos[pDir]] > 7)
pDir = 0;
mg.setColor(0, 0, 0);
if(map[i1] == 1)
{
dots++;
scoreChars[5]++;
map[i1] = 5;
mg.fillRect(pX - 4, pY, 4, 4);
} else
if(map[i1] == 2)
{
dots++;
scoreChars[4]++;
map[i1] = 6;
mg.fillRect(pX - 4, pY, 4, 4);
pCount = 100;
eatCount = 0;
for(int k2 = 0; k2 < 3; k2++)
if(gState[k2] == 2)
{
gState[k2] = 3;
gLook[k2] = 11;
}
} else
if(map[i1] == 4)
{
scoreChars[3] += bonuses[level & 0x3];
map[i1] = 0;
map[i1 - 1] = 0;
map[i1 + 1] = 0;
mg.fillRect(pX - 12, pY - 2, 20, 8);
int l2;
for(l2 = 0; sCount[l2] > 0; l2++);
sLook[l2] = 17 + (level + 3 & 0x3);
sCount[l2] = 20;
sX[l2] = pX;
sY[l2] = pY;
}
i1 += dPos[pDir];
}
pX += 2 * dx[pDir];
pY += 2 * dy[pDir];
if(pX < 0)
pX += 120;
else
if(pX > 119)
pX -= 120;
if(pDir > 0)
pLook = (pDir * 2 - 2) + (counter & 0x1);
if(dots == 244)
{
state = 2;
pCount = 45;
}
break;
}
for(int j1 = 0; j1 < 3; j1++)
switch(gState[j1])
{
default:
break;
case 0: // '\0'
gX[j1] += 4 * gDir[j1] - 14;
if(gX[j1] < 50 || gX[j1] > 66)
{
gX[j1] -= 8 * gDir[j1] - 28;
gDir[j1] = 7 - gDir[j1];
}
gCount[j1]--;
if(gCount[j1] < 0 && gX[j1] == 58)
{
gState[j1] = 1;
gDir[j1] = 1;
}
break;
case 1: // '\001'
gY[j1] += 4 * gDir[j1] - 6;
if(gY[j1] == 44)
{
gState[j1] = 2;
gDir[j1] = 3 + (pDir & 0x1);
gX[j1] += 4 * gDir[j1] - 14;
break;
}
if(gY[j1] == 56)
{
gCount[j1] = 30;
gLook[j1] = 8 + j1;
gDir[j1] = 3 + (counter & 0x1);
gState[j1] = 0;
}
break;
case 2: // '\002'
case 3: // '\003'
case 4: // '\004'
if(gState[j1] == 2)
{
speed = 2;
targetX = pX;
targetY = pY;
randomness = 15;
} else
if(gState[j1] == 3)
{
speed = 1;
targetX = 2 * gX[j1] - pX;
targetY = 2 * gY[j1] - pY;
randomness = 0;
if(pCount < 20)
gLook[j1] = 11 + (counter & 0x1);
else
gLook[j1] = 11;
} else
{
speed = 4;
targetX = 58;
targetY = 44;
}
if((gX[j1] & 0x3) + (gY[j1] & 0x3) == 0)
{
bestVal = 0;
bestDir = 0;
int i3 = (gX[j1] >> 2) + 31 * (gY[j1] >> 2);
if(map[i3 - 31] < 8 && gDir[j1] != 2)
{
bestVal = 50;
bestDir = 1;
if(targetY < gY[j1])
bestVal += (randi() & randomness) + 1;
}
if(map[i3 + 31] < 8 && gDir[j1] != 1)
{
int l3 = 50;
if(targetY > gY[j1])
l3 += (randi() & randomness) + 1;
if(l3 > bestVal)
{
bestDir = 2;
bestVal = l3;
}
}
if(map[i3 - 1] < 8 && gDir[j1] != 4)
{
int i4 = 50;
if(targetX < gX[j1])
i4 += (randi() & randomness) + 1;
if(i4 > bestVal)
{
bestDir = 3;
bestVal = i4;
}
}
if(map[i3 + 1] < 8 && gDir[j1] != 3)
{
int j4 = 50;
if(targetX > gX[j1])
j4 += (randi() & randomness) + 1;
if(j4 > bestVal)
bestDir = 4;
}
gDir[j1] = bestDir;
if(gState[j1] == 3 && pCount < 0)
{
gState[j1] = 2;
gLook[j1] = 8 + j1;
speed = 2;
} else
if(gState[j1] == 4 && gY[j1] == 44 && (gX[j1] == 56 || gX[j1] == 60))
{
gX[j1] = 58;
gState[j1] = 1;
gDir[j1] = 2;
}
}
gX[j1] += speed * dx[gDir[j1]];
gY[j1] += speed * dy[gDir[j1]];
if(gX[j1] < 0)
gX[j1] += 120;
else
if(gX[j1] > 119)
gX[j1] -= 120;
if(gX[j1] >= pX + 8 || gX[j1] <= pX - 8 || gY[j1] >= pY + 8 || gY[j1] <= pY - 8)
break;
if(gState[j1] == 3)
{
gLook[j1] = 13;
gState[j1] = 4;
gX[j1] &= 0xfc;
gY[j1] &= 0xfc;
eatCount++;
scoreChars[3] += bonuses[eatCount];
int j3;
for(j3 = 0; sCount[j3] > 0; j3++);
sLook[j3] = 17 + eatCount;
sCount[j3] = 20;
sX[j3] = pX;
sY[j3] = pY;
break;
}
if(gState[j1] == 2)
{
state = 3;
counter = -1;
}
break;
}
bg.setClip(0, 0, w, h - 9);
if(w < 112)
{
mX = 50 - pX;
if(mX > 0)
mX = 0;
else
if(mX < w - 112)
mX = w - 112;
}
if(h < 133)
{
mY = 51 - pY;
if(mY > 0)
mY = 0;
else
if(mY < h - 133)
mY = h - 133;
}
//MainCanvas _tmp3 = this;
//MainCanvas _tmp4 = this;
bg.drawImage(mazebuf, mX, mY, 0x10 | 0x4);
for(int k1 = 0; k1 < 4; k1++)
if(sCount[k1] > 0)
{
sCount[k1]--;
//MainCanvas _tmp5 = this;
//MainCanvas _tmp6 = this;
bg.drawImage(imgs[sLook[k1]], sX[k1] + mX + offsX[sLook[k1]], sY[k1] + mY + offsY[sLook[k1]], 0x10 | 0x4);
}
//MainCanvas _tmp7 = this;
//MainCanvas _tmp8 = this;
bg.drawImage(imgs[pLook], pX + mX + offsX[pLook], pY + mY + offsY[pLook], 0x10 | 0x4);
for(int l1 = 0; l1 < 3; l1++)
{
//MainCanvas _tmp9 = this;
//MainCanvas _tmp10 = this;
bg.drawImage(imgs[gLook[l1]], gX[l1] + mX + offsX[gLook[l1]], gY[l1] + mY + offsY[gLook[l1]], 0x10 | 0x4);
}
bg.setClip(0, 0, w, h);
for(int i2 = 5; i2 > 0; i2--)
if(scoreChars[i2] > '9')
{
scoreChars[i2] -= '\n';
scoreChars[i2 - 1]++;
}
if((counter & 0x1) == 0)
{
bg.setColor(0, 0, 0);
bg.fillRect(1, h - 9, fW, 9);
bg.setColor(255, 255, 255);
//MainCanvas _tmp11 = this;
//MainCanvas _tmp12 = this;
bg.drawChars(scoreChars, 1, 5, 1, h - fH, 0x10 | 0x4);
}
break;
case 2: // '\002'
pLook = pLook & 0xfe | pCount-- & 0x1;
//MainCanvas _tmp13 = this;
//MainCanvas _tmp14 = this;
bg.drawImage(imgs[pLook], pX + mX + offsX[pLook], pY + mY + offsY[pLook], 0x10 | 0x4);
if(pCount == 0)
{
level++;
scoreChars[2]++;
resetMap();
}
break;
case 3: // '\003'
bg.setClip(0, 0, w, h - 9);
//MainCanvas _tmp15 = this;
//MainCanvas _tmp16 = this;
bg.drawImage(mazebuf, mX, mY, 0x10 | 0x4);
if(counter < 6)
{
pLook = 14 + counter / 2;
//MainCanvas _tmp17 = this;
//MainCanvas _tmp18 = this;
bg.drawImage(imgs[pLook], pX + mX + offsX[pLook], pY + mY + offsY[pLook], 0x10 | 0x4);
}
if(counter <= 30)
break;
lives--;
if(lives < 0)
{
//MainCanvas _tmp19 = this;
//MainCanvas _tmp20 = this;
bg.drawImage(imgs[26], (w - 54) / 2, h / 2 - 5, 0x10 | 0x4);
state = 4;
} else
{
bg.setClip(0, 0, w, h);
bg.setColor(0, 0, 0);
bg.fillRect(fW + 8 + 10 * lives, h - 8, 8, 8);
resetMobiles();
}
break;
case 4: // '\004'
if(counter > 70)
prepareIntro();
break;
case 10: // '\n'
//MainCanvas _tmp21 = this;
//MainCanvas _tmp22 = this;
bg.drawImage(mazebuf, 0, 0, 0x10 | 0x4);
int j2 = counter & 0x3f;
int k3 = counter / 64;
if(k3 < 3)
{
//MainCanvas _tmp23 = this;
//MainCanvas _tmp24 = this;
bg.drawImage(imgs[8 + k3], (j2 + w / 2) - 64, 49 + 11 * k3, 0x10 | 0x4);
if(j2 == 63)
{
//MainCanvas _tmp25 = this;
//MainCanvas _tmp26 = this;
mg.drawImage(imgs[8 + k3], (j2 + w / 2) - 64, 49 + 11 * k3, 0x10 | 0x4);
//MainCanvas _tmp27 = this;
//MainCanvas _tmp28 = this;
mg.drawString(various[2 + k3], w / 2 + 10, 46 + 11 * k3, 0x10 | 0x4);
}
} else
if(j2 == 63)
prepareIntro();
if((counter & 0x20) == 0)
{
//MainCanvas _tmp29 = this;
//MainCanvas _tmp30 = this;
bg.drawImage(imgs[6 + (counter & 0x1)], (w / 2 - 36) + 2 * (counter & 0x1f), h - 17, 0x10 | 0x4);
} else
{
//MainCanvas _tmp31 = this;
//MainCanvas _tmp32 = this;
bg.drawImage(imgs[4 + (counter & 0x1)], (w / 2 + 28) - 2 * (counter & 0x1f), h - 17, 0x10 | 0x4);
}
break;
}
repaint(x0, y0, w, h);
serviceRepaints();
} while(true);
}
public void resume()
{
state = oldState;
if(oldState == 10)
resetGame();
removeCommand(startCommand);
addCommand(pauseCommand);
}
public void pause()
{
oldState = state;
state = 9;
removeCommand(pauseCommand);
addCommand(startCommand);
}
protected void keyPressed(int i1)
{
switch(getGameAction(i1))
{
case 6: // '\006'
wantDir = 2;
break;
case 1: // '\001'
wantDir = 1;
break;
case 2: // '\002'
wantDir = 3;
break;
case 5: // '\005'
wantDir = 4;
break;
}
}
public void paint(Graphics g)
{
if(g.getClipX() < x0 || g.getClipWidth() > w || g.getClipY() < y0 || g.getClipHeight() > h)
{
g.setColor(0);
g.fillRect(0, 0, getWidth(), getHeight());
}
g.drawImage(buf, x0, y0, 0x10 | 0x4);
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -