游戏窗体创建

资源下载:http://pan.baidu.com/s/1eSth0zg

 

游戏窗口的创建:

    1、新建一个项目Game,右键-->属性-->文本文件编码中选择其他,将编码设置为UTF-8

    2、将下载好的libs、res复制粘贴到项目下

    3、选择libs-->jar目录下选中3个jar包右键构建路径

    4、新建一个设置类GameSet并在超类中选择Window-org.itheima.game,在报错的位置添加构造函数

    5、再新建一个启动类GameStart添加main方法

    6、New一个设置类并调用start方法

    7、运行报错的话,右键-->运行方式-->运行配置,选择自变量栏,在VM自变量中输入:

       Djava.library.path=./libs/natives/windows         点击运行

 

运行配置:

 

 

 1 public class GameSet extends Window {
 2 
 3     public GameSet(String title, int width, int height, int fps) {
 4         super(title, width, height, fps);
 5         // TODO 自动生成的构造函数存根
 6     }
 7 
 8     @Override
 9     protected void onCreate() {
10         // TODO 自动生成的方法存根
11 
12     }
13 
14     @Override
15     protected void onMouseEvent(int key, int x, int y) {
16         // TODO 自动生成的方法存根
17 
18     }
19 
20     @Override
21     protected void onKeyEvent(int key) {
22         // TODO 自动生成的方法存根
23 
24     }
25 
26     @Override
27     protected void onDisplayUpdate() {
28         // TODO 自动生成的方法存根
29 
30     }
31 
32 }
设置类

 

1 public class GameStart {
2 
3     public static void main(String[] args) {
4         GameSet gs = new GameSet("游戏窗口", 1366, 768, 60);   //标题,窗口宽、高、帧率
5         gs.start();
6     }
7 
8 }
启动类

 

 

随笔说:

    

      游戏引擎
          LWJGL 全称: LightWight Java Game Library(轻量级Java游戏工具库)

        特点:
          Low-level Bindings: 低耦合
          Open Source: 开源
          Built-in Documentation: 有文档说明
          Cross-platform: 跨平台
          Community: 有社区
          GLFW Bindings: 可以支持游戏手柄开发

 

posted @ 2017-08-21 02:15  B_Lasting_尊  阅读(287)  评论(0编辑  收藏  举报