📄 ufo_applet.java
字号:
import java.awt.*;
import javax.swing.JFrame;
/**
* <p>Title: UFO_Play</p>
*
* <p>Description: 基于applet的攻击UFO的小游戏,applet游戏入口</p>
*
* <p>Copyright: Copyright (c) 2007</p>
*
* <p>Company: 鹿児島大学</p>
* @author 柴 智
* @version 1.0
*/
public class UFO_Applet extends BaseApplet {
boolean isStandalone = false;
BorderLayout borderLayout1 = new BorderLayout();
//Get a parameter value
public String getParameter(String key, String def) {
return isStandalone ? System.getProperty(key, def) :
(getParameter(key) != null ? getParameter(key) : def);
}
//Construct the applet
public UFO_Applet() {
}
//Initialize the applet
public void init() {
try {
jbInit();
setWorld(new UFO_World(this));
} catch (Exception e) {
e.printStackTrace();
}
}
//Component initialization
private void jbInit() throws Exception {
this.setSize(new Dimension(350, 500));
// this.getContentPane().setLayout(borderLayout1);
}
//Get Applet information
public String getAppletInfo() {
return "Applet Information";
}
//Get parameter info
public String[][] getParameterInfo() {
return null;
}
//Main method
public static void main(String[] args) {
UFO_Applet applet = new UFO_Applet();
applet.isStandalone = true;
JFrame frame = new JFrame();
applet.isStandalone = true;
//EXIT_ON_CLOSE == 3;
frame.setDefaultCloseOperation(3);
}
//处理鼠标移动事件
public boolean mouseMove(Event e, int x, int y) {
// 返回鼠标所在位置的X坐标
if(this.world instanceof UFO_World){
((UFO_World)world).mouseMove(e,x,y);
return true;
}else{
return false;
}
}
// 处理鼠标的按下事件
public boolean mouseDown(Event e, int x, int y) {
//游戏结束时所做的相应处理
if(this.world instanceof UFO_World){
((UFO_World)world).mouseDown(e,x,y);
return true;
}else{
return false;
}
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -