欧美一区二区三区,国内熟女精品熟女A片视频小说,日本av网,小鲜肉男男GAY做受XXX网站

java火和java魚雷

夏志豪1年前8瀏覽0評論

在Java語言中,有一種技術被稱為“Java火”和“Java魚雷”。

Java火是一種使用Java語言編寫的圖形化界面效果,它可以將文本轉換成立體的火焰效果,同時還可以在圖形界面上添加各種控制按鈕和調節參數的選項。

public class JavaFire extends JFrame {
private final int WIDTH = 800;
private final int HEIGHT = 600;
private Canvas canvas;
private int[] firePixels;
private int fireWidth;
private int fireHeight;
private boolean running;
public JavaFire() {
setSize(WIDTH, HEIGHT);
setDefaultCloseOperation(WindowConstants.EXIT_ON_CLOSE);
setLocationRelativeTo(null);
setResizable(false);
canvas = new Canvas();
canvas.setSize(WIDTH, HEIGHT);
add(canvas);
pack();
fireWidth = WIDTH / FireConfig.CELL_SIZE;
fireHeight = HEIGHT / FireConfig.CELL_SIZE;
firePixels = new int[fireWidth * fireHeight];
start();
}
private void start() {
running = true;
Thread thread = new Thread(this::run);
thread.start();
}
private void run() {
while (running) {
updateFire();
renderFire();
}
dispose();
}
private void updateFire() {
for (int x = 0; x< fireWidth; x++) {
FireUtils.spreadFire(firePixels, x, fireWidth, fireHeight);
}
}
private void renderFire() {
canvas.render(firePixels);
}
public static void main(String[] args) {
new JavaFire().setVisible(true);
}
}

Java魚雷也是一種Java語言編寫的圖形化界面效果,它可以模擬出真實的海水動態效果,并且可以在圖形界面上添加各種控制按鈕和調節參數的選項。

public class JavaTorpedo extends JFrame {
private final int WIDTH = 800;
private final int HEIGHT = 600;
private Canvas canvas;
private Torpedo torpedo;
public JavaTorpedo() {
setSize(WIDTH, HEIGHT);
setDefaultCloseOperation(WindowConstants.EXIT_ON_CLOSE);
setLocationRelativeTo(null);
setResizable(false);
canvas = new Canvas();
canvas.setSize(WIDTH, HEIGHT);
add(canvas);
pack();
torpedo = new Torpedo(WIDTH, HEIGHT);
keyboard();
start();
}
private void keyboard() {
addKeyListener(new KeyAdapter() {
@Override
public void keyPressed(KeyEvent e) {
switch (e.getKeyCode()) {
case KeyEvent.VK_W:
torpedo.up();
break;
case KeyEvent.VK_S:
torpedo.down();
break;
case KeyEvent.VK_A:
torpedo.left();
break;
case KeyEvent.VK_D:
torpedo.right();
break;
case KeyEvent.VK_SPACE:
torpedo.fire();
break;
}
}
});
}
private void start() {
Thread thread = new Thread(this::run);
thread.start();
}
private void run() {
while (true) {
update();
render();
}
}
private void update() {
torpedo.update();
}
private void render() {
canvas.render(torpedo.getScreen());
}
public static void main(String[] args) {
new JavaTorpedo().setVisible(true);
}
}

在Java程序員的世界里,Java火和Java魚雷是使用Java語言制作出來的非常有趣的效果,可以讓程序員們更加深入地理解Java語言和圖形化界面的應用。

上一篇oracle host