Cant import a timer help pls

i was looking online for game making tutorials and came acrost this code below. I cant seem to get it to compile because it cant find the

import com.sun.j3d.utils.timer.J3DTimer;

what can i do or change it to make this work and complile

package BugRunner;

// BugPanel.java

// Andrew Davison, April 2005, ad@fivedots.coe.psu.ac.th

/* The game's drawing surface. Uses active rendering to a JPanel

with the help of Java 3D's timer.

See WormP for a version with statistics generation.

*/

import javax.swing.*;

import java.awt.image.*;

import java.awt.event.*;

import java.awt.*;

import com.sun.j3d.utils.timer.J3DTimer;

publicclass BugPanelextends JPanelimplements Runnable

{

privatestaticfinalint PWIDTH = 500;// size of panel

privatestaticfinalint PHEIGHT = 400;

privatestaticfinalint NO_DELAYS_PER_YIELD = 16;

/* Number of frames with a delay of 0 ms before the animation thread yields

to other running threads. */

privatestaticint MAX_FRAME_SKIPS = 5;

// no. of frames that can be skipped in any one animation loop

// i.e the games state is updated but not rendered

// image and clip loader information files

privatestaticfinal String IMS_INFO ="imsInfo.txt";

privatestaticfinal String SNDS_FILE ="clipsInfo.txt";

private Thread animator;// the thread that performs the animation

privatevolatileboolean running =false;// used to stop the animation thread

privatevolatileboolean isPaused =false;

privatelong period;// period between drawing in _nanosecs_

private BugRunner bugTop;

private ClipsLoader clipsLoader;

private BallSprite ball;// the sprites

private BatSprite bat;

privatelong gameStartTime;// when the game started

privateint timeSpentInGame;

// used at game termination

privatevolatileboolean gameOver =false;

privateint score = 0;

// for displaying messages

private Font msgsFont;

private FontMetrics metrics;

// off-screen rendering

private Graphics dbg;

private Image dbImage =null;

// holds the background image

private BufferedImage bgImage =null;

public BugPanel(BugRunner br,long period)

{

bugTop = br;

this.period = period;

setDoubleBuffered(false);

setBackground(Color.black);

setPreferredSize(new Dimension(PWIDTH, PHEIGHT));

setFocusable(true);

requestFocus();// the JPanel now has focus, so receives key events

addKeyListener(new KeyAdapter(){

publicvoid keyPressed(KeyEvent e)

{ processKey(e);}

});

// load the background image

ImagesLoader imsLoader =new ImagesLoader(IMS_INFO);

bgImage = imsLoader.getImage("bladerunner");

// initialise the clips loader

clipsLoader =new ClipsLoader(SNDS_FILE);

// create game sprites

bat =new BatSprite(PWIDTH, PHEIGHT, imsLoader,

(int)(period/1000000) );// in ms

ball =new BallSprite(PWIDTH, PHEIGHT, imsLoader, clipsLoader, this, bat);

addMouseListener(new MouseAdapter(){

publicvoid mousePressed(MouseEvent e)

{ testPress(e.getX());}// handle mouse presses

});

// set up message font

msgsFont =new Font("SansSerif", Font.BOLD, 24);

metrics = this.getFontMetrics(msgsFont);

}// end of BugPanel()

privatevoid processKey(KeyEvent e)

// handles termination and game-play keys

{

int keyCode = e.getKeyCode();

// termination keys

// listen for esc, q, end, ctrl-c on the canvas to

// allow a convenient exit from the full screen configuration

if ((keyCode == KeyEvent.VK_ESCAPE) || (keyCode == KeyEvent.VK_Q) ||

(keyCode == KeyEvent.VK_END) ||

((keyCode == KeyEvent.VK_C) && e.isControlDown()) )

running =false;

// game-play keys

if (!isPaused && !gameOver){

if (keyCode == KeyEvent.VK_LEFT)

bat.moveLeft();

elseif (keyCode == KeyEvent.VK_RIGHT)

bat.moveRight();

elseif (keyCode == KeyEvent.VK_DOWN)

bat.stayStill();

}

}// end of processKey()

publicvoid gameOver()

// called by BallSprite to signal that the game is over

{

int finalTime =

(int) ((J3DTimer.getValue() - gameStartTime)/1000000000);// ns --> secs

score = finalTime;// could be more fancy!

clipsLoader.play("gameOver",false);// play a game over clip once

gameOver =true;

}// end of gameOver()

publicvoid addNotify()

// wait for the JPanel to be added to the JFrame before starting

{ super.addNotify();// creates the peer

startGame();// start the thread

}

privatevoid startGame()

// initialise and start the thread

{

if (animator ==null || !running){

animator =new Thread(this);

animator.start();

}

}// end of startGame()

// - game life cycle methods

// called by the JFrame's window listener methods

publicvoid resumeGame()

// called when the JFrame is activated / deiconified

{ isPaused =false;}

publicvoid pauseGame()

// called when the JFrame is deactivated / iconified

{ isPaused =true;}

publicvoid stopGame()

// called when the JFrame is closing

{ running =false;}

// -

privatevoid testPress(int x)

// use a mouse press to control the bat

{if (!isPaused && !gameOver)

bat.mouseMove(x);

}// end of testPress()

publicvoid run()

/* The frames of the animation are drawn inside the while loop. */

{

long beforeTime, afterTime, timeDiff, sleepTime;

long overSleepTime = 0L;

int noDelays = 0;

long excess = 0L;

gameStartTime = J3DTimer.getValue();

beforeTime = gameStartTime;

running =true;

while(running){

gameUpdate();

gameRender();

paintScreen();

afterTime = J3DTimer.getValue();

timeDiff = afterTime - beforeTime;

sleepTime = (period - timeDiff) - overSleepTime;

if (sleepTime > 0){// some time left in this cycle

try{

Thread.sleep(sleepTime/1000000);// nano -> ms

}

catch(InterruptedException ex){}

overSleepTime = (J3DTimer.getValue() - afterTime) - sleepTime;

}

else{// sleepTime <= 0; the frame took longer than the period

excess -= sleepTime;// store excess time value

overSleepTime = 0L;

if (++noDelays >= NO_DELAYS_PER_YIELD){

Thread.yield();// give another thread a chance to run

noDelays = 0;

}

}

beforeTime = J3DTimer.getValue();

/* If frame animation is taking too long, update the game state

without rendering it, to get the updates/sec nearer to

the required FPS. */

int skips = 0;

while((excess > period) && (skips < MAX_FRAME_SKIPS)){

excess -= period;

gameUpdate();// update state but don't render

skips++;

}

}

System.exit(0);// so window disappears

}// end of run()

privatevoid gameUpdate()

{if (!isPaused && !gameOver){

ball.updateSprite();

bat.updateSprite();

}

}// end of gameUpdate()

privatevoid gameRender()

{

if (dbImage ==null){

dbImage = createImage(PWIDTH, PHEIGHT);

if (dbImage ==null){

System.out.println("dbImage is null");

return;

}

else

dbg = dbImage.getGraphics();

}

// draw the background: use the image or a black colour

if (bgImage ==null){

dbg.setColor(Color.black);

dbg.fillRect (0, 0, PWIDTH, PHEIGHT);

}

else

dbg.drawImage(bgImage, 0, 0,this);

// draw game elements

ball.drawSprite(dbg);

bat.drawSprite(dbg);

reportStats(dbg);

if (gameOver)

gameOverMessage(dbg);

}// end of gameRender()

privatevoid reportStats(Graphics g)

// Report the number of returned balls, and time spent playing

{

if (!gameOver)// stop incrementing the timer once the game is over

timeSpentInGame =

(int) ((J3DTimer.getValue() - gameStartTime)/1000000000);// ns --> secs

g.setColor(Color.yellow);

g.setFont(msgsFont);

ball.drawBallStats(g, 15, 25);// the ball sprite reports the ball stats

g.drawString("Time: " + timeSpentInGame +" secs", 15, 50);

g.setColor(Color.black);

}// end of reportStats()

privatevoid gameOverMessage(Graphics g)

// center the game-over message in the panel

{

String msg ="Game Over. Your score: " + score;

int x = (PWIDTH - metrics.stringWidth(msg))/2;

int y = (PHEIGHT - metrics.getHeight())/2;

g.setColor(Color.red);

g.setFont(msgsFont);

g.drawString(msg, x, y);

}// end of gameOverMessage()

privatevoid paintScreen()

// use active rendering to put the buffered image on-screen

{

Graphics g;

try{

g = this.getGraphics();

if ((g !=null) && (dbImage !=null))

g.drawImage(dbImage, 0, 0,null);

// Sync the display on some systems.

// (on Linux, this fixes event queue problems)

Toolkit.getDefaultToolkit().sync();

g.dispose();

}

catch (Exception e)

{ System.out.println("Graphics context error: " + e);}

}// end of paintScreen()

}// end of BugPanel class

[19775 byte] By [shadowice0823a] at [2007-11-27 2:24:37]
# 1
did you download the Java3D package and set it up correctly ?
MaxxDmga at 2007-7-12 2:31:52 > top of Java-index,Java Essentials,New To Java...
# 2
i downloaded a zip but this file was not part of it the url for it is http://fivedots.coe.psu.ac.th/~ad/jg/code/ch11Code.zip if you want to check it out and see if it i installed it wrong, but im pretty sure i got it put in right.
shadowice0823a at 2007-7-12 2:31:52 > top of Java-index,Java Essentials,New To Java...
# 3
would it be possible to change the timer to a movespeed and get by that way?
shadowice0823a at 2007-7-12 2:31:52 > top of Java-index,Java Essentials,New To Java...
# 4
you could create your own timer, but check out the setup instructions for Java3D...
MaxxDmga at 2007-7-12 2:31:52 > top of Java-index,Java Essentials,New To Java...