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();
}
我同意,[JWS(http://stackoverflow.com/tags/java-web -start/info)/'JFrame'是這個用例的最佳選擇。 – 2012-03-30 22:05:13