gpt4 book ai didi

java - 将 Java 应用程序转换为 applet 混淆

转载 作者:行者123 更新时间:2023-12-02 00:26:16 25 4
gpt4 key购买 nike

我正在努力创建一个太空入侵者类型的克隆,我已经快完成了。现在的问题是,我想让我的 friend 将其发布到他的网站,因此我需要将其从应用程序转换为小程序。我在网上查看了一些示例,并尝试了一下它,并尝试将其放入一个用 html 制作的简单网页中,但我似乎无法让它正常工作。有人可以看一下我的代码并引导我完成此转换吗?我将非常感谢任何帮助!我发布了应用程序代码,这样我可能尝试过的任何内容都不会混淆。

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();

}

最佳答案

这可能是一个更好的主意 - 与其尝试将方钉(创建 JFrame 的程序)插入圆孔(将其更改为小程序),为什么不使用 Java Web Start,因此网页可以发布JFrame吗?我认为从长远来看,这会让你的事情变得更容易。

请看这里:

关于java - 将 Java 应用程序转换为 applet 混淆,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/9950803/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com