2012-03-30 35 views
0

我正在创建Space Invaders类型克隆,并且我已经完成了它。现在的问题是,我想让我的朋友发布到他的网站,所以我需要将它转换为应用程序的小程序。我已经在网上看了一些例子,并用它做了一些尝试,并尝试将它放入一个用html制作的简单网页,但我似乎无法让它正常工作。有人可以看看我的代码,并通过这种转换来引导我吗?我将不胜感激任何帮助!我发布应用程序代码,所以我可能尝试过的任何东西都不会混淆。将Java应用程序转换为applet混淆

public class InvadersMain implements KeyListener{ 

// GUI, Keyboard, Game Data here 
private JFrame frame; 
private JPanel playArea; 
private JPanel sidePanel; 
private JLabel scoreLabel; 
private JLabel scoreDisplay; 
private JLabel livesLabel; 
private JLabel livesDisplay; 
private JLabel title1; 
private JLabel title2; 


private final int playWidth = 500; 
private final int playHeight = 500; 

public String name = ""; 

public int baddysDead = 0; 
public int playerScore = 0; 
public int playerLives = 3; 
public int waveNumber = 1; 
public int waveScore = 20; 

public double baddySpeed = 1 + (waveNumber-1)/5000; 
// Game Data 
private InvadersShip ship; 

public ArrayList<InvadersShot> shots; 
public ArrayList<InvadersBaddy> baddys; 

private boolean shipDead; // Whether or not the ship has been blown up 
private long shipTimeOfDeath; // The time at which the ship blew up 

// Keyboard data 
private boolean rightHeld = false; 
private boolean leftHeld = false; 
private boolean firing = false; 

// Set up the game and play 
public InvadersMain(){ 

    // set everything up 
    configureGUI(); 
    configureGameData(); 

    // display window 
    frame.setVisible(true); 

    // start game 
    playGame(); 
    name = JOptionPane.showInputDialog(null, "GAME OVER \nPlease enter your name"); 

} 

我想是需要改变的部分隔离开来,所以如果有什么进一步的需要,请让我知道。

public static void main(String[] args){ 
    new InvadersMain(); 

} 

回答

3

这里有可能是一个更好的主意 - 而不是试图推动方钉(您的程序创建一个JFrame)成圆孔(它变成一个applet),为什么不改用Java Web Start的,所以网页可以发布JFrame?我认为从长远来看,这会让你更容易。

请看看这里:

+1

我同意,[JWS(http://stackoverflow.com/tags/java-web -start/info)/'JFrame'是这个用例的最佳选择。 – 2012-03-30 22:05:13