浏览代码

✨Create default UI object

- Tweak GameHandler to initialize the UI module,
- Add documentation to index.html for the new partes of the engine.
Pedro Schneider 3 年之前
父节点
当前提交
aa835330d7
共有 3 个文件被更改,包括 15 次插入0 次删除
  1. 3 0
      index.html
  2. 8 0
      pandora/game_objects/ui_objects/UIObject.js
  3. 4 0
      pandora/handlers/GameHandler.js

+ 3 - 0
index.html

@@ -29,9 +29,12 @@
     
     <!-- Game Objects -->
     <script src="pandora/game_objects/GameObject.js"></script>
+    <!-- 2D Game Objects -->
     <script src="pandora/game_objects/2d_objects/Object2D.js"></script>
     <script src="pandora/game_objects/2d_objects/Shape2D.js"></script>
     <script src="pandora/game_objects/2d_objects/Sprite2D.js"></script>
+    <!-- UI Game Objects -->
+    <script src="pandora/game_objects/ui_objects/UIObject.js"></script>
 
     <!-- Handlers -->
     <script src="pandora/handlers/GameHandler.js"></script>

+ 8 - 0
pandora/game_objects/ui_objects/UIObject.js

@@ -0,0 +1,8 @@
+class UIObject extends GameObject {
+    constructor(name) {
+        super(name);
+
+        this.position = Vector2.ZERO();
+        this.size = Vector2(100, 100);
+    }
+}

+ 4 - 0
pandora/handlers/GameHandler.js

@@ -15,6 +15,7 @@ class GameHandler
         this.bDrawDebugFPS = val;
     }
 
+    static gui;
     static init(fps=60)
     {
         if (!this.renderMode) this.renderMode = RENDER_MODES.P2D;
@@ -30,6 +31,8 @@ class GameHandler
         }
         frameRate(fps);
         smooth();
+
+        this.gui = createGui();
     }
 
     static instanceGameObject(obj)
@@ -62,6 +65,7 @@ class GameHandler
             fill(0);
             text("FPS: " + frameRate(), 10, 20);
         }
+        drawGui();
 
         for (let i = 0; i < this.rootObjects.length; i++)
             this.rootObjects[i].draw(this.delta);