Skip to Main Content

Java SE (Java Platform, Standard Edition)

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

Interested in getting your voice heard by members of the Developer Marketing team at Oracle? Check out this post for AppDev or this post for AI focus group information.

Coding Help

843802Feb 27 2007
I am trying to get the code for the game: Slime Soccer (http://www.wrixton.net/projects/games/soccer.php)

At the bottom it shows there is a downloadable version and I downloaded it but the game didn't work because of a JNLP error. The folder also included a document that had the source code but I didn't understand how that worked. I wanted to use the source code and put it in my myspace but it didn't work.

Can someone please send me the code so I can use it for my myspace? Here is the source code it provided:

//<!-- 2-player version of Slime Volleyball -->
// Original code: Quin Pendragon, 1999.
// I know that this isn't exactly an ideal example of either game coding or
// good use of java. It wasn't meant to be. :P
// No responsibility is taken for any damage to software, hardware,
// keyboards, or individuals' coding habits as a result of using this code.
// Mods:
// 0) fractoid: Lost the source code, and decompiled the applet on my page
// to get it back. This is why some of the methods are in a funny
// order, and some variables are interestingly named :P
// 1) fractoid: added SuperSlime mod.
// 2) fractoid: turned it into SoccerSlime :)
// 3) fractoid: turned it into WorldCupSoccerSlime :)
// 4) fractoid: added Iceland and Night Elves, and sped up the final AI a smidgen
// 5) fractoid: Pause key pauses game
// ...

import java.applet.Applet;
import java.awt.*;

public class WorldCupSoccerSlime extends Applet
implements Runnable
{
private int nWidth;
private int nHeight;
private int p1Score;
private int p2Score;
private int p1X;
private int p2X;
private int p1Y;
private int p2Y;
private int p1Col;
private int p2Col;
private String slimeColText[] = {
"Argentina", "Belgium", "Australia", "Iceland", "Cameroon", "P.R. of China", "Costa Rica",
"Croatia", "Denmark", "Eucador", "Mexico", "France", "USA",
"Italy", "Japan", "Russia", "Paraguay", "Poland",
"Portugal", "Ireland", "Saudi Arabia", "Senegal", "Slovenia",
"Spain", "Seth Efrica", "South Corea", "Sveden", "Tunisia", "Turkey",
"Uruguay", "Brazil", "England", "Germany", "Night Elves"
};
private Color darkRed = new Color(128, 0, 0), darkGreen = new Color(0, 128, 0), darkBlue = new Color(0, 0, 128);
private Color[] slimaryCols = {
Color.cyan, Color.red, Color.green, Color.white, darkGreen, Color.white, darkRed,
darkRed, new Color(119, 41, 28), Color.yellow, Color.green, Color.white, Color.white,
new Color(128, 128, 255), darkBlue, Color.white, Color.red, Color.white,
new Color(119, 41, 28), Color.green, Color.white, Color.white, Color.white,
new Color(185, 30, 2), Color.white, Color.red, new Color(252, 239, 82), Color.white, Color.red,
new Color(16, 180, 180), new Color(241, 245, 71), new Color(230, 230, 230), Color.white, Color.blue,
};
private Color[] secondaryCols = {
Color.white, Color.black, Color.yellow, new Color(128, 128, 255), Color.red, Color.red, darkBlue,
Color.white, Color.white, darkBlue, Color.green, Color.blue, darkBlue,
Color.white, Color.white, Color.blue, Color.white, Color.red,
darkGreen, Color.white, new Color(128, 255, 128), new Color(255, 128, 0), darkGreen,
darkBlue, new Color(13, 131, 10), Color.white, Color.blue, Color.red, Color.white,
Color.black, new Color(7, 177, 33), Color.red, Color.black, Color.blue,
};
private int p1OldX;
private int p2OldX;
private int p1OldY;
private int p2OldY;
private int p1XV;
private int p2XV;
private int p1YV;
private int p2YV;
private int ballX;
private int ballY;
private int ballVX;
private int ballVY;
private int ballOldX;
private int ballOldY;
private Graphics screen;
private String promptMsg;
private int replayData[][];
private int replayPos;
private int replayStart;
private boolean mousePressed;
private boolean fCanChangeCol;
private boolean fInPlay;
private int p1Blink;
private int p2Blink;
private boolean fP1Sticky;
private boolean fP2Sticky;
private boolean fP1Touched;
private boolean fP2Touched;
private int p1TouchingGoal;
private int p2TouchingGoal;
private Thread gameThread;
private boolean fEndGame;
private boolean fPlayOn;
private int nScoreX;
private long startTime;
private long gameTime;
private int scoringRun;
private int frenzyCol = 0;
private int playOnTicks;
private Image backBuffer;
private final int SMILE_DIFF = 2;
private final int DAMPING = 7;
private final int MAX_TICKS_TOUCHING_GOAL = 60;
private int JUMPVEL;
private int SLIMEVEL;
private int GRAVITY;
private int gameLength;

private boolean worldCup = false;
private int worldCupRound = 0;
private boolean fExtraTime;
private boolean fGoldenGoal;

private boolean fSuperSlime;

private boolean doubleBuffered;

private boolean gamePaused;

public void initStuff()
{
fEndGame = true;
p1X = 200;
p1Y = 0;
p2X = 800;
p2Y = 0;
p1XV = 0;
p1YV = 0;
p2XV = 0;
p2YV = 0;
p1Score = 0;
p2Score = 0;
ballOldX = ballX = 500;
ballOldY = ballY = 200;
ballVX = 0;
ballVY = 0;
replayStart = replayPos = 0;
fP1Touched = fP2Touched = false;
playOnTicks = 10;
fPlayOn = false;
fExtraTime = false;
fGoldenGoal = false;
JUMPVEL = (fSuperSlime) ? 65 : 31;
SLIMEVEL = (fSuperSlime) ? 16 : 8;
GRAVITY = (fSuperSlime) ? 8 : 2;

gamePaused = false;
}

private void drawButtons()
{
String[] buttons = {"1 minute", "2 minutes", "4 minutes", "8 minutes", "World Cup" };
FontMetrics fm = screen.getFontMetrics();
Color darkBlue = new Color(0, 0, 128);
for (int i=0; i<5; i++)
{
screen.setColor(darkBlue);
screen.fillRect(((2*i+1)*nWidth/10)-nWidth/12,
nHeight*2/10, nWidth/6, nHeight/10);
screen.setColor(Color.white);
screen.drawString(buttons,
((2*i+1)*nWidth/10)-fm.stringWidth(buttons[i]) / 2,
nHeight*5/20+fm.getHeight()/2);
}
flip();
}

private boolean testButton(int x, int y)
{
for (int i=0; i<5; i++)
{
if ((x > ((2*i+1)*nWidth/10)-nWidth/12)
&& (x < ((2*i+1)*nWidth/10)+nWidth/12)
&& (y > (nHeight*2/10)) && (y < nHeight*3/10))
{
if (i == 4) //world cup mode
{
gameLength = 120000;
worldCup = true;
}
else
{
gameLength = (1<<i)*60000;
worldCup = false;
}
return true;
}
}
return false;
}

public boolean handleEvent(Event event)
{
switch(event.id)
{
default:
break;

case 503: // Event.MOUSE_MOVE
showStatus("Slime Volleyball 2-Player: Soccer Slime, by Quin Pendragon: tartarus.uwa.edu.au/~fractoid");
requestFocus();
break;

case 501: // Event.MOUSE_DOWN
mousePressed = true;
if(!fInPlay && testButton(event.x, event.y))
{
fEndGame = false;
fInPlay = true;
p1X = 200;
p1Y = 0;
p2X = 800;
p2Y = 0;
p1XV = 0;
p1YV = 0;
p2XV = 0;
p2YV = 0;
ballX = 500;
ballY = 200;
ballOldX = 500;
ballOldY = 200;
ballVX = 0;
ballVY = 0;
p1Score = 0;
p2Score = 0;
promptMsg = "";
paint(getGraphics());
try { Thread.sleep(100); } catch (Exception e) { }
gameThread = new Thread(this);
gameThread.start();
}
break;

case Event.KEY_ACTION:
case 401: // Event.KEY_PRESS
if (fCanChangeCol)
switch(event.key)
{
case 83: // 'S'
case 115: // 's'
do
p1Col = p1Col != slimaryCols.length-1 ? p1Col + 1 : 0;
while(p1Col == p2Col);
drawScores();
repaint();
break;

case 'W':
case 'w':
do
p1Col = p1Col == 0 ? slimaryCols.length-1 : p1Col-1;
while (p1Col == p2Col);
drawScores();
repaint();
break;

case Event.DOWN:
case 75: // 'K'
case 107: // 'k'
do
p2Col = p2Col != slimaryCols.length-1 ? p2Col + 1 : 0;
while(p2Col == p1Col);
drawScores();
repaint();
break;

case 'i':
case 'I':
case Event.UP:
do
p2Col = p2Col == 0 ? slimaryCols.length-1 : p2Col-1;
while (p1Col == p2Col);
drawScores();
repaint();
break;

case '6':
fSuperSlime = !fSuperSlime;
repaint();
}
if(fEndGame)
break;
switch(event.key)
{
default:
break;

case Event.PAUSE:
gamePaused = !gamePaused;
break;

case 's':
case 'S':
fP1Sticky = true;
break;

case 'k':
case 'K':
case Event.DOWN:
if (!worldCup)
fP2Sticky = true;
break;

case 65: // 'A'
case 97: // 'a'
p1XV = -SLIMEVEL;
break;

case 68: // 'D'
case 100: // 'd'
p1XV = SLIMEVEL;
break;

case 87: // 'W'
case 119: // 'w'
if(p1Y == 0)
p1YV = JUMPVEL;
break;

case Event.LEFT:
case 74: // 'J'
case 106: // 'j'
if (!worldCup)
p2XV = -SLIMEVEL;
break;

case Event.RIGHT:
case 76: // 'L'
case 108: // 'l'
if (!worldCup)
p2XV = SLIMEVEL;
break;

case Event.UP:
case 73: // 'I'
case 105: // 'i'
if(p2Y == 0)
if (!worldCup)
p2YV = JUMPVEL;
break;

case 'b':
case 'B':
toggleBuffering();
break;

case 32: // ' '
mousePressed = true;
break;
}
break;

case Event.KEY_ACTION_RELEASE:
case 402: // Event.KEY_RELEASE
switch(event.key)
{
case 's':
case 'S':
fP1Sticky = false;
break;

case 'k':
case 'K':
case Event.DOWN:
fP2Sticky = false;
break;

case 65: // 'A'
case 97: // 'a'
if(p1XV < 0)
p1XV = 0;
break;

case 68: // 'D'
case 100: // 'd'
if(p1XV > 0)
p1XV = 0;
break;

case Event.LEFT:
case 74: // 'J'
case 106: // 'j'
if(p2XV < 0)
if (!worldCup)
p2XV = 0;
break;

case Event.RIGHT:
case 76: // 'L'
case 108: // 'l'
if(p2XV > 0)
if (!worldCup)
p2XV = 0;
break;
}
}
return false;
}

private int[] pointsX = new int[4], pointsY = new int[4];
private void DrawSlimers()
{
int k1 = nWidth / 10;
int j2 = nHeight / 10;
int i3 = nWidth / 50;
int j3 = nHeight / 25;
int k3 = (ballX * nWidth) / 1000;
int l3 = (4 * nHeight) / 5 - (ballY * nHeight) / 1000;
int i = (p1OldX * nWidth) / 1000 - k1 / 2;
int l = (7 * nHeight) / 10 - (p1OldY * nHeight) / 1000;
screen.setColor(Color.blue);
screen.fillRect(i, l, k1, j2);
i = (p2OldX * nWidth) / 1000 - k1 / 2;
l = (7 * nHeight) / 10 - (p2OldY * nHeight) / 1000;
screen.setColor(Color.blue);
screen.fillRect(i, l, k1, j2);
if (!fEndGame) MoveBall();
i = (p1X * nWidth) / 1000 - k1 / 2;
l = (7 * nHeight) / 10 - (p1Y * nHeight) / 1000;
screen.setColor(fSuperSlime ? slimaryCols[frenzyCol = ((frenzyCol + 1) % slimaryCols.length)] : slimaryCols[p1Col]);
screen.fillArc(i, l, k1, 2 * j2, 0, 180);
screen.setColor(secondaryCols[p1Col]);
pointsX[0] = pointsX[2] = i+k1/2; pointsX[1] = i + k1 * 2 / 5; pointsX[3] = i + k1 / 8;
pointsY[0] = l; pointsY[1] = pointsY[3] = l + j2/2; pointsY[2] = l + j2;
screen.fillPolygon(pointsX, pointsY, 4);
int l4 = p1X + 38;
int i5 = p1Y - 60;
i = (l4 * nWidth) / 1000;
l = (7 * nHeight) / 10 - (i5 * nHeight) / 1000;
int i4 = i - k3;
int j4 = l - l3;
int k4 = (int)Math.sqrt(i4 * i4 + j4 * j4);
boolean flag = Math.random() < 0.01D;
if(flag)
p1Blink = 5;
if(p1Blink == 0)
{
screen.setColor(Color.white);
screen.fillOval(i - i3, l - j3, i3, j3);
if(k4 > 0 && !flag)
{
screen.setColor(Color.black);
screen.fillOval(i - (4 * i4) / k4 - (3 * i3) / 4, l - (4 * j4) / k4 - (3 * j3) / 4, i3 / 2, j3 / 2);
}
} else
{
p1Blink--;
}
if(p1Score > p2Score + SMILE_DIFF)
{
int j = (p1X * nWidth) / 1000;
int i1 = (7 * nHeight) / 10 - ((p1Y - 40) * nHeight) / 1000;
int l1 = nWidth / 20;
int k2 = nHeight / 20;
int j5 = 0;
do
{
screen.setColor(Color.black);
screen.drawArc(j, i1 + j5, l1, k2, -30, -150);
} while(++j5 < 3);
}
i = (p2X * nWidth) / 1000 - k1 / 2;
l = (7 * nHeight) / 10 - (p2Y * nHeight) / 1000;
screen.setColor(fSuperSlime ? slimaryCols[frenzyCol = ((frenzyCol + 1) % slimaryCols.length)] : slimaryCols[p2Col]);
screen.fillArc(i, l, k1, 2 * j2, 0, 180);
screen.setColor(secondaryCols[p2Col]);
pointsX[0] = pointsX[2] = i+k1/2; pointsX[1] = i+k1*3/5; pointsX[3] = i+k1*7/8;
pointsY[0] = l; pointsY[1] = pointsY[3] = l+j2/2; pointsY[2] = l+j2;
screen.fillPolygon(pointsX, pointsY, 4);
l4 = p2X - 18;
i5 = p2Y - 60;
i = (l4 * nWidth) / 1000;
l = (7 * nHeight) / 10 - (i5 * nHeight) / 1000;
i4 = i - k3;
j4 = l - l3;
k4 = (int)Math.sqrt(i4 * i4 + j4 * j4);
flag = Math.random() < 0.01D;
if(flag)
p2Blink = 5;
if(p2Blink == 0)
{
screen.setColor(flag ? Color.gray : Color.white);
screen.fillOval(i - i3, l - j3, i3, j3);
if(k4 > 0 && !flag)
{
screen.setColor(Color.black);
screen.fillOval(i - (4 * i4) / k4 - (3 * i3) / 4, l - (4 * j4) / k4 - (3 * j3) / 4, i3 / 2, j3 / 2);
}
} else
{
p2Blink--;
}
if(p2Score > p1Score + SMILE_DIFF)
{
int i2 = nWidth / 20;
int l2 = nHeight / 20;
int k = (p2X * nWidth) / 1000 - i2;
int j1 = (7 * nHeight) / 10 - ((p2Y - 40) * nHeight) / 1000;
int k5 = 0;
do
{
screen.setColor(Color.black);
screen.drawArc(k, j1 + k5, i2, l2, -10, -150);
} while(++k5 < 3);
}
}

public void paint(Graphics g)
{
nWidth = size().width;
nHeight = size().height;
screen.setColor(Color.blue);
screen.fillRect(0, 0, nWidth, (4 * nHeight) / 5);
screen.setColor(Color.gray);
screen.fillRect(0, (4 * nHeight) / 5, nWidth, nHeight / 5);
screen.setColor(Color.white);
// g.fillRect(nWidth / 2 - 2, (7 * nHeight) / 10, 4, nHeight / 10 + 5);
drawScores();
if (!fInPlay)
{
DrawSlimers();
drawButtons();
}
DrawGoals();
drawPrompt();
if(!fInPlay)
{
FontMetrics fontmetrics = screen.getFontMetrics();
screen.setColor(Color.white);
if (fSuperSlime)
screen.drawString("Super Soccer Slime!", nWidth / 2 - fontmetrics.stringWidth("Super Soccer Slime!") / 2, nHeight / 2 - fontmetrics.getHeight());
else
screen.drawString("Soccer Slime!", nWidth / 2 - fontmetrics.stringWidth("Soccer Slime!") / 2, nHeight / 2 - fontmetrics.getHeight());
screen.setColor(Color.white);
fontmetrics = screen.getFontMetrics();
screen.drawString("Written by Quin Pendragon", nWidth / 2 - fontmetrics.stringWidth("Written by Quin Pendragon") / 2, nHeight / 2 + fontmetrics.getHeight() * 2);
}
flip();
}

public void destroy()
{
gameThread.stop();
gameThread = null;
}

private void ReplayFrame(int i, int j, int k, int l, int i1, boolean flag)
{
if(flag)
{
ballX = -1000; ballOldX = 500;
ballY = -1000; ballOldY = 500;
p1OldX = p1OldY = p2OldX = p2OldY = -10000;
} else
{
int j1 = i != 0 ? i - 1 : 199;
p1OldX = replayData[j1][0];
p1OldY = replayData[j1][1];
p2OldX = replayData[j1][2];
p2OldY = replayData[j1][3];
if (i == 0)
{
ballOldX = 500;
ballOldY = 200;
}
else
{
ballOldX = replayData[j1][4];
ballOldY = replayData[j1][5];
}
}
p1X = replayData[i][0];
p1Y = replayData[i][1];
p2X = replayData[i][2];
p2Y = replayData[i][3];
ballX = replayData[i][4];
ballY = replayData[i][5];
p1Col = replayData[i][6];
p2Col = replayData[i][7];
ballVX = 0;
ballVY = 1;
if((i / 10) % 2 > 0)
{
screen.setColor(Color.red);
screen.drawString("Replay...", j, k);
} else
{
screen.setColor(Color.blue);
screen.fillRect(j, k - i1, l, i1 * 2);
}
DrawSlimers();
DrawGoals();
try
{
Thread.sleep(20L);
return;
}
catch(InterruptedException _ex)
{
return;
}
}

private String MakeTime(long l)
{
long l1 = (l / 10L) % 100L;
long l2 = (l / 1000L) % 60L;
long l3 = (l / 60000L) % 60L;
String s = "";
if(l3 < 10L)
s += "0";
s += l3;
s += ":";
if(l2 < 10L)
s += "0";
s += l2;
s += ":";
if(l1 < 10L)
s += "0";
s += l1;
return s;
}

private void MoveSlimers()
{
if (worldCup) //get the AI to move p2
{
switch (worldCupRound)
{
case 0: controlP2v0(); break;
case 1: controlP2v1(); break;
case 2: controlP2v2(); break;
case 3: controlP2v3(); break;
}
}
p1X += p1XV;
if(p1X < 50)
p1X = 50;
if(p1X > 950)
p1X = 950;
if(p1YV != 0)
{
p1Y += p1YV -= GRAVITY;
if(p1Y < 0)
{
p1Y = 0;
p1YV = 0;
}
}
p2X += p2XV;
if(p2X > 950)
p2X = 950;
if(p2X < 50)
p2X = 50;
if(p2YV != 0)
{
p2Y += p2YV -= GRAVITY;
if(p2Y < 0)
{
p2Y = 0;
p2YV = 0;
}
}
}

public WorldCupSoccerSlime()
{
p2Col = 1;
replayData = new int[200][8];
}

private void MoveBall()
{
int k = (30 * nHeight) / 1000;
int i = (ballOldX * nWidth) / 1000;
int j = (4 * nHeight) / 5 - (ballOldY * nHeight) / 1000;
screen.setColor(Color.blue);
screen.fillOval(i - k, j - k, k * 2, k * 2);
ballY += --ballVY;
ballX += ballVX;
if(!fEndGame)
{
int l1 = (ballX - p1X) * 2;
int i2 = ballY - p1Y;
int j2 = l1 * l1 + i2 * i2;
int k2 = ballVX - p1XV;
int l2 = ballVY - p1YV;
if(i2 > 0 && j2 < 15625 && j2 > 25)
{
int l = (int)Math.sqrt(j2);
int j1 = (l1 * k2 + i2 * l2) / l;
ballX = p1X + (l1 * 63) / l;
ballY = p1Y + (i2 * 125) / l;
if(j1 <= 0)
{
if (!fP1Sticky)
{
ballVY += p1YV - (2 * i2 * j1) / l;
ballVX += (p1XV - (2 * l1 * j1) / l) * DAMPING / 10;
}
else
{
ballVX = 0;
ballVY = 0;
}
if(ballVX < -15)
ballVX = -15;
if(ballVX > 15)
ballVX = 15;
if(ballVY < -22)
ballVY = -22;
if(ballVY > 22)
ballVY = 22;
}
fP1Touched = true;
}
l1 = (ballX - p2X) * 2;
i2 = ballY - p2Y;
j2 = l1 * l1 + i2 * i2;
k2 = ballVX - p2XV;
l2 = ballVY - p2YV;
if(i2 > 0 && j2 < 15625 && j2 > 25)
{
int i1 = (int)Math.sqrt(j2);
int k1 = (l1 * k2 + i2 * l2) / i1;
ballX = p2X + (l1 * 63) / i1;
ballY = p2Y + (i2 * 125) / i1;
if(k1 <= 0)
{
if (!fP2Sticky)
{
ballVX += (p2XV - (2 * l1 * k1) / i1) * DAMPING / 10;
ballVY += p2YV - (2 * i2 * k1) / i1;
}
else
{
ballVX = 0;
ballVY = 0;
}
if(ballVX < -15)
ballVX = -15;
if(ballVX > 15)
ballVX = 15;
if(ballVY < -22)
ballVY = -22;
if(ballVY > 22)
ballVY = 22;
}
fP2Touched = true;
}
if(ballX < 15)
{
ballX = 15;
ballVX = -ballVX;
}
if(ballX > 985)
{
ballX = 985;
ballVX = -ballVX;
}
if ((ballX <= 50) || (ballX >= 950))
{
if (((ballY > 200) && (ballOldY < 200))
|| ((ballY < 200) && (ballOldY >= 200)))
{
ballY = 200;
ballVY *= -1;
}
if ((ballY > 180) && (ballY < 220))
{
if ((ballX > 40) && (ballX < 50) && (ballVX < 0))
{
ballX = 50;
ballVX *= -1;
}
if ((ballX < 960) && (ballX > 950) && (ballVX > 0))
{
ballX = 950;
ballVX *= -1;
}
}
}
if (ballY < 34)
{
ballY = 34;
ballVY = -ballVY * DAMPING / 10;
ballVX = ballVX * DAMPING / 10;
}
}
i = (ballX * nWidth) / 1000;
j = (4 * nHeight) / 5 - (ballY * nHeight) / 1000;
screen.setColor(Color.yellow);
screen.fillOval(i - k, j - k, k * 2, k * 2);
}

private void DrawGoals()
{
screen.setColor(Color.white);
screen.fillRect(nWidth / 20, 4 * nHeight / 5 - 200 * nHeight / 1000,
5, 200 * nHeight / 1000);
screen.fillRect(nWidth - nWidth / 20 - 5,
4 * nHeight / 5 - 200 * nHeight / 1000,
5, 200 * nHeight / 1000);
screen.fillRect(0, 4*nHeight/5 + 2, nWidth/10, 2);
screen.fillRect(nWidth*9/10, 4*nHeight/5 + 2, nWidth/10, 2);
for (int i=0; i<nWidth / 20; i += 5)
{
screen.drawLine(i, 4 * nHeight / 5 - 200 * nHeight / 1000,
i, 4 * nHeight / 5);
screen.drawLine(nWidth-i, 4 * nHeight / 5 - 200 * nHeight / 1000,
nWidth-i, 4 * nHeight / 5);
}
for (int i=4 * nHeight / 5 - nHeight / 5; i<4 * nHeight / 5; i += 5)
{
screen.drawLine(0, i, nWidth/20, i);
screen.drawLine(nWidth, i, nWidth-nWidth/20, i);
}
int p1TickX = (MAX_TICKS_TOUCHING_GOAL - p1TouchingGoal)
* nWidth / (2 * MAX_TICKS_TOUCHING_GOAL);
screen.setColor(secondaryCols[p1Col]);
screen.fillRect(0, nHeight-5, p1TickX, 5);
screen.setColor(Color.gray);
screen.fillRect(p1TickX, nHeight-5, nWidth/2-p1TickX, 5);
int p2TickX = nWidth - (MAX_TICKS_TOUCHING_GOAL - p2TouchingGoal)
* nWidth / (2 * MAX_TICKS_TOUCHING_GOAL);
screen.setColor(secondaryCols[p2Col]);
screen.fillRect(p2TickX, nHeight-5, nWidth, 5);
screen.setColor(Color.gray);
screen.fillRect(nWidth/2, nHeight-5, p2TickX-nWidth/2, 5);
}

private void DrawStatus()
{
Graphics g = screen;
FontMetrics fontmetrics = screen.getFontMetrics();
String s=null, time = MakeTime(gameTime);
int i = nHeight / 20;
int k=0, kt = fontmetrics.stringWidth(time);
if (worldCup)
{
switch (worldCupRound)
{
case 1: s = "Quarter Finals"; break;
case 2: s = "Semi-Finals"; break;
case 3: s = "Final"; break;
default: s = "Qualifying";
}
if (fGoldenGoal) s += " [Golden Goal]";
else if (fExtraTime) s += " [Extra Time]";
k = fontmetrics.stringWidth(s);
}
int mw = (k>kt) ? k : kt;
g.setColor(Color.blue);
g.fillRect(nWidth/2 - mw / 2 - 5, 0, mw + 10, i + 22);
g.setColor(Color.white);
screen.drawString(time, nWidth/2 - kt / 2, fontmetrics.getAscent() + 20);
if (s != null) screen.drawString(s, nWidth/2 - k/2, fontmetrics.getAscent()+20-fontmetrics.getHeight());
}

public void drawPrompt()
{
screen.setColor(Color.gray);
screen.fillRect(0, (4 * nHeight) / 5 + 6, nWidth, nHeight / 5 - 10);
drawPrompt(promptMsg, 0);
}

public void drawPrompt(String s, int i)
{
FontMetrics fontmetrics = screen.getFontMetrics();
screen.setColor(Color.lightGray);
screen.drawString(s, (nWidth - fontmetrics.stringWidth(s)) / 2, (nHeight * 4) / 5 + fontmetrics.getHeight() * (i + 1) + 10);
}

private void promptBox(String msg1, String msg2)
{
FontMetrics fontmetrics = screen.getFontMetrics();
int len1 = fontmetrics.stringWidth(msg1);
int len2 = fontmetrics.stringWidth(msg2);
int maxlen = (len1 > len2) ? len1 : len2;
screen.setColor(Color.darkGray);
screen.fillRect(nWidth/2-maxlen/2-20, nHeight*2/5, maxlen+40, nHeight/5);
screen.setColor(Color.white);
screen.drawString(msg1, nWidth/2-len1/2, nHeight*9/20);
screen.drawString(msg2, nWidth/2-len2/2, nHeight*11/20);
flip();
}

private void SaveReplayData()
{
replayData[replayPos][0] = p1X;
replayData[replayPos][1] = p1Y;
replayData[replayPos][2] = p2X;
replayData[replayPos][3] = p2Y;
replayData[replayPos][4] = ballX;
replayData[replayPos][5] = ballY;
replayData[replayPos][6] = p1Col;
replayData[replayPos][7] = p2Col;
replayPos++;
if(replayPos >= 200)
replayPos = 0;
if(replayStart == replayPos)
replayStart++;
if(replayStart >= 200)
replayStart = 0;
}

private void drawScores()
{
Graphics g = screen;
int k = nHeight / 20;
FontMetrics fm = screen.getFontMetrics();
int i = fm.stringWidth("Replay...");
g.setColor(Color.blue);
g.fillRect(0, 0, nWidth, k + 22);
g.setColor(Color.white);
g.drawString(slimeColText[p1Col] + " : " + p1Score, nWidth/20, k);
String p2ScrStr = p2Score + " : " + slimeColText[p2Col];
g.drawString(p2ScrStr, nWidth-nWidth/20-fm.stringWidth(p2Sc
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Mar 27 2007
Added on Feb 27 2007
0 comments
197 views