📄 gamescreen.java~6~
字号:
goalKeepers[0].draw(bg);
goalKeepers[1].draw(bg);
ball.draw(bg);
bg.drawImage(top, 0, 0, 0);
bg.clipRect(40, 5, MenuScreen.formWidth, MenuScreen.form.getHeight());
bg.drawImage(MenuScreen.form, 40 - MenuScreen.formWidth * userCommand, 5, 0);
bg.setClip(0, 0, getWidth(), getHeight());
bg.clipRect(110, 5, MenuScreen.formWidth, MenuScreen.form.getHeight());
bg.drawImage(MenuScreen.form, 110 - MenuScreen.formWidth * compCommandColor, 5, 0);
bg.setClip(0, 0, getWidth(), getHeight());
drawScore(bg);
bg.drawImage(bottom, 0, gHeight - bottom.getHeight(), 0);
if(mode == 5)
drawMessage(bg, 9);
if(messageTime > 0)
drawMessage(bg, messageType);
if(mode == 2)
drawMessage(bg, 10);
else
if(mode == 7)
bg.drawImage(confirm, 0, gHeight - confirm.getHeight(), 0);
g.drawImage(b, 0, 0, 0);
}
}
public void drawScore(Graphics g)
{
g.setColor(0xffffff);
g.setFont(fbold);
g.drawString(Integer.toString(scoreUser), 73, 8, g.TOP | g.LEFT);
g.drawString(Integer.toString(scoreComp), 95, 8, g.TOP | g.LEFT);
int i = timeToEnd / 600;
int j = (timeToEnd / 10) % 60;
String s = Integer.toString(i) + ":" + (j >= 10 ? "" : "0") + Integer.toString(j);
g.drawString(s, gWidth - fbold.stringWidth(s) - 2, 1, g.TOP | g.LEFT);
if(additionTime)
if(timeToEnd < extraTime / 2)
g.drawString("2et", 0, 1, g.TOP | g.LEFT);
else
g.drawString("1et", 0, 1, g.TOP | g.LEFT);
g.setFont(f);
g.setColor(0x80ff80);
g.drawString(MenuScreen.commands[userCommand], 0, 12, g.TOP | g.LEFT);
g.setColor(0xffffff);
g.drawString(MenuScreen.commands[compCommand], gWidth - f.stringWidth(MenuScreen.commands[compCommand]), 12, g.TOP | g.LEFT);
}
public void fault()
{
mode = 14;
if(goalKeepers[faultTeam].distance(ball) < goalKeepers[1 - faultTeam].distance(ball) && 74 <= ((Sprite) (ball)).x && ((Sprite) (ball)).x <= 276 && (((Sprite) (ball)).y <= 90 || ((Sprite) (ball)).y >= 460))
{
messageType = 17;
messageTime = 3000;
} else
{
messageType = 18;
messageTime = 3000;
}
}
public void penaltyKick()
{
int i = 175;
int j = 90 - playerHeight;
byte byte0 = 20;
int k = 0;
if(((Sprite) (goalKeepers[faultTeam])).y > 275)
{
j = 460;
byte0 = -20;
k = 4;
}
int l = -1;
faultKicker = -1;
for(int i1 = 0; i1 < 14; i1++)
{
if(((Sprite) (all[i1])).type == 1 - faultTeam && (faultKicker == -1 || l > all[i1].distance(i, j)))
{
faultKicker = i1;
l = all[i1].distance(i, j);
}
for(; ((Sprite) (all[i1])).x + playerWidth >= 74 && ((Sprite) (all[i1])).x <= 276 && (((Sprite) (all[i1])).y <= 90 || ((Sprite) (all[i1])).y + playerHeight >= 460); all[i1].y += byte0);
all[i1].hasBall = false;
all[i1].active = false;
}
goalKeepers[faultTeam].x = i;
all[faultKicker].setPos(i, j);
all[faultKicker].direction = k;
all[faultKicker].setBallOwn();
all[faultKicker].correctBallPosition();
mode = 15;
}
public void doPenaltyKick()
{
all[faultKicker].hasBall = false;
ball.kickBall(((Sprite) (all[faultKicker])).direction, 0, 3 + rnd(5));
ball.ballMove();
mode = 1;
}
public void doFreeKick()
{
all[faultKicker].hasBall = false;
ball.kickBall(((Sprite) (all[faultKicker])).direction);
ball.ballMove();
mode = 1;
}
public void freeKick()
{
int i = -1;
faultKicker = -1;
boolean aflag[] = new boolean[14];
for(int k = 0; k < 14; k++)
{
if(((Sprite) (all[k])).type == 1 - faultTeam && (faultKicker == -1 || i > all[k].distance(((Sprite) (ball)).x, ((Sprite) (ball)).y)))
{
faultKicker = k;
i = all[k].distance(((Sprite) (ball)).x, ((Sprite) (ball)).y);
}
aflag[k] = false;
all[k].hasBall = false;
all[k].active = false;
}
int l = 0;
int ai[][] = new int[3][2];
if(((Sprite) (ball)).y >= 90 && ((Sprite) (ball)).y + ((Sprite) (ball)).sH <= 460)
{
int i1;
byte byte1;
if(((Sprite) (goalKeepers[faultTeam])).y < ((Sprite) (ball)).y)
{
l = 0;
byte1 = -50;
i1 = (byte1 * (((Sprite) (goalKeepers[faultTeam])).x - ((Sprite) (ball)).x)) / (((Sprite) (goalKeepers[faultTeam])).y - ((Sprite) (ball)).y);
} else
{
l = 4;
byte1 = 50;
i1 = (byte1 * (((Sprite) (goalKeepers[faultTeam])).x - ((Sprite) (ball)).x)) / (((Sprite) (goalKeepers[faultTeam])).y - ((Sprite) (ball)).y);
}
ai[0][0] = i1 - 15;
ai[0][1] = byte1;
ai[1][0] = i1;
ai[1][1] = byte1;
ai[2][0] = i1 + 15;
ai[2][1] = byte1;
} else
{
byte byte0;
int j1;
if(((Sprite) (goalKeepers[faultTeam])).x < ((Sprite) (ball)).x)
{
l = 6;
j1 = 0;
byte0 = -50;
} else
{
l = 2;
j1 = 0;
byte0 = 50;
}
ai[0][0] = byte0;
ai[0][1] = j1 - 15;
ai[1][0] = byte0;
ai[1][1] = j1;
ai[2][0] = byte0;
ai[2][1] = j1 + 15;
}
all[faultKicker].setPos(((Sprite) (ball)).x, ((Sprite) (ball)).y);
all[faultKicker].direction = l;
all[faultKicker].setBallOwn();
all[faultKicker].correctBallPosition();
if((fieldY <= 90 || fieldY + screenHeight >= 460) && goalKeepers[faultTeam].distance(ball) < goalKeepers[1 - faultTeam].distance(ball))
{
for(int k1 = 0; k1 < 3; k1++)
if(((Sprite) (ball)).x + ai[k1][0] >= 10 && ((Sprite) (ball)).x + ai[k1][0] + playerWidth <= 340 && ((Sprite) (ball)).y + ai[k1][1] >= 30 && ((Sprite) (ball)).y + ai[k1][1] + playerHeight <= 520)
{
int j = -1;
int l1 = -1;
for(int i2 = 0; i2 < 14; i2++)
if(((Sprite) (all[i2])).type == faultTeam && !aflag[i2] && (l1 == -1 || all[i2].distance(ball) < j))
{
l1 = i2;
j = all[i2].distance(ball);
}
aflag[l1] = true;
all[l1].setPos(((Sprite) (ball)).x + ai[k1][0], ((Sprite) (ball)).y + ai[k1][1]);
all[l1].direction = l;
}
}
mode = 16;
}
public void ballOutside()
{
if(((Sprite) (ball)).y > 30 && ((Sprite) (ball)).y + ((Sprite) (ball)).sH / 2 < 520)
{
nearestPlayer = -1;
for(int i = 0; i < 14; i++)
{
all[i].hasBall = false;
all[i].active = false;
all[i].targetReached = true;
if(((Sprite) (all[i])).type == 1 - ball.lastBallOwner && (nearestPlayer == -1 || all[nearestPlayer].distance(ball) > all[i].distance(ball)))
nearestPlayer = i;
}
all[nearestPlayer].setTarget(((Sprite) (ball)).x, ((Sprite) (ball)).y, nearestPlayerDirection);
int ai[] = new int[2];
ai[0] = 0;
ai[1] = 1;
for(int k = 0; k < 14; k++)
if(k != nearestPlayer)
{
for(; ai[((Sprite) (all[k])).type] < nearBallPositions.length; ai[((Sprite) (all[k])).type]++)
{
int l = ((Sprite) (ball)).x + ((Sprite) (ball)).sW / 2;
int i1 = ((Sprite) (ball)).y + ((Sprite) (ball)).sH / 2;
if(((Sprite) (all[k])).type == 1 - ball.lastBallOwner)
{
l += (nearBallPositions[ai[((Sprite) (all[k])).type]][0] * 3) / 5;
i1 += (nearBallPositions[ai[((Sprite) (all[k])).type]][1] * 3) / 5;
} else
{
l += (nearBallPositions[ai[((Sprite) (all[k])).type]][0] * 4) / 5;
i1 += (nearBallPositions[ai[((Sprite) (all[k])).type]][1] * 4) / 5;
}
if(10 > l + playerWidth / 2 || l - playerWidth / 2 > 340 || 30 > i1 + playerHeight / 2 || i1 - playerHeight / 2 > 520)
continue;
all[k].setTarget(l, i1, ((Sprite) (all[k])).direction);
ai[((Sprite) (all[k])).type]++;
break;
}
if(((Sprite) (all[k])).targetReached)
all[k].setPos(10 + rnd(330), 40 + rnd(470));
}
messageType = 14;
messageTime = 3000;
mode = 8;
} else
{
for(int j = 0; j < 16; j++)
{
all[j].hasBall = false;
all[j].active = false;
}
if(ball.distance(goalKeepers[ball.lastBallOwner]) > ball.distance(goalKeepers[1 - ball.lastBallOwner]))
messageType = 12;
else
messageType = 13;
messageTime = 3000;
mode = 11;
}
}
public void kickOutBall()
{
all[nearestPlayer].hasBall = false;
if(nearestPlayerDirection % 2 == 1)
ball.kickBall(nearestPlayerDirection);
else
if(nearestPlayerDirection == 0)
{
int i = rnd(3);
if(i == 2)
ball.kickBall(7);
else
ball.kickBall(i);
} else
{
ball.kickBall((nearestPlayerDirection - 1) + rnd(3));
}
ball.ballMove();
mode = 1;
}
public void goalKick()
{
int i = 0;
if(goalKeepers[1].distance(ball) < goalKeepers[0].distance(ball))
i = 1;
goalKeepers[i].setBallOwn();
if(((Sprite) (goalKeepers[i])).y < 275)
goalKeepers[i].direction = 4;
else
goalKeepers[i].direction = 0;
goalKeepers[i].correctBallPosition();
}
public void cornerKick()
{
int i = -1;
char c = '\r';
char c1 = '!';
int j = 3;
if(ball.distance(340, 30) < ball.distance(c, c1))
{
c = '\u0151';
c1 = '!';
j = 5;
}
if(ball.distance(340, 520) < ball.distance(c, c1))
{
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -