hello everyone:
im having lots of problem gettin this thing to work!!!!!!! as u can see its a pong game written in JApplet and my problem is that i cant seem to find a solution to make both the initial display for the introduction and the display of the game to work together without any interference between them. if anyone could help me on this one id really appreciate it the only thing i need is a presentation like for example stating the name of the game and the creator and then as u click on the mouse u can start playing(also any advices are welcome since its possible that there are many unused things in the code), here's the code:
public class jPongback extends Applet implements Runnable { Thread runner;
Image offscreeni;
Graphics offscreeng;
Rectangle plane;
Point ballPoint, racketPoint, enemyPoint, ballSpeed;
boolean start, death = false;
int playerScore, enemyScore = 0;
int tuffhet = 8;
int place;
AudioClip rebond;
AudioClip touch;
AudioClip murrebond;
Image ii;
Dimension d;
int[] dx,dy;
Graphics goff;
Font largefont = new Font("Helvetica", Font.BOLD, 24);
Font smallfont = new Font("Helvetica", Font.BOLD, 14);
final int blocksize=24;
final int nrofblocks=15;
FontMetrics fmsmall, fmlarge;
final int scrsize=nrofblocks*blocksize;
boolean showtitle=true;
boolean scared=false;
final int screendelay=120;
int count=screendelay;
short[] screendata;
public String getAppletInfo()
{
return("PacMan - par Hugon Bastien");
}
public void init() {
Graphics g;
d = getSize();
setBackground(Color.blue);
g=getGraphics();
g.setFont(smallfont);
fmsmall = g.getFontMetrics();
g.setFont(largefont);
fmlarge = g.getFontMetrics();
GameInit();}
public void GameInit(){
offscreeni = createImage(this.size().width, this.size().height);
offscreeng = offscreeni.getGraphics();
setBackground(Color.black);
ballPoint = new Point((this.size().width/2), (this.size().height/2));
racketPoint = new Point((this.size().width -25), ((this.size().height/2) -25));
enemyPoint = new Point(20, ((this.size().height/2) -25));
plane = new Rectangle(15, 15, (this.size().width), (this.size().height -30));
ballSpeed = new Point(0,0);
rebond = getAudioClip (getCodeBase(), "rebond.au");
murrebond = getAudioClip (getCodeBase(), "murrebond.au");
touch = getAudioClip (getCodeBase(), "touch.au");
repaint();
}
public void start() {
if (runner == null) {
runner = new Thread(this);
runner.start();
}
}
public void stop() {
if (runner != null) {
runner.stop();
runner = null;
}
}
public void run() {
for (int i = 3; i > 0; i = (i - 1)) {
death = true;
repaint();
try { Thread.sleep(300); }
catch (InterruptedException e) { };
death = false;
repaint();
try { Thread.sleep(300); }
catch (InterruptedException e) { };
}
ballPoint = new Point((this.size().width/2), (this.size().height/2)); //reinitialisation de la position de la balle
ballSpeed.x = 0;
ballSpeed.y = 0;
start = false;
}