Browse Source

✨ Add Component base class to all components

Pedro Schneider 3 years ago
parent
commit
62211041d3

+ 1 - 0
build

@@ -12,6 +12,7 @@ cat pandora/handlers/GameHandler.js >> build.js
 cat pandora/handlers/AssetHandler.js >> build.js
 
 # Package components
+cat pandora/components/Component.js >> build.js
 cat pandora/components/Color.js >> build.js
 cat pandora/components/Vector2.js >> build.js
 cat pandora/components/Signal.js >> build.js

+ 26 - 0
pandora/components/Component.js

@@ -0,0 +1,26 @@
+/************************************************************************
+ * Component.js
+ ************************************************************************
+ * Copyright (c) 2021 Pedro Tonini Rosenberg Schneider.
+ *
+ * This file is part of Pandora.
+ *
+ * Pandora is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * Pandora is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *     
+ * You should have received a copy of the GNU General Public License     
+ * along with Pandora.  If not, see <https://www.gnu.org/licenses/>.
+ *************************************************************************/
+
+class Component
+{
+    constructor()
+    {}
+}

+ 3 - 1
pandora/components/Ellipse.js

@@ -27,7 +27,7 @@
  * 
  * @class
  */
-class Ellipse
+class Ellipse extends Component
 {
     /**
      * Initializes an Ellipse with the given parameters.
@@ -39,6 +39,8 @@ class Ellipse
      */
     constructor(rx, ry = rx)
     {
+        super();
+        
         this.rx = rx;
         this.ry = ry;
     }

+ 3 - 1
pandora/components/Rect.js

@@ -27,7 +27,7 @@
  * 
  * @class
  */
-class Rect
+class Rect extends Component
 {
     /**
      * Initializes a Rect with the given parameters.
@@ -39,6 +39,8 @@ class Rect
      */
     constructor(w, h = w)
     {
+        super();
+        
         this.w = w;
         this.h = h;
     }

+ 3 - 1
pandora/components/Signal.js

@@ -29,10 +29,12 @@
  * 
  * @class
  */
-class Signal
+class Signal extends Component
 {
     constructor(name)
     {
+        super();
+
         this.name = name;
         this.targets = [];
         this.callbacks = [];

+ 3 - 1
pandora/components/Vector2.js

@@ -27,7 +27,7 @@
  * 
  * @class
  */
-class Vector2
+class Vector2 extends Component
 {
     /**
      * Creates a Vector2 with length 0.
@@ -98,6 +98,8 @@ class Vector2
      */
     constructor(x, y)
     {
+        super();
+
         this.x = x;
         this.y = y;
     }