"Java에서 Killer Game Programming"이라는 책을 얻었습니다. J2SE 5.0을 설치하기로되어 있었지만 J2SE는 End of Life에 있습니다. StackOverflow 및 저자와의 토론 후 JSE 7u5 인 oracle.com에서 업데이트 된 버전을 설치했습니다. JRE가 포함 된 JDK를 다운로드했습니다. 이제 NetBeans 7.1.2를 JDK 1.7과 함께 사용하고 있지만 터미널에서는 1.7.0_05라고 부릅니다. 첫 번째 프로그램은 주요 방법 없이는 실행할 수 없다는 말입니다. 설치 한 업데이트 된 버전이이 설명서의 프로그램에서 작동하지 않을 수있는 이유가 있습니까? 시도해야하는 또 다른 권장 버전이 있습니까? 아래에 전체 코드를 게시했습니다. 수정 사항이 없습니다. 이 링크에서 바로 나타납니다 http://fivedots.coe.psu.ac.th/~ad/jg/ch1/ch1.pdf 모든 오류는 기울임 꼴이며 굵게 표시됩니다.사용할 Java 버전
public class GamePanel extends JPanel implements Runnable
{
private static final int PWIDTH = 500; // size of panel
private static final int PHEIGHT = 400;
private Thread animator;
private boolean running = false;
private boolean gameOver = false;
// more variables, explained later
:
public GamePanel()
// for the animation
// stops the animation
// for game termination
{
setBackground(***Color***.white); // white background
setPreferredSize(new ***Dimension***(PWIDTH, PHEIGHT));
// create game components
} // end of GamePanel()
public void addNotify()
/* Wait for the JPanel to be added to the
JFrame/JApplet before starting. */
{
***super.addNotify();*** // creates the peer
startGame(); // start the thread
}
private void startGame()
// initialise and start the thread
{
if (animator == null || !running) {
***animator = new Thread(this);***
animator.start();
}
} // end of startGame()
public void stopGame()
// called by the user to stop execution
{ running = false; }
public void run()
/* Repeatedly update, render, sleep */
{
running = true;
while(running) {
gameUpdate();
***gameRender();***
repaint();
try {
// game state is updated
// render to a buffer
// paint with the buffer
Thread.sleep(20); // sleep a bit
}
catch(InterruptedException ex){}
}
System.exit(0); // so enclosing JFrame/JApplet exits
} // end of run()
private void gameUpdate()
{ if (!gameOver)
// update game state ...
}
// more methods, explained later...
} // end of GamePanel class
"컴파일하지 않는다"는 것은 무엇을 의미합니까? 컴파일하지 않는 코드를 보여줄 수 있습니까? –
그래, 7.x를 사용하면 괜찮을거야. 발생하는 코드 및 특정 오류에 대한 질문에 다시 집중하십시오. – Marvo
코드 또는 오류 메시지없이 ... 도움이 어렵습니다. –