浏览代码

🔥 Remove the source for the Pandora engine from the project

- The files have been removed from this repository because it is meant for the game itself. The engine source code can be found here:
https://gitlab.com/pedrotrschneider/pandora
Pedro Schneider 3 年之前
父节点
当前提交
9631bbbde6
共有 34 个文件被更改,包括 0 次插入5900 次删除
  1. 0 65
      pandora/components/Color.js
  2. 0 41
      pandora/components/Component.js
  3. 0 47
      pandora/components/Ellipse.js
  4. 0 47
      pandora/components/Rect.js
  5. 0 43
      pandora/components/Shape.js
  6. 0 42
      pandora/components/Signal.js
  7. 0 269
      pandora/components/Vector2.js
  8. 0 220
      pandora/game_objects/2d_objects/AnimatedSprite2D.js
  9. 0 169
      pandora/game_objects/2d_objects/Area2D.js
  10. 0 229
      pandora/game_objects/2d_objects/Object2D.js
  11. 0 69
      pandora/game_objects/2d_objects/Sprite2D.js
  12. 0 97
      pandora/game_objects/AudioPlayer.js
  13. 0 420
      pandora/game_objects/GameObject.js
  14. 0 158
      pandora/game_objects/Timer.js
  15. 0 461
      pandora/game_objects/Tween.js
  16. 0 66
      pandora/game_objects/ui_objects/Button.js
  17. 0 142
      pandora/game_objects/ui_objects/CheckBox.js
  18. 0 73
      pandora/game_objects/ui_objects/ColorPicker.js
  19. 0 130
      pandora/game_objects/ui_objects/Input.js
  20. 0 76
      pandora/game_objects/ui_objects/Label.js
  21. 0 195
      pandora/game_objects/ui_objects/Radio.js
  22. 0 170
      pandora/game_objects/ui_objects/Select.js
  23. 0 132
      pandora/game_objects/ui_objects/Slider.js
  24. 0 648
      pandora/game_objects/ui_objects/UIObject.js
  25. 0 210
      pandora/handlers/AssetHandler.js
  26. 0 378
      pandora/handlers/GameHandler.js
  27. 0 46
      pandora/resources/AudioRes.js
  28. 0 46
      pandora/resources/FontRes.js
  29. 0 43
      pandora/resources/Resource.js
  30. 0 233
      pandora/resources/SpriteFrames.js
  31. 0 46
      pandora/resources/TextureRes.js
  32. 0 118
      pandora/singletons/Collisions.js
  33. 0 679
      pandora/singletons/Easings.js
  34. 0 92
      pandora/singletons/Enums.js

+ 0 - 65
pandora/components/Color.js

@@ -1,65 +0,0 @@
-/************************************************************************
- * Color.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/>.
- *************************************************************************/
-
-/**
- * This {@code Color} class provides an interface to store a color as a component to
- * any GameObject.
- * 
- * @author Pedro Schneider
- * 
- * @class
- */
-class Color
-{
-    /**
-     * Initializes a Color with the given parameters.
-     * 
-     * @param {number(0, 255)} r 
-     * @param {number(0, 255)} g 
-     * @param {number(0, 255)} b 
-     * @param {number(0, 255)} a 
-     * 
-     * @constructor
-     */
-    constructor(r, g, b, a = 255)
-    {
-        this.r = r;
-        this.g = g;
-        this.b = b;
-        this.a = a;
-
-        this.p5Color = color(this.r, this.g, this.b, this.a);
-    }
-
-    /**
-     * Converts the color data in this Color component to a p5.Color.
-     * 
-     * @returns {p5.Color}  p5.Color representing this Color component.
-     */
-    getP5Color()
-    {
-        this.p5Color.setRed(this.r);
-        this.p5Color.setGreen(this.g);
-        this.p5Color.setBlue(this.b);
-        this.p5Color.setAlpha(this.a);
-        return this.p5Color;
-    }
-}

+ 0 - 41
pandora/components/Component.js

@@ -1,41 +0,0 @@
-/************************************************************************
- * 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/>.
- *************************************************************************/
-
-/**
- * This {@code Component} class represents the base class all Components inherit from.
- * 
- * ! This is an empty class the serves only to be inherited from to organize the hierarchy.
- * ! This class should not bet used by the user.
- * 
- * @author Pedro Schneider
- * 
- * @class
- */
-class Component
-{
-    /**
-     * Creates an empty Component.
-     * 
-     * @constructor
-     */
-    constructor()
-    {}
-}

+ 0 - 47
pandora/components/Ellipse.js

@@ -1,47 +0,0 @@
-/************************************************************************
- * Ellipse.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/>.
- *************************************************************************/
-
-/**
- * This {@code Ellipse} class provides an interface to store an ellipse as a component to
- * any GameObject.
- * 
- * @author Pedro Schneider
- * 
- * @class
- */
-class Ellipse extends Shape
-{
-    /**
-     * Initializes an Ellipse with the given parameters.
-     * 
-     * @param {number} rx   radius on the X axis. 
-     * @param {number} ry   radius on the Y axis. Default is the same as the X axis.
-     * 
-     * @constructor
-     */
-    constructor(rx, ry = rx)
-    {
-        super();
-
-        this.rx = rx;
-        this.ry = ry;
-    }
-}

+ 0 - 47
pandora/components/Rect.js

@@ -1,47 +0,0 @@
-/************************************************************************
- * Rect.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/>.
- *************************************************************************/
-
-/**
- * This {@code Rect} class provides an interface to store a rectangle as a component to
- * any GameObject.
- * 
- * @author Pedro Schneider
- * 
- * @class
- */
-class Rect extends Shape
-{
-    /**
-     * Initializes a Rect with the given parameters.
-     * 
-     * @param {number} w    width of the Rect.
-     * @param {number} h    height of the Rect.
-     * 
-     * @constructor
-     */
-    constructor(w, h = w)
-    {
-        super();
-
-        this.w = w;
-        this.h = h;
-    }
-}

+ 0 - 43
pandora/components/Shape.js

@@ -1,43 +0,0 @@
-/************************************************************************
- * Shape.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/>.
- *************************************************************************/
-
-/**
- * This {@code Shape} class represents the base class all Shape components inherit from.
- * 
- * ! This is an empty class the serves only to be inherited from to organize the hierarchy.
- * ! This class should not bet used by the user.
- * 
- * @author Pedro Schneider
- * 
- * @class
- */
-class Shape extends Component
-{
-    /**
-     * Creates an empty Shape Component.
-     * 
-     * @constructor
-     */
-    constructor()
-    {
-        super();
-    }
-}

+ 0 - 42
pandora/components/Signal.js

@@ -1,42 +0,0 @@
-/************************************************************************
- * Signal.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/>.
- *************************************************************************/
-
-/**
- * This {@code Signal} class provides an object to store data about a signal.
- * 
- * ! This class should not be used directly by the user. To add signals to GameObjects
- * ! use the addSignal() method from the object inside the _initSignals() callback.
- * 
- * @author Pedro Schneider
- * 
- * @class
- */
-class Signal extends Component
-{
-    constructor(name)
-    {
-        super();
-
-        this.name = name;
-        this.targets = [];
-        this.callbacks = [];
-    }
-}

+ 0 - 269
pandora/components/Vector2.js

@@ -1,269 +0,0 @@
-/************************************************************************
- * Vector2.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/>.
- *************************************************************************/
-
-/**
- * This {@code Vector2} class provides an interface to store a 2D vector as a component to
- * any GameObject.
- * 
- * @author Pedro Schneider
- * 
- * @class
- */
-class Vector2 extends Component
-{
-    /**
-     * Creates a Vector2 with length 0.
-     * 
-     * @returns {Vector2}   length 0 Vector2.
-     */
-    static ZERO()
-    {
-        return new Vector2(0, 0);
-    }
-
-    /**
-     * Creates a Vector2 with both dimetions equal to 1.
-     * 
-     * @returns {Vector2}   Vector2 with both dimentions equal to 1.
-     */
-    static ONE()
-    {
-        return new Vector2(1, 1);
-    }
-
-    /**
-     * Creates a Vector2 pointing right.
-     * 
-     * @returns {Vector2}   Vector2 pointing right.
-     */
-    static RIGHT()
-    {
-        return new Vector2(1, 0);
-    }
-
-    /**
-     * Creates a Vector2 pointing left.
-     * 
-     * @returns {Vector2}   Vector2 pointing left.
-     */
-    static LEFT()
-    {
-        return new Vector2(-1, 0);
-    }
-
-    /**
-     * Creates a Vector2 pointing up.
-     * 
-     * @returns {Vector2}   Vector2 pointing up.
-     */
-    static UP()
-    {
-        return new Vector2(0, -1);
-    }
-
-    /**
-     * Creates a Vector2 pointing down.
-     * 
-     * @returns {Vector2}   Vector2 pointing down.
-     */
-    static DOWN()
-    {
-        return new Vector2(0, 1);
-    }
-
-    /**
-     * Initializes a Vector2 with the given dimentions.
-     * @param {number} x 
-     * @param {number} y 
-     * 
-     * @constructor
-     */
-    constructor(x, y)
-    {
-        super();
-
-        this.x = x;
-        this.y = y;
-    }
-
-    /**
-     * Creates a Vector2 with de dimentions equal to the absolute value of
-     * this Vector2's dimentions.
-     * 
-     * @returns {Vector2}   created Vector2.
-     */
-    abs()
-    {
-        return new Vector2(abs(this.x), abs(this.y));
-    }
-
-    /**
-     * Returns this Vector2's angle in radians with respect to the positive X axis,
-     * or the (1, 0) vector.
-     *  
-     * @returns {number}    angle in radian between this Vector2 and the positive X axis.
-     */
-    angle()
-    {
-        return atan2(this.y, this.x);
-    }
-
-    /**
-     * Returns this Vector2's length squared.
-     * 
-     * @returns {number}    this Vector2's length squared.
-     */
-    lengthSquared()
-    {
-        return this.x * this.x + this.y * this.y;
-    }
-
-    /**
-     * Returns this Vector2's length.
-     * 
-     * @returns {number}    this Vector2's length. 
-     */
-    length()
-    {
-        return sqrt(this.lengthSquared());
-    }
-
-    /**
-     * Creates a Vector2 with length 1 pointing in the same direction of this Vector2.
-     * 
-     * @returns {Vector2}   normalized vector.
-     */
-    normalized()
-    {
-        let len = this.length();
-        return new Vector2(this.x / len, this.y / len);
-    }
-
-    /**
-     * Normalizes this vector inplace.
-     */
-    normalize()
-    {
-        let len = this.length();
-        this.x /= len;
-        this.y /= len;
-    }
-
-    /**
-     * Creates a Vector2 rotated a radians clockwise in relation to this Vector2.
-     * 
-     * @param {number} a    angle in radians to rotate the vector.
-     * 
-     * @returns {Vector2}   rotated Vector2.
-     */
-    rotated(a)
-    {
-        return new Vector2(this.x * cos(-a) - this.y * sin(-a), this.x * sin(-a) + this.y * cos(-a))
-    }
-
-    /**
-     * Rotates this Vector2 inplace by a radians clockwise.
-     * 
-     * @param {number} a    angle in radians to rotate this vector.
-     */
-    rotate(a)
-    {
-        let rotX = this.x * cos(-a) - this.y * sin(-a),
-            rotY = this.x * sin(-a) + this.y * cos(-a);
-
-        this.x = rotX;
-        this.y = rotY;
-    }
-
-    /**
-     * Creates a Vector2 based on this Vector2 but scaled by s.
-     * 
-     * @param {number} s    factor to scale the Vector2.
-     * 
-     * @returns {Vector2}   scaled Vector2. 
-     */
-    scaled(s)
-    {
-        return new Vector2(this.x * s, this.y * s);
-    }
-
-    /**
-     * Scales this Vector2 inplace.
-     * 
-     * @param {number} s    factor to scale the Vector2.
-     */
-    scale(s)
-    {
-        this.x *= s;
-        this.y *= s;
-    }
-
-    /**
-     * Creates a Vector2 based on this Vector2 but translated by x on the X-axis and y on the Y-axis.
-     * 
-     * @param {number} x    X-axis translation.
-     * @param {number} y    Y-axis translation.
-     * 
-     * @returns {Vector2}   translated Vector2.
-     */
-    translated(x, y)
-    {
-        return new Vector2(this.x + x, this.y + y);
-    }
-
-    /**
-     * Translates this Vector2 by x on the X-axis and y on the Y-axis.
-     * 
-     * @param {number} x    X-axis translation.
-     * @param {number} y    Y-axis translation.
-     */
-    translate(x, y)
-    {
-        this.x += x;
-        this.y += y;
-    }
-
-    /**
-     * Returns this Vector2's distance squared to another Vector2.
-     * 
-     * @param {Vector2} v   Vector2 to calculate the distance to.
-     * 
-     * @returns {number}    distance squared between this Vector2 and the provided
-     *                      Vector2. 
-     */
-    distanceSquaredTo(v)
-    {
-        return new Vector2(v.x - this.x, v.y - this.y).length();
-    }
-
-    /**
-     * Returns this Vector2's distance to another Vector2.
-     * 
-     * @param {Vector2} v   Vector2 to calculate the distance to.
-     * 
-     * @returns {number}    distance between this Vector2 and the provided
-     *                      Vector2. 
-     */
-    distance(v)
-    {
-        return sqrt(this.distanceSquaredTo(v));
-    }
-}

+ 0 - 220
pandora/game_objects/2d_objects/AnimatedSprite2D.js

@@ -1,220 +0,0 @@
-/************************************************************************
- * AnimatedSprite2D.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/>.
- *************************************************************************/
-
-/**
- * The {@code AnimatedSprite2D} class represents a GameObject that inherits from
- * Sprite2D and extends its functionality to automatically draw a series of sprites
- * to the screen forming an animation.
- * 
- * ! All GameObjects need to be inside the tree to do anything (can be added as a child
- * ! of another GameObject on the tree or as a root).
- * 
- * @author Pedro Schneider
- * 
- * @class
- */
-class AnimatedSprite2D extends Sprite2D
-{
-    /**
-     * Initializes as AnimatedSprite2D GameObject with the specified parameters.
-     * 
-     * @param {String} name                 name for this AnimatedSprite2D GameObject. 
-     * @param {p5.Image} p5Image            this AnimatedSprite2D's p5.Image to be drawn
-     *                                      to the buffer.
-     * @param {SpriteFrames} spriteFrames   data holding the animation in frames to be
-     *                                      played by this GameObject.
-     * 
-     * @constructor
-     */
-    constructor(name, p5Image, spriteFrames)
-    {
-        super(name, p5Image);
-
-        this.spriteFrames = spriteFrames;
-        this.playing = false;
-        this.frame = 0;
-        this.currentAnimation = 0;
-        this.timeSinceLastFrame = 0;
-    }
-
-    /**
-     * Sets the current SpriteAnimation to be played based on its index on the list of
-     * animations on SpriteFrames. Does nothing if the index is invalid.
-     * 
-     * ! The index refers to the order you added the animations to this AnimatedSprite2D's
-     * ! SpriteFrames, starting at 0.
-     * 
-     * @param {number} idx  index of the SpriteAnimation on SpriteFrames.
-     */
-    setCurrentAnimationByIndex(idx)
-    {
-        if (idx < this.spriteFrames.numAnimations)
-            this.currentAnimation = idx;
-        else this.currentAnimation = null;
-        this.frame = 0;
-        this.timeSinceLastFrame = 0;
-    }
-
-    /**
-     * Sets the current SpriteAnimation to be played based on its name on the list of
-     * animations on SpriteFrames. Does nothing if the name is invalid.
-     * 
-     * @param {String} name name of the SpriteAnimation on SpriteFrames.
-     */
-    setCurrentAnimationByName(name)
-    {
-        this.currentAnimation = this.spriteFrames.getAnimationIndexByName(name);
-        this.frame = 0;
-        this.timeSinceLastFrame = 0;
-    }
-
-    /**
-     * Sets the current SpriteAnimation's time between frames.
-     * 
-     * @param {number} time new time in seconds between frames for the
-     *                      current SpriteAnimation.
-     */
-    setCurrentFrameTime(time)
-    {
-        this.getCurrentAnimation().setFrameTime(time);
-    }
-
-    /**
-     * Sets the current SpriteAnimation's frames per second.
-     * 
-     * @param {number} fps  new frames per second for the current SpriteAnimation.
-     */
-    setCurrentFPS(fps)
-    {
-        this.getCurrentAnimation().setFPS(fps);
-    }
-
-    /**
-     * Returns the SpriteAnimation with the given index on the list os SpriteAnimations on
-     * this AnimatedSprite2D's SpriteFrames.
-     * 
-     * ! The index refers to the order you added the animations to this AnimatedSprite2D's
-     * ! SpriteFrames, starting at 0.
-     * 
-     * @param {number} idx  index of the desired SpriteAnimation on SpriteFrames' list.
-     * 
-     * @returns {SpriteAnimation}   the desired SpriteAnimation based on the given index,
-     *                              or null if the index is invalid.
-     */
-    getAnimationByIndex(idx)
-    {
-        return this.spriteFrames.getAnimationByIndex(idx);
-    }
-
-    /**
-     * Returns the current SpriteAnimation on this AnimatedSprite2D's Sprite Frames.
-     * 
-     * @returns {SpriteAnimation}   the current SpriteAnimation on the SprteFrames.
-     */
-    getCurrentAnimation()
-    {
-        return this.spriteFrames.getAnimationByIndex(this.currentAnimation);
-    }
-
-    /**
-     * Rerturns the p5.Image of the current frame on the current SpriteAnimation.
-     * 
-     * @returns {p5.Image}  image of the current frame. 
-     */
-    getCurrentFrame()
-    {
-        return this.getCurrentAnimation().getFrame(this.frame);
-    }
-
-    /**
-     * Returns the time in seconds between frames of the current SpriteAnimation.
-     * 
-     * @returns {number}    time in seconds between frames of the current SpriteAnimation.
-     */
-    getCurrentFrameTime()
-    {
-        return this.getCurrentAnimation().getFrameTime();
-    }
-
-    /**
-     * Returns the number of frames of the current SpriteAnimation.
-     * 
-     * @returns {number}    number of frames of the current SpriteAnimation.
-     */
-    getCurrentNumFrames()
-    {
-        return this.getCurrentAnimation().getNumFrames();
-    }
-
-    /**
-     * Starts playing the current SpriteAnimation.
-     */
-    play()
-    {
-        this.playing = true;
-    }
-
-    /**
-     * Stops playing the current SpriteAnimation.
-     */
-    stop()
-    {
-        this.playing = false;
-    }
-
-    /**
-     * Rerturns the playing state of the current SpriteAnimation.
-     * 
-     * @returns {boolean}   true if the animation is playing, false if not. 
-     */
-    isPlaying()
-    {
-        return this.playing;
-    }
-
-    /**
-     * Updates the current SpriteAnimation if its playing, and updates this
-     * AnimatedSprite2D's P5Image to the current frame based on the current
-     * SpriteAnimation.
-     * 
-     * @param {number} delta    number of seconds ellapsed since the last frame. 
-     * 
-     * @override
-     */
-    update(delta)
-    {
-        this.udpateGlobalTransform();
-
-        // Forwards the animation.
-        if (this.playing)
-        {
-            this.timeSinceLastFrame += delta;
-            if (this.timeSinceLastFrame >= this.getCurrentFrameTime())
-            {
-                this.frame = (this.frame + 1) % this.getCurrentNumFrames();
-                this.timeSinceLastFrame = 0;
-            }
-        }
-        this.P5Image = this.getCurrentFrame();
-
-        this.updateChildren(delta);
-    }
-}

+ 0 - 169
pandora/game_objects/2d_objects/Area2D.js

@@ -1,169 +0,0 @@
-/************************************************************************
- * Area2D.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/>.
- *************************************************************************/
-
-/**
- * The {@code Area2D} class represents a GameObject that has a shape and can
- * detect the mouse on the secondary buffer.
- * 
- * ! All GameObjects need to be inside the tree to do anything (can be added as a child
- * ! of another GameObject on the tree or as a root).
- * 
- * @author Pedro Schneider
- * 
- * @class
- */
-class Area2D extends Object2D
-{
-    /**
-     * Creates an empty Area2D with the specified parameters.
-     * 
-     * @param {String} name             name for the Area2D GameObject.
-     * @param {SHAPES} shapeType        type of the shape on the Area2D.
-     * @param {Shape} shape             data for the shape of the Area2D.
-     * @param {boolean} listenToMouse   should this Area2D interact with the mouse?
-     *                                  Default is true.
-     * @param {boolean} drawDebug       should the Area2D's shape be drawn to the 
-     *                                  secondary buffer? Default is false.
-     * 
-     * @constructor
-     */
-    constructor(name, shapeType, shape, listenToMouse = true, drawDebug = false)
-    {
-        super(name);
-
-        this.shapeType = shapeType;
-        switch (this.shapeType)
-        {
-            case SHAPES.RECT:
-                this.shapeName = "Rect";
-                break;
-            case SHAPES.ELLIPSE:
-                this.shapeName = "Ellipse";
-                break;
-        }
-        this.shape = shape;
-        this.listenToMouse = listenToMouse;
-        this.drawDebug = drawDebug;
-
-        this.mouseIn = false;
-    }
-
-    /**
-     * Sets wether or not the Area2D's shape should be drawn to the screen.
-     * 
-     * @param {boolean} val new value for drawDebug.
-     */
-    setDrawDebug(val)
-    {
-        this.drawDebug = val;
-    }
-
-    /**
-     * Defines default signals for Area2Ds and serves as the caller to this Area2Ds's
-     * _initSignals() callbacks.
-     * 
-     * @signal mouseEntered emited once every time the mouse enters this Area2D's shape.
-     * @signal mouseExited  emited once every time the mouse exits this Area2D's shape.
-     * 
-     * @override
-     */
-    initSignals()
-    {
-        this.addSignal("mouseEntered");
-        this.addSignal("mouseExited");
-
-        this._initSignals();
-    }
-
-    /**
-     * Checks for the mouse position over this Area2D's shape and recursively calls the _update(delta)
-     * callback for this GameObject and all of it's children.
-     * 
-     * @param {number} delta    number of ellapsed seconds since the last frame.
-     * 
-     * @override
-     */
-    update(delta)
-    {
-        this.udpateGlobalTransform();
-
-        // Checks collision with mouse
-        if (this.listenToMouse)
-        {
-            if (Collisions[this.shapeName].point(this.globalPosition.x, this.globalPosition.y, this.globalRotationDegrees, this.globalScale.x,
-                    this.globalScale.y, this.shape, GameHandler.mouseX, GameHandler.mouseY))
-            {
-                if (!this.mouseIn)
-                    this.emitSignal("mouseEntered");
-                this.mouseIn = true;
-            }
-            else
-            {
-                if (this.mouseIn)
-                    this.emitSignal("mouseExited");
-                this.mouseIn = false;
-            }
-        }
-
-        this.updateChildren(delta);
-    }
-
-    /**
-     * Applies this Object2D's transform before calling this GameObject's _draw() callback
-     * and recursively calls the same callback on all of it's children. Also draws this Area2D's
-     * shape to the secondary buffer if requested.
-     * 
-     * @param {number} delta    number in seconds ellapsed since the last frame.
-     * @param {p5.Graphics} db  secondary buffer to draw to.
-     * 
-     * @override
-     */
-    draw(delta, db)
-    {
-        if (!this.visible) return;
-
-        db.push();
-        this.applyTransform(db);
-
-        // Draw the shape for debug purposes.
-        if (this.drawDebug)
-        {
-            db.push();
-            db.noStroke();
-            db.fill(0, 0, 100, 100);
-            switch (this.shapeType)
-            {
-                case SHAPES.ELLIPSE:
-                    db.ellipseMode(CENTER);
-                    db.ellipse(0, 0, this.shape.rx * 2, this.shape.ry * 2);
-                    break;
-                case SHAPES.RECT:
-                    db.rectMode(CENTER);
-                    db.rect(0, 0, this.shape.w, this.shape.h);
-                    break;
-            }
-            db.pop();
-        }
-
-        this.drawChildren(delta, db);
-        db.pop()
-    }
-}

+ 0 - 229
pandora/game_objects/2d_objects/Object2D.js

@@ -1,229 +0,0 @@
-/************************************************************************
- * Object2D.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/>.
- *************************************************************************/
-
-/**
- * The {@code Object2D} class represents a GameObject that has a transform,
- * comprised of a position, a rotation in degrees and a scale. All parameters
- * of this transform are relative to the parent of this GameObject, if it has one.
- * 
- * ! All GameObjects need to be inside the tree to do anything (can be added as a child
- * ! of another GameObject on the tree or as a root).
- * 
- * @author Pedro Schneider
- * 
- * @class
- */
-class Object2D extends GameObject
-{
-    /**
-     * Initializes an empty Object2D GameObject.
-     * 
-     * @param {String} name name of the Object2D GameObject. 
-     * 
-     * @constructor
-     */
-    constructor(name)
-    {
-        super(name);
-
-        this.position = Vector2.ZERO(); // This Object2D's position on the secondary buffer.
-        this.rotationDegrees = 0; // This Object2D's rotation degrees on the secondary buffer.
-        this.scale = Vector2.ONE(); // This Object2D's scale on the secondary buffer.
-        this.visible = true; // Is this Object2D visible at the moment?
-
-        this.globalPosition = Vector2.ZERO(); // This Object2D's global position on the secondary buffer.
-        this.globalRotationDegrees = 0; // This Object2D's global rotation degrees on the secondary buffer.
-        this.globalScale = Vector2.ONE(); // This Object2D's global scale on the secondary buffer.
-    }
-
-    /**
-     * Sets this Object2D's position.
-     * 
-     * @param {number} x    new position on the x axis for this Object2D. 
-     * @param {number} y    new positoin on the y axis for this Object2D.
-     */
-    setPosition(x, y)
-    {
-        this.position.x = x;
-        this.position.y = y;
-    }
-
-    /**
-     * Sets the visibility flag of this Object2D and all of its children
-     * that have a visibility flag to true.
-     */
-    show()
-    {
-        this.visible = true;
-
-        for (let i = 0; i < this.children.length; i++)
-        {
-            if (!this.children[i].show) continue;
-            this.children[i].show();
-        }
-    }
-
-    /**
-     * Sets the visibility flag of this Object2D and all of its children
-     * that have a visibility flag to false.
-     */
-    hide()
-    {
-        this.visible = false;
-
-        for (let i = 0; i < this.children.length; i++)
-        {
-            if (!this.children[i].hide) continue;
-            this.children[i].hide();
-        }
-    }
-
-    /**
-     * Sets the visibility flag of this Object2D and all of its children that have a visibility
-     * flag to the provided value.
-     * 
-     * @param {boolean} val value to set the flag to.
-     */
-    setVisibility(val)
-    {
-        this.visible = val;
-
-        for (let i = 0; i < this.children.length; i++)
-        {
-            if (!this.children[i].setVisibility) continue;
-            this.children[i].setVisibility(val);
-        }
-    }
-
-    /**
-     * Returns this Object2D's visibility flag.
-     * 
-     * @returns {boolean} true if this Object2D is visible, false if not.
-     */
-    getVisibility()
-    {
-        return this.visible;
-    }
-
-    /**
-     * Translates this Object2D by (x, y).
-     * 
-     * @param {number} x    X-axis translation. 
-     * @param {number} y    Y-axis translation.
-     */
-    translate(x, y)
-    {
-        this.position.x += x;
-        this.position.y += y;
-    }
-
-    /**
-     * Rotates this Object2D by a degrees.
-     * 
-     * @param {number} a    rotation in degrees. 
-     */
-    rotate(a)
-    {
-        this.rotationDegrees += a;
-    }
-
-    /**
-     * Scales this Object2D by (x, y).
-     * 
-     * @param {number} x    X-axis scale.
-     * @param {number} y    Y-axis scale.
-     */
-    addScale(x, y)
-    {
-        this.scale.x *= x;
-        this.scale.y *= y;
-    }
-
-    /**
-     * Updates this Object2D's global transform.
-     * 
-     * ! This method only exists to modularize the code, and should not be used by the user.
-     */
-    udpateGlobalTransform()
-    {
-        if (!this.parented || !(this.parent instanceof Object2D))
-        {
-            this.globalPosition = this.position;
-            this.globalRotationDegrees = this.rotationDegrees;
-            this.globalScale = this.scale;
-        }
-        else
-        {
-            this.globalPosition.x = this.parent.globalPosition.x + this.position.x;
-            this.globalPosition.y = this.parent.globalPosition.y + this.position.y;
-            this.globalRotationDegrees = this.parent.globalRotationDegrees + this.rotationDegrees;
-            this.globalScale.x = this.parent.globalScale.x * this.scale.x;
-            this.globalScale.y = this.parent.globalScale.y * this.scale.y;
-        }
-    }
-
-    /**
-     * Updates this Object2D's global transform and recursively calls the _update(delta)
-     * callback for this GameObject and all of it's children.
-     * 
-     * @param {number} delta    number of ellapsed seconds since the last frame.
-     * 
-     * @override
-     */
-    update(delta)
-    {
-        this.udpateGlobalTransform();
-        this.updateChildren(delta);
-    }
-
-    /**
-     * Apply this Object2D's transform to the secondary buffer.
-     * 
-     * ! This method only exists to modularize the code, and should not be used by the user. 
-     * 
-     * @param {p5.Graphics} db   secondary buffer to draw to. 
-     */
-    applyTransform(db)
-    {
-        db.translate(this.position.x, this.position.y);
-        db.rotate(this.rotationDegrees / 180 * PI);
-        db.scale(this.scale.x, this.scale.y);
-    }
-
-    /**
-     * Applies this Object2D's transform before calling this GameObject's _draw() callback
-     * and recursively calls the same callback on all of it's children. This results in the
-     * appearence of relative position.
-     * 
-     * @param {number} delta    number of seconds ellapsed since the last frame.
-     * @param {p5.Graphics} db  secondary buffer to draw to.
-     * 
-     * @override
-     */
-    draw(delta, db)
-    {
-        if (!this.visible) return;
-        db.push();
-        this.applyTransform(db);
-        this.drawChildren(delta, db);
-        db.pop()
-    }
-}

+ 0 - 69
pandora/game_objects/2d_objects/Sprite2D.js

@@ -1,69 +0,0 @@
-/************************************************************************
- * Sprite2D.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/>.
- *************************************************************************/
-
-/**
- * The {@code Sprite2D} class represents a GameObject that inherits from
- * Object2D and extends its functionality to automatically draw a Sprite on the
- * buffer.
- * 
- * ! All GameObjects need to be inside the tree to do anything (can be added as a child
- * ! of another GameObject on the tree or as a root).
- * 
- * @author Pedro Schneider
- * 
- * @class
- */
-class Sprite2D extends Object2D
-{
-    /**
-     * Initializes a Sprite2D GameObject with the specified parameters.
-     * 
-     * @param {String} name         name for this Sprite2D. 
-     * @param {p5.Image} p5Image    p5.Image to be drawn on the buffer.
-     * 
-     * @constructor
-     */
-    constructor(name, p5Image)
-    {
-        super(name);
-
-        this.P5Image = p5Image; // This Sprite2D p5.Image.
-    }
-
-    /**
-     * Applies this Object2D's transform before calling this GameObject's _draw() callback
-     * and recursively calls the same callback on all of it's children. Also draws an image
-     * on the buffer based on the data passed to this GameObject.
-     * 
-     * @param {number} delta    number in seconds ellapsed since the last frame.
-     * @param {p5.Graphics} db  secondary buffer to draw to.
-     * 
-     * @override
-     */
-    draw(delta, db)
-    {
-        db.push();
-        this.applyTransform(db);
-        db.image(this.P5Image, 0, 0, this.P5Image.width, this.P5Image.height);
-        this.drawChildren(delta, db);
-        db.pop();
-    }
-}

+ 0 - 97
pandora/game_objects/AudioPlayer.js

@@ -1,97 +0,0 @@
-/************************************************************************
- * AudioPlayer.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/>.
- *************************************************************************/
-
-/**
- * The {@code AudioPlayer} class represents a GameObject that can playa p5.Audio
- * loaded from the AssetHandler.
- * 
- * ! All GameObjects need to be inside the tree to do anything (can be added as a child
- * ! of another GameObject on the tree or as a root).
- * 
- * @author Pedro Schneider
- * 
- * @class
- */
-class AudioPlayer extends GameObject
-{
-    /**
-     * Initializes an AudioPlayer GameObject with the given parameters.
-     * 
-     * @param {String} name         name for the AudioPlayer GameObject.
-     * @param {p5.Audio} p5Audio    p5.Audio this AudioPlayer will play from.
-     * 
-     * @constructor
-     */
-    constructor(name, p5Audio = null)
-    {
-        super(name);
-
-        this.p5Audio = p5Audio;
-    }
-
-    /**
-     * Overrides AudioPlayer's p5Audio.
-     * 
-     * @param {p5.Audio} p5Audio    new p5.Audio for this AudioPlayer to play from.
-     */
-    setP5Audio(p5Audio)
-    {
-        if (this.p5Audio) this.p5Audio.stop();
-        this.p5Audio = p5Audio;
-    }
-
-    /**
-     * Returns this AudioPlayer's p5Audio.
-     * 
-     * @returns {p5.Audio}  this AudioPlayer's p5Audio.
-     */
-    getP5Audio()
-    {
-        return this.p5Audio;
-    }
-
-    /**
-     * Starts playing this AudioPlayer's p5Audio.
-     */
-    play()
-    {
-        if (this.p5Audio) this.p5Audio.play();
-    }
-
-    /**
-     * Stops playing this AudioPlayer's p5Audio.
-     */
-    stop()
-    {
-        if (this.p5Audio) this.p5Audio.stop();
-    }
-
-    // TODO: This don't worky, make it worky.
-    // Something to do with new browser audio policy.
-    /**
-     * Sets this AudioPlayer's autoplay falg to true, so it starts whenever
-     * it is ready.
-     */
-    autoplay()
-    {
-        if (this.p5Audio) this.p5Audio.autoplay(true);
-    }
-}

+ 0 - 420
pandora/game_objects/GameObject.js

@@ -1,420 +0,0 @@
-/************************************************************************
- * GameObject.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/>.
- *************************************************************************/
-
-/**
- * The {@code GameObject} class represents a minimal structure for any object in the
- * game. All objects added to the tree, either as a root or a child of an object
- * on the tree must be or inherit from GameObject.
- * 
- * ! All GameObjects need to be inside the tree to do anything (can be added as a child
- * ! of another GameObject on the tree or as a root).
- * 
- * @author Pedro Schneider
- * 
- * @class
- */
-class GameObject
-{
-    /**
-     * Creates an empty GameObject, with default properties.
-     * 
-     * @param {String} name name of the new GameObject.
-     * 
-     * @constructor
-     */
-    constructor(name)
-    {
-        this.id = 0; // Global unique indentifier for the object.
-
-        this.name = name; // Set the name for the object.
-
-        this.children = []; // List of children.
-        this.parented = false; // Does this GameObject have a parent?
-        this.parent = null; // Who is the parent? null if orphan.
-        this.isOnTree = false; // Is this GameObject on the tree?
-        this.isRoot = false; // Is this GameObject a root object?
-
-        this.signals = []; // List of signals.
-        this.initSignals();
-
-        GameHandler.instanceGameObject(this);
-    }
-
-    /**
-     * Returns the list of children of this GameObject.
-     * 
-     * @returns {Array} array containing a reference to all of this GameObject's
-     *                  children.
-     */
-    getChildren()
-    {
-        return this.children;
-    }
-
-    /**
-     * Query for a child of this GameObject with the child's index.
-     * 
-     * ! The index refers to the order you added the children to this
-     * ! GameObject, starting at 0.
-     * 
-     * @param {String} idx  index of the desired child on the GameObject's
-     *                      children list.
-     * 
-     * @returns {GameObject}    a reference to the child with the given index, or null if
-     *                          no child has that index. 
-     */
-    getChildByIndex(idx)
-    {
-        if (idx >= 0 && idx < this.children.length)
-            return this.children[idx];
-        return null;
-    }
-
-    /**
-     * Query for a child of this GameObject with the child's id.
-     * 
-     * @param {String} id  id of the desired child on the GameObject's
-     *                      children list.
-     * 
-     * @returns {GameObject}    a reference to the child with the given id, or null if
-     *                          no child has that id. 
-     */
-    getChildById(id)
-    {
-        for (let i = 0; i < this.children.length; i++)
-        {
-            if (this.children[i].id == id)
-                return this.children[i];
-        }
-        return null;
-    }
-
-    /**
-     * Query for a child of this GameObject with the child's name.
-     * 
-     * @param {String} name name of the desired child.
-     *  
-     * @returns {GameObject}    a reference to the child with the given name, or null
-     *                          if no child has that name. 
-     */
-    getChildByName(name)
-    {
-        for (let i = 0; i < this.children.length; i++)
-            if (this.children[i].name == name) return this.children[i];
-        return null;
-    }
-
-    /**
-     * Get a reference to this GameObject's parent.
-     * 
-     * @returns {GameObject}    a reference to this GameObject's parent if it
-     *                          exists, null if it doesn't.
-     */
-    getParent()
-    {
-        if (!this.parented) return null;
-        return this.parent;
-    }
-
-    /**
-     * Add a new signal to this GameObject.
-     * 
-     * @param {String} name name for the new signal. 
-     */
-    addSignal(name)
-    {
-        this.signals.push(new Signal(name));
-    }
-
-    /**
-     * Connect another GameObject to one of this GameObject's signals.
-     *  
-     * @param {String} signalName   name of the signal to be connected. 
-     * @param {GameObject} target   reference to the GameObject that wants
-     *                              to be connected to this signal.
-     * @param {String} callback     name of the method to be called every
-     *                              time this signal is emited. 
-     */
-    connect(signalName, target, callback)
-    {
-        for (let i = 0; i < this.signals.length; i++)
-        {
-            if (this.signals[i].name == signalName)
-            {
-                this.signals[i].targets.push(target);
-                this.signals[i].callbacks.push(callback);
-                return;
-            }
-        }
-    }
-
-    /**
-     * Emits one of this GameObject's signals.
-     * 
-     * @param {String} signalName   name of the signal to be emited. 
-     * @param  {...any} params      parameters the connected callbacks
-     *                              should receive.
-     */
-    emitSignal(signalName, ...params)
-    {
-        for (let i = 0; i < this.signals.length; i++)
-        {
-            if (this.signals[i].name == signalName)
-            {
-                for (let j = 0; j < this.signals[i].callbacks.length; j++)
-                    this.signals[i].targets[j][this.signals[i].callbacks[j]](...params);
-                return;
-            }
-        }
-    }
-
-    /**
-     * Add the GameObject as a child of this GameObject.
-     * 
-     * @param {GameObject} child    reference to the GameObject to be
-     *                              added as a child. 
-     */
-    addChild(child)
-    {
-        child.parent = this;
-        child.parented = true;
-        this.children.push(child);
-
-        if (this.isOnTree) child.setup();
-    }
-
-    /**
-     * Remove a child of this GameObject by its index. This action does not
-     * delete the child GameObject; if this is the functionality you want, 
-     * freeing a game object from memory automatically removes it from its
-     * parent.
-     * 
-     * ! The index refers to the order you added the children to this
-     * ! GameObject, starting at 0.
-     * 
-     * @param {number} idx  index of the child to be removed.
-     */
-    removeChildByIndex(idx)
-    {
-        if (idx >= 0 && idx < this.children.length)
-            this.children.splice(idx, 1);
-    }
-
-    /**
-     * Remove a child of this GameObject by its id. This action does not
-     * delete the child GameObject; if this is the functionality you want, 
-     * freeing a game object from memory automatically removes it from its
-     * parent.
-     * 
-     * @param {number} id   id of the child to be removed.
-     */
-    removeChildById(id)
-    {
-        for (let i = 0; i < this.children.length; i++)
-        {
-            if (this.children[i].id == id)
-            {
-                this.children.splice(i, 1);
-                return;
-            }
-        }
-    }
-
-    /**
-     * Remove a child of this GameObject by its name. This action does not
-     * delete the child GameObject; if this is the functionality you want, 
-     * freeing a game object from memory automatically removes it from its
-     * parent.
-     * 
-     * @param {String} name name of the child to be removed.
-     */
-    removeChildByName(name)
-    {
-        for (let i = 0; i < this.children.length; i++)
-        {
-            if (this.children[i].name == name)
-            {
-                this.children.splice(i, 1);
-                return;
-            }
-        }
-    }
-
-    /**
-     * De-parents the GameObject from its parent, or removes it from the root of the
-     * tree if orphan, and recursively marks this GameObject's and all of its children's
-     * memory for garbage collection.
-     */
-    free()
-    {
-        if (this.parented)
-            this.getParent().removeChildById(this.id);
-        else if (this.isRoot)
-            GameHandler.removeRootObjectById(this.id);
-
-        this.destroy();
-    }
-
-    /**
-     * Recursively marks this GameObject's and all of its children's
-     * memory for garbage collection.
-     */
-    destroy()
-    {
-        for (let i = 0; i < this.children.length; i++)
-            this.children[i].destroy();
-
-        for (var prop in this)
-            this[prop] = null;
-    }
-
-    /**
-     * Caller for the _initSignals() callback
-     */
-    initSignals()
-    {
-        this._initSignals();
-    }
-
-    /**
-     * Caller for the _setup() callback. Recursively calls itself for all
-     * of this GameObject's children.
-     */
-    setup()
-    {
-        this.isOnTree = true;
-        this._setup();
-        for (let i = 0; i < this.children.length; i++)
-        {
-            this.children[i].setup();
-        }
-    }
-
-    /**
-     * Serves as a caller to this GameObject's _update method and recursively updates all of
-     * this GameObject's children.
-     * 
-     * ! This method only exists to modularize the code, and should not be used by the user. 
-     *
-     * @param {number} delta    ellapsed seconds since the last frame.
-     */
-    updateChildren(delta)
-    {
-        this._update(delta);
-        for (let i = 0; i < this.children.length; i++)
-        {
-            this.children[i].update(delta);
-        }
-    }
-
-    /**
-     * Caller for the _update(delta) callback. Recrusively calls itself for
-     * all of this GameOject's children.
-     * 
-     * @param {number} delta    ellapsed seconds since the last frame. 
-     */
-    update(delta)
-    {
-        this.updateChildren(delta);
-    }
-
-    /**
-     * Caller for the _draw(delta, db) callback. Recursively calls itself for
-     * all of this GameObject's children.
-     * 
-     * ! This method only exists to modularize the code, and should not be used by the user. 
-     * 
-     * @param {number} delta    ellapsed seconds since the last frame. 
-     * @param {p5.Graphics} db  secondary buffer to draw on. 
-     */
-    drawChildren(delta, db)
-    {
-        this._draw(delta, db);
-        for (let i = 0; i < this.children.length; i++)
-            this.children[i].draw(delta, db);
-    }
-
-    /**
-     * Caller for the _draw(delta, db) callback. Recursively calls itself for
-     * all of this GameObject's children.
-     * 
-     * @param {number} delta    ellapsed seconds since the last frame. 
-     * @param {p5.Graphics} db  secondary buffer to draw on. 
-     */
-    draw(delta, db)
-    {
-        this.drawChildren(delta, db);
-    }
-
-    /**
-     * ! This function should be overriden, it provides no default functionality.
-     * This function is called once when the GameObject is created and should declare
-     * any and all signals the user wants for the GameObject.
-     * 
-     * @callback
-     */
-    _initSignals()
-    {
-
-    }
-
-    /**
-     * ! This function should be overriden, it provides no default functionality.
-     * This function is called once when the GameObject is added to the tree (as a child
-     * of another GameObject or as a root).
-     * 
-     * @callback
-     */
-    _setup()
-    {
-
-    }
-
-    /**
-     * ! This function should be overriden, it provides no default functionality.
-     * This function is called once at the start of every frame and should be used for
-     * any logic that doesn't have anything to do with drawing graphics to the screen buffer.
-     * 
-     * @param {number} delta    ellapsed seconds since the last frame. 
-     * 
-     * @callback
-     */
-    _update(delta)
-    {
-
-    }
-
-    /**
-     * ! This function should be overriden, it provides no default functionality.
-     * This function is called once at the start of every frame after all update() calls
-     * have been completed and should be used for any logic that results in something
-     * beeing drawn to the screen buffer.
-     * 
-     * @param {number} delta    ellapsed seconds since the last frame. 
-     * @param {p5.Graphics} db  secondary buffer to draw on. 
-     * 
-     * @callback
-     */
-    _draw(delta, db)
-    {
-
-    }
-}

+ 0 - 158
pandora/game_objects/Timer.js

@@ -1,158 +0,0 @@
-/************************************************************************
- * Timer.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/>.
- *************************************************************************/
-
-/**
- * The {@code Timer} class represents a Timer GameObject with the functionality
- * of emiting a signal after some amount of time passed.
- * 
- * ! All GameObjects need to be inside the tree to do anything (can be added as a child
- * ! of another GameObject on the tree or as a root).
- * 
- * @author Pedro Schneider
- * 
- * @class
- */
-class Timer extends GameObject
-{
-    /**
-     * Initializes a Timer GameObject with the given parameters.
-     * 
-     * @param {String} name         name for this Timer GameObject.
-     * @param {number} duration     duration in seconds of the timer.
-     *                              Default is 1 second.
-     * @param {boolean} autostart   shuold the timer start automaticaly
-     *                              when it enters the tree? Default is false.
-     * @param {boolean} oneShot     should the timer run only once?
-     *                              Default is false.
-     * 
-     * @constructor
-     */
-    constructor(name, duration = 1, autostart = false, oneShot = false)
-    {
-        super(name);
-
-        this.duration = duration;
-        this.timeLeft = this.duration;
-        this.paused = !autostart;
-        this.autostart = autostart;
-        this.oneShot = oneShot;
-    }
-
-    /**
-     * Starts counting the Timer if it is paused, and does nothing if
-     * the Timer is already running.
-     * 
-     * @param {number} timeSec  duration in seconds to override Timer's duration.
-     *                          Defaults to current Timer's duration.
-     */
-    start(timeSec = this.duration)
-    {
-        if (!this.paused) return;
-        this.duration = timeSec;
-        this.paused = false;
-        this.timeLeft = this.duration;
-    }
-
-    /**
-     * Pauses the Timer. Does nothing if already paused.
-     */
-    stop()
-    {
-        this.paused = true;
-    }
-
-    /**
-     * Resumes the Timer. Does nothing if already running.
-     */
-    resume()
-    {
-        this.paused = false;
-    }
-
-    /**
-     * Returns the paused state of the Timer.
-     * 
-     * @returns {boolean} true if the timer is paused, false if not.
-     */
-    isStopped()
-    {
-        return this.paused;
-    }
-
-    /**
-     * This function is called when the timer is done and serves
-     * to change the data of the timer accordingly and emit the
-     * timeout signal.
-     */
-    onFinish()
-    {
-        if (this.oneShot) this.paused = true
-        this.timeLeft = this.duration;
-        this._onFinish();
-        this.emitSignal("timeout");
-    }
-
-    /**
-     * Updates the Timer and calls the onFinish() function if the timer ended.
-     * Also recursively calls the update() function for all of this GameObject's
-     * children.
-     * 
-     * @param {number} delta    time in seconds ellapsed since the last frame. 
-     * 
-     * @override
-     */
-    update(delta)
-    {
-        if (!this.paused)
-        {
-            this.timeLeft -= delta;
-            if (this.timeLeft <= 0) this.onFinish();
-        }
-
-        this.updateChildren(delta);
-    }
-
-    /**
-     * Adds default signals for the Timer GameObject and serves as a caller
-     * to the _initSignals() callback.
-     * 
-     * @signal timeout  emited once every time this timer is done.
-     * 
-     * @override
-     */
-    initSignals()
-    {
-        this.addSignal("timeout");
-        this._initSignals();
-    }
-
-    /**
-     * ! This function should be overriden, it provides no default functionality.
-     * Called once every time the Timer is done and can be used in
-     * objects that inherit from Timer to add functinoality this event.
-     * 
-     * @callback
-     */
-    _onFinish()
-    {
-
-    }
-}

+ 0 - 461
pandora/game_objects/Tween.js

@@ -1,461 +0,0 @@
-/************************************************************************
- * Tween.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/>.
- *************************************************************************/
-
-/**
- * The {@code TweenData} class represents the data that a Tween GameObject needs to
- * interpolate a given property.
- * 
- * ! All GameObjects need to be inside the tree to do anything (can be added as a child
- * ! of another GameObject on the tree or as a root).
- * 
- * @author Pedro Schneider
- * 
- * @class
- */
-class TweenData
-{
-    /**
-     * Creates a TweenData Object with the specified parameters.
-     * 
-     * @param {Object} target                   Object that has the property to be interpolated.
-     * @param {String} property                 name of the property of target to be interpolated.
-     *                                          target[property] should be number, Vector2 or Color. 
-     * @param {PROPERTY_TYPE} propertyType      type of the property to be interpolated. 
-     * @param {number, Vector2, Color} initVal  initial value for the interpolation.
-     *                                          Should be the same type as target[property].
-     * @param {number, Vector2, Color} finalVal final value for the interpolation.
-     *                                          Should be the same type as target[property].
-     * @param {number} duration                 duration in seconds of the interpolation. 
-     * @param {TRANS_TYPE} transType            transition type of the interpolation. 
-     * @param {EASE_TYPE} easeType              easing type of the interpolation.
-     * @param {number} delay                    delay in seconds for the interpolation to start. 
-     * 
-     * @constructor
-     */
-    constructor(target, property, propertyType, initVal, finalVal, duration, transType, easeType, delay)
-    {
-        this.target = target; // Object that has the property to be interpolated.
-        this.property = property; // Name of the property to be interpolated.
-        this.propertyType = propertyType; // Type of the property to be interpolated.
-
-        // Initializes new objects for final value and initial value depending on the type.
-        switch (this.propertyType)
-        {
-            case PROPERTY_TYPE.COLOR:
-                this.initVal = new Color(initVal.r, initVal.g, initVal.b, initVal.a);
-                this.finalVal = new Color(finalVal.r, finalVal.g, finalVal.b, finalVal.a);
-                break;
-            case PROPERTY_TYPE.VECTOR2:
-                this.initVal = new Vector2(initVal.x, initVal.y);
-                this.finalVal = new Vector2(finalVal.x, finalVal.y);
-                break;
-            case PROPERTY_TYPE.NUMBER:
-                this.initVal = initVal;
-                this.finalVal = finalVal;
-                break;
-        }
-
-        this.duration = duration; // Duration in seconds of the interpolation
-        this.transType = transType; // Type of the transition.
-        this.easeType = easeType; // Type of the easing.
-
-        this.t = -delay; // Current time of the interpolation.
-        this.playing = false; // Is the interpolation playing?
-        this.done = false; // Is the interpolation done?
-
-        this.p = []; // List of sub-properties to be interpolated depending on the type.
-        switch (this.propertyType)
-        {
-            case PROPERTY_TYPE.COLOR:
-                this.p.push("r");
-                this.p.push("g");
-                this.p.push("b");
-                break;
-            case PROPERTY_TYPE.VECTOR2:
-                this.p.push("x");
-                this.p.push("y");
-                break;
-            case PROPERTY_TYPE.NUMBER:
-                break;
-        }
-
-        this.trans = ""; // String for the transition type.
-        switch (this.transType)
-        {
-            case TRANS_TYPE.LINEAR:
-                this.trans = "Linear";
-                break;
-            case TRANS_TYPE.QUAD:
-                this.trans = "Quad";
-                break;
-            case TRANS_TYPE.CUBIC:
-                this.trans = "Cubic";
-                break;
-            case TRANS_TYPE.QUART:
-                this.trans = "Quart";
-                break;
-            case TRANS_TYPE.QUINT:
-                this.trans = "Quint";
-                break;
-            case TRANS_TYPE.SINE:
-                this.trans = "Sine";
-                break;
-            case TRANS_TYPE.EXPONENTIAL:
-                this.trans = "Expo";
-                break;
-            case TRANS_TYPE.CIRCULAR:
-                this.trans = "Circ";
-                break;
-            case TRANS_TYPE.ELASTIC:
-                this.trans = "Elastic";
-                break;
-            case TRANS_TYPE.BACK:
-                this.trans = "Back";
-                break;
-            case TRANS_TYPE.BOUNCE:
-                this.trans = "Bounce";
-                break;
-        }
-
-        this.ease = ""; // String for the easing type.
-        if (this.transType == TRANS_TYPE.LINEAR) this.ease = "ease";
-        else
-        {
-            switch (this.easeType)
-            {
-                case EASE_TYPE.IN:
-                    this.ease = "easeIn";
-                    break;
-                case EASE_TYPE.OUT:
-                    this.ease = "easeOut";
-                    break;
-                case EASE_TYPE.IN_OUT:
-                    this.ease = "easeInOut";
-                    break;
-            }
-        }
-    }
-}
-
-/**
- * The {@code Tween} class represents a Tween GameObject that has functionality to
- * interpolate any property of another GameObject if the properties are of the type
- * number, Vector2 or Color.
- * 
- * @author Pedro Schneider
- * 
- * @class
- */
-class Tween extends GameObject
-{
-    /**
-     * Creates an empty Tween GameObject.
-     * 
-     * @param {String} name name of the Tween GameObject. 
-     * 
-     * @constructor
-     */
-    constructor(name)
-    {
-        super(name);
-
-        this.tweenData = [];
-        this.doneTweens = 0;
-        this.done = false;
-    }
-
-    /**
-     * Add a new TweenData Object to this Tween with the necessary information to interpolate
-     * the target's property.
-     * 
-     * @param {Object} target                   Object that has the property to be interpolated.
-     * @param {String} property                 name of the property of target to be interpolated.
-     *                                          target[property] should be number, Vector2 or Color. 
-     * @param {PROPERTY_TYPE} propertyType      type of the property to be interpolated. 
-     * @param {number, Vector2, Color} initVal  initial value for the interpolation.
-     *                                          Should be the same type as target[property].
-     * @param {number, Vector2, Color} finalVal final value for the interpolation.
-     *                                          Should be the same type as target[property].
-     * @param {number} duration                 duration in seconds of the interpolation. 
-     * @param {TRANS_TYPE} transType            transition type of the interpolation.
-     *                                          Default is TRANS_TYPE.LINEAR.
-     * @param {EASE_TYPE} easeType              easing type of the interpolation.
-     *                                          Default is EASY_TYPE.IN_OUT.
-     * @param {number} delay                    delay in seconds for the interpolation to start.
-     *                                          Default is 0. 
-     */
-    interpolateProperty(target, property, propertyType, initVal, finalVal, duration, transType = 1, easeType = 3, delay = 0)
-    {
-        this.done = false; // Are all TweenData on this Tween done?
-
-        // Adding a new TweenData.
-        this.tweenData.push(new TweenData(target, property, propertyType, initVal, finalVal, duration, transType, easeType, delay));
-    }
-
-    /**
-     * Given a TweenData, sets its interpolation's target's property to the appropriate value for
-     * the current time of the interpolation.
-     * 
-     * @param {TweenData} td    reference to the TweenData Object. 
-     */
-    interpolate(td)
-    {
-        if (td.propertyType == PROPERTY_TYPE.NUMBER)
-            td.target[td.property] = Easings[td.trans][td.ease](td.t, td.initVal, td.finalVal - td.initVal, td.duration);
-        else
-        {
-            for (let i = 0; i < td.p.length; i++)
-                td.target[td.property][td.p[i]] = Easings[td.trans][td.ease](td.t, td.initVal[td.p[i]], td.finalVal[td.p[i]] - td.initVal[td.p[i]], td.duration);
-        }
-    }
-
-    /**
-     * Starts interpolating all TweenData Objectcs currently added to this Tween.
-     */
-    startAll()
-    {
-        for (let i = 0; i < this.tweenData.length; i++)
-            this.tweenData[i].playing = true;
-    }
-
-    /**
-     * Starts interpolating a specific TweenData Object based on its index.
-     * 
-     * ! Since TwennData are not GameObjects, this is the only way to query
-     * ! for them. The index refera to the order you added the TweenData to
-     * ! this Tween, starting at 0.
-     * 
-     * @param {number} idx  index of the desired TweenData to start.
-     */
-    startByIndex(idx)
-    {
-        if (idx < 0 && idx >= this.tweenData.length) return;
-        this.tweenData[idx].playing = true;
-    }
-
-    /**
-     * Stops interpolating all TweenData Objects currently added to this Tween.
-     */
-    stopAll()
-    {
-        for (let i = 0; i < this.tweenData.length; i++)
-            this.tweenData[i].playing = false;
-    }
-
-    /**
-     * Stops interpolating a specific TweenData Object based on its index.
-     * 
-     * ! Since TwennData are not GameObjects, this is the only way to query
-     * ! for them. The index refera to the order you added the TweenData to
-     * ! this Tween, starting at 0.
-     * 
-     * @param {number} idx  index of the desired TweenData to stop.
-     */
-    stopByIndex(idx)
-    {
-        if (idx < 0 && idx >= this.tweenData.length) return;
-        this.tweenData[idx].playing = false;
-    }
-
-    /**
-     * Resumes interpolating all TweenData currently added to this Tween.
-     */
-    resumeAll()
-    {
-        for (let i = 0; i < this.tweenData.length; i++)
-            this.tweenData[i].playing = true;
-    }
-
-    /**
-     * Resumes interpolating a specific TweenData Object based on its index.
-     * 
-     * ! Since TwennData are not GameObjects, this is the only way to query
-     * ! for them. The index refera to the order you added the TweenData to
-     * ! this Tween, starting at 0.
-     * 
-     * @param {number} idx  index of the desired TweenData to resume.
-     */
-    resumeByIndex(idx)
-    {
-        if (idx < 0 && idx >= this.tweenData.length) return;
-        this.tweenData[idx].playing = true;
-    }
-
-    /**
-     * Resets all TweenData currently added to this Tween.
-     */
-    resetAll()
-    {
-        this.doneTweens = 0;
-        this.done = false;
-        for (let i = 0; i < this.tweenData.length; i++)
-        {
-            this.tweenData[i].t = 0;
-            this.tweenData[i].done = false;
-        }
-    }
-
-    /**
-     * Resets a specific TweenData Object based on its index.
-     * 
-     * ! Since TwennData are not GameObjects, this is the only way to query
-     * ! for them. The index refera to the order you added the TweenData to
-     * ! this Tween, starting at 0.
-     * 
-     * @param {number} idx  index of the desired TweenData to reset.
-     */
-    resetByIndex(idx)
-    {
-        if (idx < 0 && idx >= this.tweenData.length) return;
-        this.doneTweens--;
-        this.done = false;
-        this.tweenData[idx].t = 0;
-        this.tweenData[idx].done = false;
-    }
-
-    /**
-     * Removes all TweenData currently added to this Tween.
-     */
-    removeAll()
-    {
-        while (this.tweenData.length > 0)
-            this.tweenData.pop();
-    }
-
-    /**
-     * Removes a specific TweenData Object based on its index.
-     * 
-     * ! Since TwennData are not GameObjects, this is the only way to query
-     * ! for them. The index refera to the order you added the TweenData to
-     * ! this Tween, starting at 0.
-     * 
-     * @param {number} idx  index of the desired TweenData to remove.
-     */
-    removeByIndex(idx)
-    {
-        if (idx < 0 && idx >= this.tweenData.length) return;
-        this.tweenData.splice(idx, 1);
-    }
-
-    /**
-     * Sets the current time of all TweenData currently added to this Tween
-     * to the specified time.
-     * 
-     * @param {number} time time in seconds to seek all TweenData on this Tween. 
-     */
-    seekAll(time)
-    {
-        if (time < 0) return;
-        for (let i = 0; i < this.tweenData.length; i++)
-            this.tweenData[i].t = min(time, this.tweenData[i].duration);
-    }
-
-    /**
-     * Sets the current time of a specific TweenData Object, based on its index,
-     * to the specified time. 
-     * 
-     * ! Since TwennData are not GameObjects, this is the only way to query
-     * ! for them. The index refera to the order you added the TweenData to
-     * ! this Tween, starting at 0.
-     * 
-     * @param {number} idx  index of the TweenData to seek to the time.
-     * @param {number} time time in seconds to seek the specified TweenData
-     */
-    seekByIndex(idx, time)
-    {
-        if (idx < 0 && idx >= this.tweenData.length) return;
-        this.tweenData[idx].t = min(time, this.tweenData[idx].duration);
-    }
-
-    /**
-     * Called once every time all TweenData on this Tween are completed.
-     * Emits the tweenDataAllCompleted signal.
-     */
-    allDone()
-    {
-        this.emitSignal("tweenAllCompleted");
-        this.done = true;
-    }
-
-    /**
-     * Adds default signals for the Tween GameObject and serves as a caller
-     * to the _initSignals() callback.
-     * 
-     * @signal tweenAllCompleted    Emited once when all TweenData on this Tween
-     *                              are done.
-     * @signal tweenCompleted       Emited once when one TweenData on this Tween
-     *                              is done. Passes the completed TweenData as a
-     *                              parameter.
-     * @signal tweenStarted         Emited once when one TweenData on this Tween
-     *                              starts. Passes the started TweenData as a 
-     *                              parameter.
-     * 
-     * @override
-     */
-    initSignals()
-    {
-        this.addSignal("tweenAllCompleted");
-        this.addSignal("tweenCompleted");
-        this.addSignal("tweenStarted");
-        this._initSignals();
-    }
-
-    /**
-     * Updates all TweenData added to this Tween and recursively calls the _update(delta)
-     * callback for this GameObject and all of it's children.
-     * 
-     * @param {number} delta    number of ellapsed seconds since the last frame.
-     * 
-     * @override
-     */
-    update(delta)
-    {
-        // Checks if all TweenData are done.
-        if (!this.done && this.doneTweens == this.tweenData.length) this.allDone();
-
-        for (let i = 0; i < this.tweenData.length; i++)
-        {
-            // Ignores TweenData that aren't playing.
-            if (!this.tweenData[i].playing) continue;
-
-            // Interpolates TweenData that are out of the delay.
-            if (this.tweenData[i].t >= 0)
-                this.interpolate(this.tweenData[i]);
-
-            // Checks if the TweenData just went out of the delay (just started).
-            if (this.tweenData[i].t <= 0 && this.tweenData[i].t + delta >= 0)
-                this.emitSignal("tweenStarted", this.tweenData[i]);
-
-            // Updates TweenData's current time.
-            this.tweenData[i].t = min(this.tweenData[i].t + delta, this.tweenData[i].duration);
-
-            // Checks if the TweenData is done.
-            if (!this.tweenData[i].done && this.tweenData[i].t == this.tweenData[i].duration)
-            {
-                this.emitSignal("tweenDone", this.tweenData[i]);
-                this.tweenData[i].done = true;
-                this.doneTweens += 1;
-            }
-        }
-
-        this.updateChildren(delta);
-    }
-}

+ 0 - 66
pandora/game_objects/ui_objects/Button.js

@@ -1,66 +0,0 @@
-/************************************************************************
- * Button.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/>.
- *************************************************************************/
-
-/**
- * The {@code Button} class represents an UIObject that holds and HTML button.
- * 
- * ! All GameObjects need to be inside the tree to do anything (can be added as a child
- * ! of another GameObject on the tree or as a root).
- * 
- * @author Pedro Schneider
- * 
- * @class
- */
-class Button extends UIObject
-{
-    /**
-     * Initializes an empty Button GameObject.
-     * 
-     * @param {String} name 
-     * @param {String} label 
-     * 
-     * @constructor
-     */
-    constructor(name, label = "Button")
-    {
-        super(name);
-
-        this.P5Element = createButton(); // This Button's HTML button.
-        this.label = label; // This Button's label
-        this.P5Element.html(label); // Set the label to the inner HTML of the button.
-        this.setPosition(0, 0); // Set the position of the Button on the secondary buffer.
-
-        this.setStyle(STYLE.DEFAULT_STYLE); // Set the default style of the UIObject.
-
-        this.connectCallbacks(); // Connect the events of the p5.Element.
-    }
-
-    /**
-     * Sets the label on this UIObject's button.
-     * 
-     * @param {String} label    new label for the button.
-     */
-    setLabel(label)
-    {
-        this.label = label;
-        this.P5Element.html(label);
-    }
-}

+ 0 - 142
pandora/game_objects/ui_objects/CheckBox.js

@@ -1,142 +0,0 @@
-/************************************************************************
- * CheckBox.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/>.
- *************************************************************************/
-
-/**
- * The {@code CheckBox} class represents an UIObject that holds and HTML checkbox.
- * 
- * ! All GameObjects need to be inside the tree to do anything (can be added as a child
- * ! of another GameObject on the tree or as a root).
- * 
- * @author Pedro Schneider
- * 
- * @class
- */
-class CheckBox extends UIObject
-{
-    /**
-     * Initializes an empty CheckBox GameObject.
-     * 
-     * @param {String} name     name for the CheckBox GameObject. 
-     * @param {String} label    label for the CheckBox GameObject.
-     * @param {boolean} val     initial value for the CheckBox. True
-     *                          for checked, false for unchecked.
-     * 
-     * @constructor
-     */
-    constructor(name, label = "checkbox", val = false)
-    {
-        super(name);
-
-        this.label = label; // This Button's HTML checkbox
-        this.P5Element = createCheckbox(label, val); // This Button's label
-        this.setPosition(0, 0); // Set the position of the Button on the secondary buffer.
-
-        this.setStyle(STYLE.DEFAULT_STYLE); // Set the default style of the UIObject.
-
-        this.connectCallbacks(); // Connect the events of the p5.Element.
-        this.P5Element.changed(this.onChanged); // Connect the extra event checkboxes have
-    }
-
-    /**
-     * Sets the label on this UIObject's checkbox.
-     * 
-     * @param {String} label    new label for the checkbox.
-     */
-    setLabel(label)
-    {
-        this.label = label;
-        this.P5Element.html(label);
-    }
-
-    /**
-     * Defines default signals for UIObjects and serves as the caller to this UIObject's
-     * _initSignals() callbacks. Also adds the extra onChaged signal for CheckBoxes.
-     * 
-     * @signal mousePressed     emited once every time a mouse button is pressed over this
-     *                          UIObject.
-     * @signal doubleClicked    emited once every time a mouse button is pressed twice over
-     *                          this UIObject.
-     * @signal mouseWheel       emited once everty time a mouse wheel is scrolled over this
-     *                          UIObject. Passes one argument {event} that holds the deltaY
-     *                          property, that holds a number based on how much was vertically
-     *                          scrolled (up is positive) and the deltaX property, that holds a
-     *                          number based on how much was horizontaly scrolled (right is positive).
-     * @signal mouseReleased    emited once every time a mouse button is released over this
-     *                          UIObject.
-     * @signal mouseClicked     emited once every time a mouse button is pressed and released
-     *                          over this UIObject.
-     * @signal mouseMoved       emited once every time a mouse moves over this UIObject.
-     * @signal mouseOver        emited once every time a mouse moves onto this UIObject.
-     * @signal mouseOut         emited once every time a mouse moves out of this UIObject.
-     * @signal touchStarted     emited once every time a touch is regiestered over this UIObject.
-     * @signal touchMoved       emited once every time a touch move is regiestered over this
-     *                          UIObject.
-     * @signal touchEnded       emited once every time a touch is regiestered over this UIObject.
-     * @signal dragOver         emited once every time a file is dragged over this UIObject.
-     * @signal dragLeave        emited once every time a dragged file leaves this UIObject's area.
-     * 
-     * @signal changed          emited once every time this UIObject's checkbox's value is changed.
-     * 
-     * @override
-     */
-    initSignals()
-    {
-        this.addSignal("mousePressed");
-        this.addSignal("doubleClicked");
-        this.addSignal("mouseWheel");
-        this.addSignal("mouseReleased");
-        this.addSignal("mouseClicked");
-        this.addSignal("mouseMoved");
-        this.addSignal("mouseOver");
-        this.addSignal("mouseOut");
-        this.addSignal("touchStarted");
-        this.addSignal("touchMoved");
-        this.addSignal("touchEnded");
-        this.addSignal("dragOver");
-        this.addSignal("dragLeave");
-
-        this.addSignal("changed");
-        this._initSignals();
-    }
-
-    /**
-     * Called once every time this UIObject's checkbox's value is changed.
-     * Connected to the changed event from this UIObject's p5.Element.
-     * Serves as an emiter to the changed signal and calls the _onChanged()
-     * callback.
-     */
-    onChanged()
-    {
-        this.pandoraObject.emitSignal("changed");
-        this.pandoraObject._onChanged();
-    }
-
-    /**
-     * ! This function should be overriden, it provides no default functionality.
-     * Called once every time this UIObject's checkbox's value is changed.
-     * 
-     * @callback
-     */
-    _onChanged()
-    {
-        console.log(this.P5Element.checked());
-    }
-}

+ 0 - 73
pandora/game_objects/ui_objects/ColorPicker.js

@@ -1,73 +0,0 @@
-/************************************************************************
- * ColorPicker.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/>.
- *************************************************************************/
-
-/**
- * The {@code ColorPicker} class represents an UIObject that holds and HTML color picker.
- * 
- * ! All GameObjects need to be inside the tree to do anything (can be added as a child
- * ! of another GameObject on the tree or as a root).
- * 
- * @author Pedro Schneider
- * 
- * @class
- */
-class ColorPicker extends UIObject
-{
-    /**
-     * Initializes an empty ColorPicker with the specified parameters.
-     * 
-     * @param {String} name             name for the ColorPicker GameObject.
-     * @param {p5.Color, String} color  default color for the ColorPicker
-     * 
-     * @constructor
-     */
-    constructor(name, color = "#FFFFFF")
-    {
-        super(name);
-
-        this.P5Element = createColorPicker(color); // This Button's HTML color picker.
-        this.setPosition(0, 0); // Set the position of the ColorPicker on the secondary buffer.
-
-        this.setStyle(STYLE.DEFAULT_STYLE); // Set the default style of the UIObject.
-
-        this.connectCallbacks(); // Connect the events of the p5.Element.
-    }
-
-    /**
-     * Sets the color of this ColorPicker UIObject.
-     * 
-     * @param {p5.Color, String} col    new color for this ColorPicker.
-     */
-    setColor(col)
-    {
-        this.P5Element.color(col);
-    }
-
-    /**
-     * Returns this ColorPicker's color.
-     * 
-     * @returns {p5.Color}  this ColorPicker's color.
-     */
-    getColor()
-    {
-        return this.P5Element.color();
-    }
-}

+ 0 - 130
pandora/game_objects/ui_objects/Input.js

@@ -1,130 +0,0 @@
-/************************************************************************
- * Input.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/>.
- *************************************************************************/
-
-/**
- * The {@code Input} class represents an UIObject that holds and HTML input box.
- * 
- * ! All GameObjects need to be inside the tree to do anything (can be added as a child
- * ! of another GameObject on the tree or as a root).
- * 
- * @author Pedro Schneider
- * 
- * @class
- */
-class Input extends UIObject
-{
-    /**
-     * Initializes an empty Input with the given parameters.
-     * 
-     * @param {String} name     name for the Input GameObject.
-     * @param {String} value    default message inside the input box.
-     * @param {String} type     type of the input box (e.g: "text", "password"). 
-     * 
-     * @constructor
-     */
-    constructor(name, value = "", type = "text")
-    {
-        super(name);
-
-        this.P5Element = createInput(value, type); // This Button's HTML input.
-        this.setPosition(0, 0); // Set the position of the Input on the secondary buffer.
-        this.setSize(200, 30); // Set the size of the Input on the secondary buffer.
-
-        this.setStyle(STYLE.DEFAULT_STYLE); // Set the default style of the UIObject.
-
-        this.connectCallbacks(); // Connect events of the p5.Element.
-        this.P5Element.input(this.onInput); // Connect the extra event inputs have.
-    }
-
-    /**
-     * Defines default signals for UIObjects and serves as the caller to this UIObject's
-     * _initSignals() callbacks. Also adds the extra onChaged signal for CheckBoxes.
-     * 
-     * @signal mousePressed     emited once every time a mouse button is pressed over this
-     *                          UIObject.
-     * @signal doubleClicked    emited once every time a mouse button is pressed twice over
-     *                          this UIObject.
-     * @signal mouseWheel       emited once everty time a mouse wheel is scrolled over this
-     *                          UIObject. Passes one argument {event} that holds the deltaY
-     *                          property, that holds a number based on how much was vertically
-     *                          scrolled (up is positive) and the deltaX property, that holds a
-     *                          number based on how much was horizontaly scrolled (right is positive).
-     * @signal mouseReleased    emited once every time a mouse button is released over this
-     *                          UIObject.
-     * @signal mouseClicked     emited once every time a mouse button is pressed and released
-     *                          over this UIObject.
-     * @signal mouseMoved       emited once every time a mouse moves over this UIObject.
-     * @signal mouseOver        emited once every time a mouse moves onto this UIObject.
-     * @signal mouseOut         emited once every time a mouse moves out of this UIObject.
-     * @signal touchStarted     emited once every time a touch is regiestered over this UIObject.
-     * @signal touchMoved       emited once every time a touch move is regiestered over this
-     *                          UIObject.
-     * @signal touchEnded       emited once every time a touch is regiestered over this UIObject.
-     * @signal dragOver         emited once every time a file is dragged over this UIObject.
-     * @signal dragLeave        emited once every time a dragged file leaves this UIObject's area.
-     * 
-     * @signal input            emited once every time and input is dettected.
-     * 
-     * @override
-     */
-    initSignals()
-    {
-        this.addSignal("mousePressed");
-        this.addSignal("doubleClicked");
-        this.addSignal("mouseWheel");
-        this.addSignal("mouseReleased");
-        this.addSignal("mouseClicked");
-        this.addSignal("mouseMoved");
-        this.addSignal("mouseOver");
-        this.addSignal("mouseOut");
-        this.addSignal("touchStarted");
-        this.addSignal("touchMoved");
-        this.addSignal("touchEnded");
-        this.addSignal("dragOver");
-        this.addSignal("dragLeave");
-
-        this.addSignal("input");
-        this._initSignals();
-    }
-
-    /**
-     * Called once everty this this UIObject's input is triggered i.e typing.
-     * Connectec to the input event from this UIObject's p5.Element.
-     * Serves as an emitter to the input signal and calls the _onInput()
-     * callback.
-     */
-    onInput()
-    {
-        this.pandoraObject.emitSignal("input");
-        this.pandoraObject._onInput();
-    }
-
-    /**
-     * ! This function should be overriden, it provides no default functionality.
-     * Called once everty this this UIObject's input is triggered i.e typing.
-     * 
-     * @callback
-     */
-    _onInput()
-    {
-
-    }
-}

+ 0 - 76
pandora/game_objects/ui_objects/Label.js

@@ -1,76 +0,0 @@
-/************************************************************************
- * Label.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/>.
- *************************************************************************/
-
-/**
- * The {@code Lagel} class represents an UIObject that holds and HTML label.
- * 
- * ! All GameObjects need to be inside the tree to do anything (can be added as a child
- * ! of another GameObject on the tree or as a root).
- * 
- * @author Pedro Schneider
- * 
- * @class
- */
-class Label extends UIObject
-{
-    /**
-     * Initializes and empty Label with the specified parameters.
-     * 
-     * @param {String} name name for the Label GameObject. 
-     * @param {String} text inner HTML text of the label.
-     * 
-     * @constructor
-     */
-    constructor(name, text = "Label")
-    {
-        super(name);
-
-        this.text = text; // This Label's inner HTML text.
-        this.P5Element = createDiv(text); // This Label's HTML label.
-        this.setPosition(0, 0); // Set the position of the Label on the secondary buffer.
-        this.setSize(200, 50); // Set the size of the Label on the secondary buffer.
-
-        this.setStyle(STYLE.DEFAULT_STYLE); // Set the default style of the UIObject.
-
-        this.connectCallbacks(); // Connect events of the p5.Element.
-    }
-
-    /**
-     * Sets the text inside this Label's HTML label.
-     * 
-     * @param {String} t    new text for the label.
-     */
-    setText(t)
-    {
-        this.P5Element.html(t);
-        this.text = t;
-    }
-
-    /**
-     * Returns this Label's HTML label's text.
-     * 
-     * @returns {String}    HTML label's text.
-     */
-    getText()
-    {
-        return this.text;
-    }
-}

+ 0 - 195
pandora/game_objects/ui_objects/Radio.js

@@ -1,195 +0,0 @@
-/************************************************************************
- * Radio.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/>.
- *************************************************************************/
-
-/**
- * The {@code Radio} class represents an UIObject that holds and HTML radio button.
- * 
- * ! All GameObjects need to be inside the tree to do anything (can be added as a child
- * ! of another GameObject on the tree or as a root).
- * 
- * @author Pedro Schneider
- * 
- * @class
- */
-class Radio extends UIObject
-{
-    /**
-     * Initializes an empty Radio.
-     * 
-     * @param {String} name name for the Radio GameObject. 
-     * 
-     * @constructor
-     */
-    constructor(name)
-    {
-        super(name);
-
-        this.P5Element = createRadio(); // This Radio's HTML radio.
-        this.setPosition(10, 10); // Set this position of the Radio on the secondary buffer.
-        this.multiLine = false; // Should the different radio buttons be shown on separate lines?
-
-        this.setStyle(STYLE.DEFAULT_STYLE); // Set the default style of the UIObject.
-
-        this.connectCallbacks(); // Connect events of the p5.Element.
-        this.P5Element.changed(this.onChanged); // Connect the extra event radios have.
-    }
-
-    /**
-     * Sets the selected option on this Radio's HTML radio button based on its value.
-     * 
-     * @param {String} value    value of the radio button to be selected.
-     */
-    setSelected(value)
-    {
-        this.P5Element.selected(value);
-    }
-
-    /**
-     * Returns the value of the selected option from this Radio's HTML radio button.
-     * 
-     * @returns {String}    the value of the selected option.
-     */
-    getSelected()
-    {
-        return this.P5Element.selected();
-    }
-
-    /**
-     * Inserts a new option on this Radio's HTML radio button with the given value.
-     * 
-     * @param {String} value    value for the new option.
-     */
-    addOption(value)
-    {
-        this.P5Element.option(value);
-
-        if (this.multiLine) this.makeMultiline();
-    }
-
-
-    // TODO make this work question mark?
-    // removeOption(value)
-    // {
-    //     this.P5Element.remove(value);
-    // }
-
-    /**
-     * This fucntion creates separete HTML divs for each option on this Radio's HTML radio button ]
-     * in order to make them appear on different lines.
-     */
-    makeMultiline()
-    {
-        this.multiLine = true;
-        const inputs = selectAll('input', this.P5Element),
-            labels = selectAll('label', this.P5Element),
-            len = inputs.length;
-
-        for (let i = 0; i < len; ++i)
-            createDiv().parent(this.P5Element).child(inputs[i]).child(labels[i]);
-
-        this.fixRadioDivElement();
-    }
-
-    /**
-     * Fixes de div elements after the call to makeMultiLine().
-     */
-    fixRadioDivElement()
-    {
-        this.P5Element._getInputChildrenArray = function()
-        {
-            return this.elt.getElementsByTagName('input');
-        }
-    }
-
-    /**
-     * Defines default signals for UIObjects and serves as the caller to this UIObject's
-     * _initSignals() callbacks. Also adds the extra onChaged signal for CheckBoxes.
-     * 
-     * @signal mousePressed     emited once every time a mouse button is pressed over this
-     *                          UIObject.
-     * @signal doubleClicked    emited once every time a mouse button is pressed twice over
-     *                          this UIObject.
-     * @signal mouseWheel       emited once everty time a mouse wheel is scrolled over this
-     *                          UIObject. Passes one argument {event} that holds the deltaY
-     *                          property, that holds a number based on how much was vertically
-     *                          scrolled (up is positive) and the deltaX property, that holds a
-     *                          number based on how much was horizontaly scrolled (right is positive).
-     * @signal mouseReleased    emited once every time a mouse button is released over this
-     *                          UIObject.
-     * @signal mouseClicked     emited once every time a mouse button is pressed and released
-     *                          over this UIObject.
-     * @signal mouseMoved       emited once every time a mouse moves over this UIObject.
-     * @signal mouseOver        emited once every time a mouse moves onto this UIObject.
-     * @signal mouseOut         emited once every time a mouse moves out of this UIObject.
-     * @signal touchStarted     emited once every time a touch is regiestered over this UIObject.
-     * @signal touchMoved       emited once every time a touch move is regiestered over this
-     *                          UIObject.
-     * @signal touchEnded       emited once every time a touch is regiestered over this UIObject.
-     * @signal dragOver         emited once every time a file is dragged over this UIObject.
-     * @signal dragLeave        emited once every time a dragged file leaves this UIObject's area.
-     * 
-     * @signal changed          emited once every time this UIObject's radio button's value is changed.
-     * 
-     * @override
-     */
-    initSignals()
-    {
-        this.addSignal("mousePressed");
-        this.addSignal("doubleClicked");
-        this.addSignal("mouseWheel");
-        this.addSignal("mouseReleased");
-        this.addSignal("mouseClicked");
-        this.addSignal("mouseMoved");
-        this.addSignal("mouseOver");
-        this.addSignal("mouseOut");
-        this.addSignal("touchStarted");
-        this.addSignal("touchMoved");
-        this.addSignal("touchEnded");
-        this.addSignal("dragOver");
-        this.addSignal("dragLeave");
-
-        this.emitSignal("changed");
-        this._initSignals();
-    }
-
-    /**
-     * Called once every time this UIObject's radio buttons's value is changed.
-     * Connected to the changed event from this UIObject's p5.Element.
-     * Serves as an emiter to the changed signal and calls the _onChanged()
-     * callback.
-     */
-    onChanged()
-    {
-        this.pandoraObject.emitSignal("changed");
-        this.pandoraObject._onChanged();
-    }
-
-    /**
-     * ! This function should be overriden, it provides no default functionality.
-     * Called once every time this UIObject's radio button's value is changed.
-     * 
-     * @callback
-     */
-    _onChanged()
-    {
-        console.log(this.getSelected());
-    }
-}

+ 0 - 170
pandora/game_objects/ui_objects/Select.js

@@ -1,170 +0,0 @@
-/************************************************************************
- * Select.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/>.
- *************************************************************************/
-
-/**
- * The {@code Select} class represents an UIObject that holds and HTML select.
- * 
- * ! All GameObjects need to be inside the tree to do anything (can be added as a child
- * ! of another GameObject on the tree or as a root).
- * 
- * @author Pedro Schneider
- * 
- * @class
- */
-class Select extends UIObject
-{
-    /**
-     * Intializes an empty Select.
-     * 
-     * @param {String} name name for the Select GameObject.
-     * 
-     * @constructor
-     */
-    constructor(name)
-    {
-        super(name);
-
-        this.P5Element = createSelect(); // This Select's HTML select.
-        this.setPosition(0, 0); // Set this Select's position on the secondary buffer.
-        this.setSize(100, 20); // Set this Select's size on the secondary buffer.
-
-        this.setStyle(STYLE.DEFAULT_STYLE); // Set this UIObject's default style.
-
-        this.connectCallbacks(); // Connect the events of the p5.Element.
-        this.P5Element.changed(this.onChanged); // Connect the extra event selects have.
-    }
-
-    /**
-     * Set this Select's selected option based on the option's value.
-     * 
-     * @param {String} value    value of the option to be selected.
-     */
-    setSelected(value)
-    {
-        this.P5Element.selected(value);
-    }
-
-    /**
-     * Returns the selecte option's value.
-     * 
-     * @returns {String}
-     */
-    getSelected()
-    {
-        return this.P5Element.selected();
-    }
-
-    /**
-     * Add a new option to this Select's HTML select with the given value.
-     * 
-     * @param {String} value    value for the new option.
-     */
-    addOption(value)
-    {
-        this.P5Element.option(value);
-    }
-
-    // TODO confirm if disable methods really dont exist or if something is broken.
-
-    // disableAll()
-    // {
-    //     this.P5Element.disable();
-    // }
-
-    // disableOption(value)
-    // {
-    //     this.P5Element.disable(value);
-    // }
-
-    /**
-     * Defines default signals for UIObjects and serves as the caller to this UIObject's
-     * _initSignals() callbacks. Also adds the extra onChaged signal for CheckBoxes.
-     * 
-     * @signal mousePressed     emited once every time a mouse button is pressed over this
-     *                          UIObject.
-     * @signal doubleClicked    emited once every time a mouse button is pressed twice over
-     *                          this UIObject.
-     * @signal mouseWheel       emited once everty time a mouse wheel is scrolled over this
-     *                          UIObject. Passes one argument {event} that holds the deltaY
-     *                          property, that holds a number based on how much was vertically
-     *                          scrolled (up is positive) and the deltaX property, that holds a
-     *                          number based on how much was horizontaly scrolled (right is positive).
-     * @signal mouseReleased    emited once every time a mouse button is released over this
-     *                          UIObject.
-     * @signal mouseClicked     emited once every time a mouse button is pressed and released
-     *                          over this UIObject.
-     * @signal mouseMoved       emited once every time a mouse moves over this UIObject.
-     * @signal mouseOver        emited once every time a mouse moves onto this UIObject.
-     * @signal mouseOut         emited once every time a mouse moves out of this UIObject.
-     * @signal touchStarted     emited once every time a touch is regiestered over this UIObject.
-     * @signal touchMoved       emited once every time a touch move is regiestered over this
-     *                          UIObject.
-     * @signal touchEnded       emited once every time a touch is regiestered over this UIObject.
-     * @signal dragOver         emited once every time a file is dragged over this UIObject.
-     * @signal dragLeave        emited once every time a dragged file leaves this UIObject's area.
-     * 
-     * @signal changed          emited once every time this UIObject's select's value is changed.
-     * 
-     * @override
-     */
-    initSignals()
-    {
-        this.addSignal("mousePressed");
-        this.addSignal("doubleClicked");
-        this.addSignal("mouseWheel");
-        this.addSignal("mouseReleased");
-        this.addSignal("mouseClicked");
-        this.addSignal("mouseMoved");
-        this.addSignal("mouseOver");
-        this.addSignal("mouseOut");
-        this.addSignal("touchStarted");
-        this.addSignal("touchMoved");
-        this.addSignal("touchEnded");
-        this.addSignal("dragOver");
-        this.addSignal("dragLeave");
-
-        this.addSignal("changed");
-        this._initSignals();
-    }
-
-    /**
-     * Called once every time this UIObject's select's value is changed.
-     * Connected to the changed event from this UIObject's p5.Element.
-     * Serves as an emiter to the changed signal and calls the _onChanged()
-     * callback.
-     */
-    onChanged()
-    {
-        this.pandoraObject.emitSignal("changed");
-        this.pandoraObject._onChanged();
-    }
-
-    /**
-     * ! This function should be overriden, it provides no default functionality.
-     * Called once every time this UIObject's select's value is changed.
-     * 
-     * @callback
-     */
-    _onChanged()
-    {
-
-    }
-}

+ 0 - 132
pandora/game_objects/ui_objects/Slider.js

@@ -1,132 +0,0 @@
-/************************************************************************
- * Slider.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/>.
- *************************************************************************/
-
-/**
- * The {@code Slider} class represents an UIObject that holds and HTML slider.
- * 
- * ! All GameObjects need to be inside the tree to do anything (can be added as a child
- * ! of another GameObject on the tree or as a root).
- * 
- * @author Pedro Schneider
- * 
- * @class
- */
-class Slider extends UIObject
-{
-    /**
-     * Initializes a Slider with the specified parameters.
-     * 
-     * @param {String} name     name for the Slider GameObject. 
-     * @param {number} min      minimum value on the slider.
-     * @param {number} max      maximum value on the slider.
-     * @param {number} value    initial value for the slider.
-     * @param {number} step     step value for the slider.
-     * 
-     * @constructor
-     */
-    constructor(name, min = 0, max = 100, value = 0, step = 0)
-    {
-        super(name);
-
-        this.P5Element = createSlider(min, max, value, step); // This Slider's HTML slider.
-        this.setPosition(0, 0); // Set this Slider's position on the secondary buffer.
-        this.setSize(200, 25); // Set this Slider's size on the secondary buffer.
-
-        this.setStyle(STYLE.DEFAULT_STYLE); // Set this UIObject's default style.
-
-        this.connectCallbacks(); // Connect the events of the p5.Element.
-        this.P5Element.changed(this.onChanged); // Connect the extra event sliders have.
-    }
-
-    /**
-     * Defines default signals for UIObjects and serves as the caller to this UIObject's
-     * _initSignals() callbacks. Also adds the extra onChaged signal for CheckBoxes.
-     * 
-     * @signal mousePressed     emited once every time a mouse button is pressed over this
-     *                          UIObject.
-     * @signal doubleClicked    emited once every time a mouse button is pressed twice over
-     *                          this UIObject.
-     * @signal mouseWheel       emited once everty time a mouse wheel is scrolled over this
-     *                          UIObject. Passes one argument {event} that holds the deltaY
-     *                          property, that holds a number based on how much was vertically
-     *                          scrolled (up is positive) and the deltaX property, that holds a
-     *                          number based on how much was horizontaly scrolled (right is positive).
-     * @signal mouseReleased    emited once every time a mouse button is released over this
-     *                          UIObject.
-     * @signal mouseClicked     emited once every time a mouse button is pressed and released
-     *                          over this UIObject.
-     * @signal mouseMoved       emited once every time a mouse moves over this UIObject.
-     * @signal mouseOver        emited once every time a mouse moves onto this UIObject.
-     * @signal mouseOut         emited once every time a mouse moves out of this UIObject.
-     * @signal touchStarted     emited once every time a touch is regiestered over this UIObject.
-     * @signal touchMoved       emited once every time a touch move is regiestered over this
-     *                          UIObject.
-     * @signal touchEnded       emited once every time a touch is regiestered over this UIObject.
-     * @signal dragOver         emited once every time a file is dragged over this UIObject.
-     * @signal dragLeave        emited once every time a dragged file leaves this UIObject's area.
-     * 
-     * @signal changed          emited once every time this UIObject's slider's value is changed.
-     * 
-     * @override
-     */
-    initSignals()
-    {
-        this.addSignal("mousePressed");
-        this.addSignal("doubleClicked");
-        this.addSignal("mouseWheel");
-        this.addSignal("mouseReleased");
-        this.addSignal("mouseClicked");
-        this.addSignal("mouseMoved");
-        this.addSignal("mouseOver");
-        this.addSignal("mouseOut");
-        this.addSignal("touchStarted");
-        this.addSignal("touchMoved");
-        this.addSignal("touchEnded");
-        this.addSignal("dragOver");
-        this.addSignal("dragLeave");
-
-        this.addSignal("changed");
-        this._initSignals();
-    }
-
-    /**
-     * Called once every time this UIObject's slider's value is changed.
-     * Connected to the changed event from this UIObject's p5.Element.
-     * Serves as an emiter to the changed signal and calls the _onChanged()
-     * callback.
-     */
-    onChanged()
-    {
-        this.pandoraObject.emitSignal("changed");
-        this.pandoraObject._onChanged();
-    }
-
-    /**
-     * ! This function should be overriden, it provides no default functionality.
-     * Called once every time this UIObject's slider's value is changed.
-     * 
-     * @callback
-     */
-    _onChanged()
-    {
-
-    }
-}

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

@@ -1,648 +0,0 @@
-/************************************************************************
- * UIObject.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/>.
- *************************************************************************/
-
-/**
- * The {@code UIObject} class represents a minimal structure for any GameObject that
- * hold an HTML interface element.
- * 
- * ! All GameObjects need to be inside the tree to do anything (can be added as a child
- * ! of another GameObject on the tree or as a root).
- * 
- * @author Pedro Schneider
- * 
- * @class
- */
-class UIObject extends GameObject
-{
-    /**
-     * Initializes an empty UIObject.
-     * 
-     * @param {String} name name for this UIObject. 
-     * 
-     * @constructor
-     */
-    constructor(name)
-    {
-        super(name);
-
-        this.P5Element = null; // This UIOBject's p5.Element (that holds an HTML element).
-        this.visible = true; // Is this UIObject visible at the moment?
-        this.position = new Vector2(0, 0); // This UIObject's position on the secondary buffer.
-        this.size = new Vector2(300, 100); // The UIObject's size on the secondary buffer.
-        this.fontSize = STYLE.DEFAULT_FONT_SIZE; // This UIObject's font style.
-    }
-
-    /**
-     * Connects this UIObject's p5.Element's events to this GameObject's appropriate
-     * methods.
-     */
-    connectCallbacks()
-    {
-        this.P5Element.mousePressed(this.onMousePressed);
-        this.P5Element.doubleClicked(this.onDoubleClicked);
-        this.P5Element.mouseWheel(this.onMouseWheel);
-        this.P5Element.mouseReleased(this.onMouseReleased);
-        this.P5Element.mouseClicked(this.onMouseClicked);
-        this.P5Element.mouseMoved(this.onMouseMoved);
-        this.P5Element.mouseOver(this.onMouseOver);
-        this.P5Element.mouseOut(this.onMouseOut);
-        this.P5Element.touchStarted(this.onTouchStarted);
-        this.P5Element.touchMoved(this.onTouchMoved);
-        this.P5Element.touchEnded(this.onTouchEnded);
-        this.P5Element.dragOver(this.onDragOver);
-        this.P5Element.dragLeave(this.onDragLeave);
-
-        this.P5Element.pandoraObject = this;
-    }
-
-    /**
-     * Sets the position of this UIObject on the secondary buffer.
-     * 
-     * @param {number} x    pixel position on the X axis.
-     * @param {number} y    pixel position on the Y axis.
-     */
-    setPosition(x, y)
-    {
-        this.position.x = x;
-        this.position.y = y;
-    }
-
-    /**
-     * Sets the size of this UIObject on the secondary buffer.
-     * 
-     * @param {number} w    pixel width of this UIObject. 
-     * @param {number} h    pixel height of this UIObject.
-     */
-    setSize(w, h)
-    {
-        this.size.x = w;
-        this.size.y = h;
-    }
-
-    /**
-     * Sets this UIObject's font size.
-     * 
-     * @param {number} fs   new font size.
-     */
-    setFontSize(fs)
-    {
-        this.fontSize = fs;
-    }
-
-    /**
-     * Sets the visibility of this UIObject's p5.Element's visibility.
-     * 
-     * @param {boolean} vis new value for the visibility of the UIObject.
-     */
-    setVisibility(vis)
-    {
-        if (vis) this.P5Element.show();
-        else this.P5Element.hide();
-        this.visible = !this.visible;
-    }
-
-    /**
-     * Sets the inner html value of this UIObject's p5.Element.
-     * 
-     * @param {*} val   new inner HTML value for this UIObject.
-     */
-    setValue(val)
-    {
-        this.P5Element.value(val)
-    }
-
-    /**
-     * Sets the CSS style of this UIObject's p5.Element.
-     * 
-     * @param {Object} style    object containing the CSS style for this
-     *                          UIObject. 
-     */
-    setStyle(style)
-    {
-        for (const [key, value] of Object.entries(style))
-        {
-            this.P5Element.style(`${key}`, value);
-        }
-    }
-
-    /**
-     * Returns this UIOBject's position on the secondary buffer.
-     * 
-     * @returns {Vector2} this UIObject's position on the secondary buffer.
-     */
-    getPosition()
-    {
-        return this.position;
-    }
-
-    /**
-     * Returns this Object's position on the secondary buffer.
-     * 
-     * @returns {Vector2}   this UIObject's size on the secondary buffer.
-     */
-    getSize()
-    {
-        return this.size;
-    }
-
-    /**
-     * Returns this UIObject's font size.
-     * 
-     * @returns {number}    this UIObject's font size.
-     */
-    getFontSize()
-    {
-        return this.fontSize;
-    }
-
-    /**
-     * Returns this UIObject's visibility flag.
-     * 
-     * @returns {boolean}   true if this UIObject is visible, false if not.
-     */
-    getVisibility()
-    {
-        return this.visible;
-    }
-
-    /**
-     * Return the inner HTML value of this UIObject's p5.Element.
-     * 
-     * @returns {String}    inner HTML value of this UIObject's p5.Element. 
-     */
-    getValue()
-    {
-        return this.P5Element.value();
-    }
-
-    /**
-     * Sets this UIObject's visibility flag to true, shows the p5.Element, and
-     * recursively calls the show() method on all of this GameObject's children 
-     * if they have it.
-     */
-    show()
-    {
-        this.visible = true;
-        this.P5Element.show();
-
-        for (let i = 0; i < this.children.length; i++)
-        {
-            if (!this.children[i].show) continue;
-            this.children[i].show();
-        }
-    }
-
-    /**
-     * Sets this UIObject's visibility flag to false, hides the p5.Element, and
-     * recursively calls the hide() method on all of this GameObject's children 
-     * if they have it.
-     */
-    hide()
-    {
-        this.visible = false;
-        this.P5Element.hide();
-
-        for (let i = 0; i < this.children.length; i++)
-        {
-            if (!this.children[i].hide) continue;
-            this.children[i].hide();
-        }
-    }
-
-    /**
-     * Adds a GameObject as a child of this UIObject, and parents the child's p5.Element
-     * if they are a UIObject.
-     * 
-     * @param {GameObject} child 
-     * 
-     * @override
-     */
-    addChild(child)
-    {
-        child.parent = this;
-        child.parented = true;
-        this.children.push(child);
-
-        if (child.P5Element)
-            child.P5Element.parent(this.P5Element);
-    }
-
-    /**
-     * Recursively marks this GameObject's and all of its children's
-     * memory for garbage collection. Also removes this UIObject's p5.Element.
-     * 
-     * @override
-     */
-    destroy()
-    {
-        for (let i = 0; i < this.children.length; i++)
-            this.children[i].destroy();
-
-        if (this.P5Element)
-            this.P5Element.remove();
-
-        for (var prop in this)
-            this[prop] = null;
-    }
-
-    /**
-     * Defines default signals for UIObjects and serves as the caller to this UIObject's
-     * _initSignals() callbacks.
-     * 
-     * @signal mousePressed     emited once every time a mouse button is pressed over this
-     *                          UIObject.
-     * @signal doubleClicked    emited once every time a mouse button is pressed twice over
-     *                          this UIObject.
-     * @signal mouseWheel       emited once everty time a mouse wheel is scrolled over this
-     *                          UIObject. Passes one argument {event} that holds the deltaY
-     *                          property, that holds a number based on how much was vertically
-     *                          scrolled (up is positive) and the deltaX property, that holds a
-     *                          number based on how much was horizontaly scrolled (right is positive).
-     * @signal mouseReleased    emited once every time a mouse button is released over this
-     *                          UIObject.
-     * @signal mouseClicked     emited once every time a mouse button is pressed and released
-     *                          over this UIObject.
-     * @signal mouseMoved       emited once every time a mouse moves over this UIObject.
-     * @signal mouseOver        emited once every time a mouse moves onto this UIObject.
-     * @signal mouseOut         emited once every time a mouse moves out of this UIObject.
-     * @signal touchStarted     emited once every time a touch is regiestered over this UIObject.
-     * @signal touchMoved       emited once every time a touch move is regiestered over this
-     *                          UIObject.
-     * @signal touchEnded       emited once every time a touch is regiestered over this UIObject.
-     * @signal dragOver         emited once every time a file is dragged over this UIObject.
-     * @signal dragLeave        emited once every time a dragged file leaves this UIObject's area.
-     * 
-     * @override
-     */
-    initSignals()
-    {
-        this.addSignal("mousePressed");
-        this.addSignal("doubleClicked");
-        this.addSignal("mouseWheel");
-        this.addSignal("mouseReleased");
-        this.addSignal("mouseClicked");
-        this.addSignal("mouseMoved");
-        this.addSignal("mouseOver");
-        this.addSignal("mouseOut");
-        this.addSignal("touchStarted");
-        this.addSignal("touchMoved");
-        this.addSignal("touchEnded");
-        this.addSignal("dragOver");
-        this.addSignal("dragLeave");
-
-        this._initSignals();
-    }
-
-    /**
-     * Updates this UIObject's p5.Element size, position and font size based
-     * on the secondary buffer's size on the actual window. This gives the
-     * impression that the HTML element is actually beeing drawn to the secondary
-     * buffer instead of the main one.
-     * ? is it possible to draw them directly to the secondary buffer?
-     * 
-     * @param {number} delta    number of ellapsed seconds since the last frame.
-     * @param {p5.Graphics} db  secondary buffer to draw to.
-     * 
-     * @override
-     */
-    draw(delta, db)
-    {
-        let ar = db.screenWidth / db.width;
-        let offsetx = (windowWidth - db.screenWidth) / 2;
-        let offsety = (windowHeight - db.screenHeight) / 2;
-        this.P5Element.position(offsetx + this.position.x * ar, offsety + this.position.y * ar);
-        this.P5Element.size(this.size.x * ar, this.size.y * ar);
-
-        this.setStyle(
-        {
-            "font-size": `${this.fontSize * ar}px`
-        });
-
-        this.drawChildren(delta, db);
-    }
-
-    /**
-     * Called once every time a mouse button is pressed over this UIObject.
-     * Connected to the mousePressed event from this UIObject's p5.Element.
-     * Serves as an emiter to the mousePressed signal and calls the _onMousePressed()
-     * callback.
-     */
-    onMousePressed()
-    {
-        this.pandoraObject.emitSignal("mousePressed");
-        this.pandoraObject._onMousePressed();
-    }
-
-    /**
-     * Called once every time a mouse button in pressed twice over this UIObject.
-     * Connected to the doubleClicked event from this UIObject's p5.Element.
-     * Serves as an emiter to the doubleClicked signal and calls the _onDoubleClicked()
-     * callback.
-     */
-    onDoubleClicked()
-    {
-        this.pandoraObject.emitSignal("doubleClicked");
-        this.pandoraObject._onDoubleClicked();
-    }
-
-    /**
-     * Called once every time a mouse wheel is scrolled over this UIObject.
-     * Connected to the mouseWheel event from this UIObject's p5.Element.
-     * Serves as an emiter to the mouseWheel signal and calls the _onMouseWheel()
-     * callback.
-     * 
-     * @param {Object} event    contains data about the wheen scroll, with the deltaY
-     *                          and deltaX property, containing data about the vertical
-     *                          and horizontal scrolling, repsctively.
-     */
-    onMouseWheel(event)
-    {
-        this.pandoraObject.emitSignal("mouseWheel", event);
-        this.pandoraObject._onMouseWheel(event);
-    }
-
-    /**
-     * Called once every time a mouse button is released over this UIObject.
-     * Connected to the mouseReleased event from this UIObject's p5.Element.
-     * Serves as an emiter to the mouseReleased signal and calls the _onMouseReleased()
-     * callback.
-     */
-    onMouseReleased()
-    {
-        this.pandoraObject.emitSignal("mouseReleased");
-        this.pandoraObject._onMouseReleased();
-    }
-
-    /**
-     * Called once every time a mouse button is pressed and released over this UIObject.
-     * Connected to the mouseClicked event from this UIObject's p5.Element.
-     * Serves as an emiter to the mouseClicked signal and calls the _onMouseClicked()
-     * callback.
-     */
-    onMouseClicked()
-    {
-        this.pandoraObject.emitSignal("mouseClicked");
-        this.pandoraObject._onMouseClicked();
-    }
-
-    /**
-     * Called once everty time a mouse moves over this UIObject.
-     * Connected to the mouseMoved event from this UIObject's p5.Element.
-     * Serves as an emiter to the mouseMoved signal and calls the _onMouseMoved()
-     * callback.
-     */
-    onMouseMoved()
-    {
-        this.pandoraObject.emitSignal("mouseMoved");
-        this.pandoraObject._onMouseMoved();
-    }
-
-    /**
-     * Called once every time a mouse moves onto this UIObject.
-     * Connected to the mouseOver event from this UIObject's p5.Element.
-     * Serves as an emiter to the mouseOver signal and calls the _onMouseOver()
-     * callback.
-     */
-    onMouseOver()
-    {
-        this.pandoraObject.emitSignal("mouseOver");
-        this.pandoraObject._onMouseOver();
-    }
-
-    /**
-     * Called once every time a mouse moves off the UIObject.
-     * Connected to the mouseOut event from this UIObject's p5.Element.
-     * Serves as an emiter to the mouseOut signal and calls the _onMouseOut()
-     * callback.
-     */
-    onMouseOut()
-    {
-        this.pandoraObject.emitSignal("mouseOut");
-        this.pandoraObject._onMouseOut();
-    }
-
-    /**
-     * Called once every time a touch is registered over this UIObject.
-     * Connected to the touchStarted event from this UIObject's p5.Element.
-     * Serves as an emiter to the touchStarted signal and calls the _onTouchStarted()
-     * callback.
-     */
-    onTouchStarted()
-    {
-        this.pandoraObject.emitSignal("touchStarted");
-        this.pandoraObject._onTouchStarted();
-    }
-
-    /**
-     * Called once every time a touch move is registered over this UIObject.
-     * Connected to the touchMoved event from this UIObject's p5.Element.
-     * Serves as an emiter to the touchMoved signal and calls the _onTouchMoved()
-     * callback.
-     */
-    onTouchMoved()
-    {
-        this.pandoraObject.emitSignal("touchMoved");
-        this.pandoraObject._onTouchMoved();
-    }
-
-    /**
-     * Called once every time a touch is registered over this UIObject.
-     * Connected to the touchEnded event from this UIObject's p5.Element.
-     * Serves as an emiter to the touchEnded signal and calls the _onTouchEnded()
-     * callback.
-     */
-    onTouchEnded()
-    {
-        this.pandoraObject.emitSignal("touchEnded");
-        this.pandoraObject._onTouchEnded();
-    }
-
-    /**
-     * Called once every time a file is dragged over this UIObject's area.
-     * Connected to the dragOver event from this UIObject's p5.Element.
-     * Serves as an emiter to the dragOver signal and calls the _onDragOver()
-     * callback.
-     */
-    onDragOver()
-    {
-        this.pandoraObject.emitSignal("dragOver");
-        this.pandoraObject._onDragOver();
-    }
-
-    /**
-     * Called once every time a dragged file leaves tis UIObject's area.
-     * Connected to the dragLeave event from this UIObject's p5.Element.
-     * Serves as an emiter to the dragLeave signal and calls the _onDragLeave()
-     * callback.
-     */
-    onDragLeave()
-    {
-        this.pandoraObject.emitSignal("dragLeave");
-        this.pandoraObject._onDragLeave();
-    }
-
-    /**
-     * ! This function should be overriden, it provides no default functionality.
-     * Called once every time a mouse button is pressed over this UIObject.
-     * 
-     * @callback
-     */
-    _onMousePressed()
-    {
-
-    }
-
-    /**
-     * ! This function should be overriden, it provides no default functionality.
-     * Called once every time a mouse button in pressed twice over this UIObject.
-     * 
-     * @callback
-     */
-    _onDoubleClicked()
-    {
-
-    }
-
-    /**
-     * ! This function should be overriden, it provides no default functionality.
-     * Called once every time a mouse wheel is scrolled over this UIObject.
-     * 
-     * @callback
-     * 
-     * @param {Object} event    contains data about the wheen scroll, with the deltaY
-     *                          and deltaX property, containing data about the vertical
-     *                          and horizontal scrolling, repsctively.
-     */
-    _onMouseWheel(event)
-    {
-
-    }
-
-    /**
-     * ! This function should be overriden, it provides no default functionality.
-     * Called once every time a mouse button is released over this UIObject.
-     * 
-     * @callback
-     */
-    _onMouseReleased()
-    {
-
-    }
-
-    /**
-     * ! This function should be overriden, it provides no default functionality.
-     * Called once every time a mouse button is pressed and released over this UIObject.
-     * 
-     * @callback
-     */
-    _onMouseClicked()
-    {
-
-    }
-
-    /**
-     * ! This function should be overriden, it provides no default functionality.
-     * Called once everty time a mouse moves over this UIObject.
-     * 
-     * @callback
-     */
-    _onMouseMoved()
-    {
-
-    }
-
-    /**
-     * ! This function should be overriden, it provides no default functionality.
-     * Called once every time a mouse moves onto this UIObject.
-     * 
-     * @callback
-     */
-    _onMouseOver()
-    {
-
-    }
-
-    /**
-     * ! This function should be overriden, it provides no default functionality.
-     * Called once every time a mouse moves off the UIObject.
-     * 
-     * @callback
-     */
-    _onMouseOut()
-    {
-
-    }
-
-    /**
-     * ! This function should be overriden, it provides no default functionality.
-     * Called once every time a touch is registered over this UIObject.
-     * 
-     * @callback
-     */
-    _onTouchStarted()
-    {
-
-    }
-
-    /**
-     * ! This function should be overriden, it provides no default functionality.
-     * Called once every time a touch move is registered over this UIObject.
-     * 
-     * @callback
-     */
-    _onTouchMoved()
-    {
-
-    }
-
-    /**
-     * ! This function should be overriden, it provides no default functionality.
-     * Called once every time a touch is registered over this UIObject.
-     * 
-     * @callback
-     */
-    _onTouchEnded()
-    {
-
-    }
-
-    /**
-     * ! This function should be overriden, it provides no default functionality.
-     * Called once every time a file is dragged over this UIObject's area.
-     * 
-     * @callback
-     */
-    _onDragOver()
-    {
-
-    }
-
-    /**
-     * ! This function should be overriden, it provides no default functionality.
-     * Called once every time a dragged file leaves tis UIObject's area.
-     * 
-     * @callback
-     */
-    _onDragLeave()
-    {
-
-    }
-}

+ 0 - 210
pandora/handlers/AssetHandler.js

@@ -1,210 +0,0 @@
-/************************************************************************
- * AssetHandler.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/>.
- *************************************************************************/
-
-/**
- * This {@code AssetHandler} singleton provides an interface for the user
- * to load various types of assets to memory.
- * 
- * @author Pedro Schneider
- * 
- * @namespace
- */
-const AssetHandler = {
-    cachedTextures: [], // Cache for TextureRes.
-    cachedAudio: [], // Cache for AudioRes.
-    cachedFonts: [], // Cache for FontRes.
-
-    /**
-     * Loads an image to cache as a TextureRes. Can be loaded from a request to a server
-     * or from a local path to a file. The recomended place to call this function is
-     * inside preload for static loading, but it can also be called dynamically inside
-     * the game.
-     * 
-     * @param {String} name name for the TextureRes to be saved as.
-     * @param {String} link link to load the image file from (server or local).
-     */
-    loadTexture: function(name, link)
-    {
-        let textRes = new TextureRes(name, null);
-        this.cachedTextures.push(textRes);
-        loadImage(link, img =>
-        {
-            textRes.P5Image = img;
-        });
-    },
-
-    /**
-     * Query a TextureRes by its name.
-     * 
-     * @param {String} name name of the requested TextureRes.
-     * 
-     * @returns {TextureRes}    reference to the first loaded TextureRes whose name matches
-     *                          the parameter, or null if no TextureRes matches the name.
-     */
-    getTextureByName: function(name)
-    {
-        for (let i = 0; i < this.cachedTextures.length; i++)
-        {
-            if (this.cachedTextures[i].name == name)
-            {
-                return this.cachedTextures[i];
-            }
-        }
-        return null;
-    },
-
-    /**
-     * Query a p5.Image by the name of the TextureRes it was loaded as.
-     * 
-     * @param {String} name name of the TextureRes that holds the desired
-     *                      p5.Image.
-     * 
-     * @returns {p5.Image}  p5.Image held by the first loaded TextureRes whose name
-     *                      matches the parameter, or null if no TextureRes matches the name.
-     */
-    getP5ImageByName: function(name)
-    {
-        for (let i = 0; i < this.cachedTextures.length; i++)
-        {
-            if (this.cachedTextures[i].name == name)
-            {
-                return this.cachedTextures[i].P5Image;
-            }
-        }
-        return null;
-    },
-
-    /**
-     * Loads an audio to cache as an AudioRes. Can be loaded from a request to a server
-     * or from a local path to a file. The recomended place to call this function is
-     * inside preload for static loading, but it can also be called dynamically inside
-     * the game.
-     * 
-     * @param {String} name name for the AudioRes to be saved as.
-     * @param {String} link link to load the audio file from (server or local).
-     */
-    loadAudio: function(name, link)
-    {
-        let audio = createAudio(link);
-        this.cachedAudio.push(new AudioRes(name, audio));
-    },
-
-    /**
-     * Query an AudioRes by its name.
-     * 
-     * @param {String} name name of the requested AudioRes.
-     * 
-     * @returns {AudioRes}  reference to the first loaded AudioRes whose name matches
-     *                      the parameter, or null if no AudioRes matches the name.
-     */
-    getAudioByName: function(name)
-    {
-        for (let i = 0; i < this.cachedAudio.length; i++)
-        {
-            if (this.cachedAudio[i].name == name)
-            {
-                return this.cachedAudio[i];
-            }
-        }
-        return null;
-    },
-
-    /**
-     * Query a p5.Audio by the name of the AudioRes it was loaded as.
-     * 
-     * @param {String} name name of the AudioRes that holds the desired
-     *                      p5.Audio.
-     * 
-     * @returns {p5.Audio}  p5.Audio held by the first loaded AudioRes whose name
-     *                      matches the parameter, or null if no AudioRes matches the name.
-     */
-    getP5AudioByName: function(name)
-    {
-        for (let i = 0; i < this.cachedAudio.length; i++)
-        {
-            if (this.cachedAudio[i].name == name)
-            {
-                return this.cachedAudio[i].P5Audio;
-            }
-        }
-        return null;
-    },
-
-    /**
-     * Loads a font to cache as FontRes. Can be loaded from a request to a server
-     * or from a local path to a file. The recomended place to call this function is
-     * inside preload for static loading, but it can also be called dynamically inside
-     * the game.
-     * 
-     * @param {String} name name for the FontRes to be saved as.
-     * @param {String} link link to load the font file from (server or local).
-     */
-    loadFont: function(name, link)
-    {
-        let fontRes = new FontRes(name, null);
-        this.cachedFonts.push(fontRes);
-        loadFont(link, font =>
-        {
-            fontRes.P5Font = font;
-        })
-    },
-
-    /**
-     * Query a FontRes by its name.
-     * 
-     * @param {String} name name of the requested FontRes.
-     * 
-     * @returns {FontRes}   reference to the first loaded FontRes whose name matches
-     *                      the parameter, or null if no FontRes matches the name.
-     */
-    getFontByName: function(name)
-    {
-        for (let i = 0; i < this.cachedFonts.length; i++)
-        {
-            if (this.cachedFonts[i].name == name)
-            {
-                return this.cachedFonts[i];
-            }
-        }
-        return null;
-    },
-
-    /**
-     * Query a p5.Font by the name of the FontRes it was loaded as.
-     * 
-     * @param {String} name name of the FontRes that holds the desired
-     *                      p5.Font.
-     * 
-     * @returns {p5.Font}   p5.Font held by the first loaded FontRes whose name
-     *                      matches the parameter, or null if no FontRes matches the name.
-     */
-    getP5FontByName: function(name)
-    {
-        for (let i = 0; i < this.cachedFonts.length; i++)
-        {
-            if (this.cachedFonts[i].name == name)
-            {
-                return this.cachedFonts[i].P5Font;
-            }
-        }
-        return null;
-    }
-};

+ 0 - 378
pandora/handlers/GameHandler.js

@@ -1,378 +0,0 @@
-/************************************************************************
- * GameHandler.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/>.
- *************************************************************************/
-
-/**
- * This {@code GameHandler} singleton provides an interface for the user
- * to manipulate various parameters of the game, instance objects, and more.
- * 
- * @author Pedro Schneider
- * 
- * @namespace
- */
-const GameHandler = {
-    nextId: 0, // ID to be given to the next object added to the tree.
-    rootObjects: [], // List of objects on the root of the tree.
-
-    renderMode: 1, // Can be RENDER_MODES.P2D or RENDER_MODES.WEBGL.
-
-    bDrawDebugFPS: false, // Should fps be drawn (for debug only).
-    debugFpsLabel: null, // Object that drwas fps.
-    bDrawDebugBufferBounds: false, // Should the secondary buffer's bounds be drawn?
-
-    prevMillis: 0, // Milliseconds ellapsed since the begining of the application.
-    delta: 0, // Milliseconds ellapsed since the last frame.
-
-    db: null, // Object to hold the secondary buffer.
-    dbWidth: 1920, // Width of the secondary buffer.
-    dbHeight: 1080, // Height of the secondary buffer.
-
-    isMobile: null, // True if the device is a mobile device (tablet of phone).
-    pixelDen: 1, // Pixel density for the canvas on destop devices.
-    pixelDenMobile: 2, // Pixel denisty for the canvas on mobile devices.
-
-    mouseX: 0, // X position of the mouse relative to the secondary buffer.
-    mouseY: 0, // Y position of the mouse relative to the secondary buffer.
-    pmouseX: 0, // X position of the mouse relative to the secondary buffer on the previous frame.
-    pmouseY: 0, // Y position of the mouse relative to the secondary buffer on the previous frame.
-
-    backgroundColor: null, // Default color to be drawn to the background.
-
-    /**
-     * Sets the initial game render mode.
-     * 
-     * @param {RENDER_MODES} mode   RENDER_MODES.P2D for default P5Js render or 
-     *                              RENDER_MODES.WEBGL for webgl (not recomended for mobile).
-     */
-    setRenderMode(mode)
-    {
-        this.renderMode = mode;
-    },
-
-    /**
-     * Sets the width and height in pixels to initialize the secondary buffer.
-     * 
-     * @param {number} w    width in pixels to initialize the secondary buffer.
-     * @param {number} h    height in pixels to initialize the secondary buffer.
-     */
-    setDoubleBufferSize(w, h)
-    {
-        this.dbWidth = w;
-        this.dbHeight = h;
-    },
-
-    /**
-     * Sets the pixel density for the canvas to be initialized with on desktop
-     * devices.
-     * 
-     * @param {number} val  pixel density for the canvas on desktop devices.
-     */
-    setPixelDensity(val)
-    {
-        this.pixelDen = val;
-    },
-
-    /**
-     * Sets the pixel density for the canvas to be initialized with on desktop
-     * devices.
-     * 
-     * @param {number} val  pixel density for the canvas on desktop devices.
-     */
-    setPixelDensityMobile(val)
-    {
-        this.pixelDenMobile = val;
-    },
-
-    /**
-     * Sets the default color to be drawn to the main buffer's background.
-     * 
-     * @param {Color} col   new background color; 
-     */
-    setBackgroundColor(col)
-    {
-        this.backgroundColor = col;
-    },
-
-    /**
-     * Sets the flag to draw the debug fps.
-     * 
-     * @param {boolean} val true if debug fps should be drawn, false if not.
-     */
-    drawDebugFPS(val)
-    {
-        this.bDrawDebugFPS = val;
-    },
-
-    /**
-     * Sets the flag to draw secondary buffer bounds.
-     * 
-     * @param {boolean} val true if debug secondary buffer bounds should be drawn, false if not. 
-     */
-    drawDebugBufferBounds(val)
-    {
-        this.bDrawDebugBufferBounds = val;
-    },
-
-    /**
-     * Initializes the game, creating the canvas, secondary buffer, and creates the
-     * debug fps label if necessary.
-     * 
-     * @param {number} fps  target fps for the game (default if 60).
-     */
-    init(fps = 60)
-    {
-        // Sets the mobile flag.
-        this.isMobile = /Android|webOS|iPhone|iPad|iPod|BlackBerry|IEMobile|Opera Mini/i.test(navigator.userAgent);
-
-        // Creates the main canvas and the secondary buffer with the specified size and render mode.
-        switch (this.renderMode)
-        {
-            case RENDER_MODES.P2D:
-                createCanvas(windowWidth, windowHeight);
-                this.db = createGraphics(this.dbWidth, this.dbHeight);
-                break;
-            case RENDER_MODES.WEBGL:
-                createCanvas(windowWidth, windowHeight, WEBGL);
-                this.db = createGraphics(this.dbWidth, this.dbHeight, WEBGL);
-                this.db.smooth();
-                break;
-        }
-
-        // Sets framerate and pixel density accordingly.
-        frameRate(fps);
-        if (this.isMobile)
-            pixelDensity(this.pixelDenMobile);
-        else
-            pixelDensity(this.pixelDen);
-        smooth();
-
-        // Translates the canvas to the middle if render mode is webgl to maintain
-        // consistency on the coordinate system.
-        if (this.renderMode == RENDER_MODES.WEBGL)
-        {
-            translate(-windowWidth / 2, -windowHeight / 2);
-            db.translate(-this.dbWidth / 2, -this.dbHeight / 2);
-        }
-
-        // Creates the debug fps label.
-        if (this.bDrawDebugFPS)
-        {
-            this.debugFpsLabel = new Label("debugFps", `FPS: ${frameRate()}`);
-            this.addRootObject(this.debugFpsLabel);
-        }
-    },
-
-    /**
-     * Instances a GameObject, meaning to give it an ID. This function is only called on the
-     * constructor of GameObject, and probably shouldn't be used for anything else.
-     * 
-     * @param {GameObject} obj  GameObject to be instanced. 
-     */
-    instanceGameObject(obj)
-    {
-        obj.id = this.nextId;
-        this.nextId++;
-    },
-
-    /**
-     * Adds a GameObject to the root of the tree. There should be as little root objects as possible.
-     * 
-     * @param {GameObject} obj  GameObject to be added as a root of the tree. 
-     */
-    addRootObject(obj)
-    {
-        this.rootObjects.push(obj);
-        obj.isRoot = true;
-        obj.setup();
-    },
-
-    /**
-     * Removes a GameObject from the root of the tree. This function is called automatically when a root object
-     * is freed from memory, and probably shoudn't be used for anything else. DOES NOT DELETE THE OBJECT, ONLY
-     * REMOVES IT FROM THE TREE.
-     * 
-     * @param {number} id   object id of the GameObject that should be removed from the tree.
-     */
-    removeRootObjectById(id)
-    {
-        for (let i = 0; i < this.rootObjects.length; i++)
-        {
-            if (this.rootObjects[i].id == id)
-                this.rootObjects.splice(i, 1);
-        }
-    },
-
-    upframecount: 0, // Frame count to be displayed.
-    upframenum: 20, // Delay in frames to update the frame count.
-    /**
-     * Updates all of the GameObjects on the tree.
-     */
-    update()
-    {
-        // Updates the debug fps label if it existis.
-        if (this.bDrawDebugFPS)
-        {
-            if (frameCount % this.upframenum == 0)
-            {
-                this.debugFpsLabel.setText(`FPS: ${
-                    Math.round(this.upframecount * 1000) / 1000
-                }`);
-                this.upframecount = 0;
-            }
-            else
-                this.upframecount = max(this.upframecount, frameRate());
-        }
-
-        // Updates the delta.
-        this.delta = (millis() - this.prevMillis) / 1000;
-
-        // Update mouse position relative to the secondary buffer.
-        this.pmouseX = this.mouseX;
-        this.pmouseY = this.mouseY;
-        let ar = this.db.screenWidth / this.db.width;
-        let offsetx = (windowWidth - this.db.screenWidth) / 2;
-        let offsety = (windowHeight - this.db.screenHeight) / 2;
-        this.mouseX = (mouseX - offsetx) / ar;
-        this.mouseY = (mouseY - offsety) / ar;
-
-        // Updates all game objects on the tree.
-        for (let i = 0; i < this.rootObjects.length; i++)
-            this.rootObjects[i].update(this.delta);
-    },
-
-    /**
-     * Draws all of the GameObjects on the tree.
-     */
-    draw()
-    {
-        // Clear the secondary buffer.
-        this.db.clear();
-
-        if (this.bDrawDebugBufferBounds)
-        {
-            // Draw a rectangle to visualize the secondary buffer.
-            this.db.push();
-            this.db.strokeWeight(5);
-            this.db.noFill();
-            this.db.rect(0, 0, this.dbWidth, this.dbHeight);
-            this.db.pop();
-        }
-
-        // Centers the image and calculates the dimensions of the secondary
-        // buffer to best fit the size of the window.
-        imageMode(CENTER);
-        if (windowWidth / windowHeight < this.dbWidth / this.dbHeight)
-        {
-            this.db.screenWidth = windowWidth;
-            this.db.screenHeight = windowWidth * (this.dbHeight / this.dbWidth);
-        }
-        else
-        {
-            this.db.screenHeight = windowHeight;
-            this.db.screenWidth = windowHeight * (this.dbWidth / this.dbHeight);
-        }
-
-        this.db.ellipse(this.pmouseX, this.pmouseY, 20);
-        this.db.line(this.pmouseX, this.pmouseY, this.mouseX, this.mouseY);
-
-        // Draw all game objects.
-        for (let i = 0; i < this.rootObjects.length; i++)
-            this.rootObjects[i].draw(this.delta, this.db);
-
-        // Draws the secondary buffer to the main canvas.
-        image(this.db, windowWidth / 2, windowHeight / 2, this.db.screenWidth, this.db.screenHeight);
-
-        // Updates the delta
-        this.prevMillis = millis();
-    },
-
-    /**
-     * ! This function should be overriden, it provides no default functionality.
-     * This function is called once when the page loads, and should be used by the user to load
-     * assets and other forms of data that need to be already loaded when the prorgam starts.
-     * 
-     * @callback
-     */
-    _preload()
-    {
-
-    },
-
-    /**
-     * ! This function should be overriden, it provides no default functionality.
-     * This function is called once when the program starts, and should be used by the user to
-     * initialize any necessary aspects of the game.
-     * 
-     * @callback
-     */
-    _setup()
-    {
-
-    },
-}
-
-/**
- * This function is called once when the page loads. Serves to load assets and other
- * data that needs to be loaded when the program starts.
- * 
- * @callback
- */
-function preload()
-{
-    GameHandler._preload();
-}
-
-/**
- * This function is called once at the start of the program. Serves to initialize several
- * aspects of the game.
- * 
- * @callback
- */
-function setup()
-{
-    GameHandler._setup();
-    GameHandler.init();
-}
-
-/**
- * This function is called once every frame. Serves to update and draw all GameObjects.
- * 
- * @callback
- */
-function draw()
-{
-    if (GameHandler.backgroundColor)
-        background(GameHandler.backgroundColor.getP5Color());
-    else
-        background(200);
-    GameHandler.update();
-    GameHandler.draw();
-}
-
-/**
- * This function is called once every time the browser window is resized. Here, its used to make the game
- * always ocupy the entire browser window.
- * 
- * @callback
- */
-function windowResized()
-{
-    resizeCanvas(windowWidth, windowHeight);
-}

+ 0 - 46
pandora/resources/AudioRes.js

@@ -1,46 +0,0 @@
-/************************************************************************
- * AudioRes.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/>.
- *************************************************************************/
-
-/**
- * This {@code AudioRes} class provides an interface to store an audio resource into
- * memory to be accessed later.
- * 
- * @author Pedro Schneider
- * 
- * @class
- */
-class AudioRes extends Resource
-{
-    /**
-     * Initializes an audio resource with the given parameters.
-     * 
-     * @param {String} name         name of the audio resource.
-     * @param {p5.Audio} p5Audio    audio data for the audio resource.
-     * 
-     * @constructor
-     */
-    constructor(name = "", p5Audio = null)
-    {
-        super(name);
-
-        this.P5Audio = p5Audio;
-    }
-}

+ 0 - 46
pandora/resources/FontRes.js

@@ -1,46 +0,0 @@
-/************************************************************************
- * FontRes.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/>.
- *************************************************************************/
-
-/**
- * This {@code FontRes} class provides an interface to store a font resource into
- * memory to be accessed later.
- * 
- * @author Pedro Schneider
- * 
- * @class
- */
-class FontRes extends Resource
-{
-    /**
-     * Initializes a font resource with the given parameters.
-     * 
-     * @param {String} name         name of the font resource.
-     * @param {p5.Audio} p5font     audio data for the font resource.
-     * 
-     * @constructor
-     */
-    constructor(name = "", p5Font = null)
-    {
-        super(name);
-
-        this.P5Font = p5Font;
-    }
-}

+ 0 - 43
pandora/resources/Resource.js

@@ -1,43 +0,0 @@
-/************************************************************************
- * Resource.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/>.
- *************************************************************************/
-
-/**
- * This {@code Resource} class represents the base class all Resources inherit from.
- * 
- * ! This is an empty class the serves only to be inherited from to organize the hierarchy.
- * ! This class should not bet used by the user.
- * 
- * @author Pedro Schneider
- * 
- * @class
- */
-class Resource
-{
-    /**
-     * Creates an empty Resource.
-     * 
-     * @constructor
-     */
-    constructor(name = "")
-    {
-        this.name = name;
-    }
-}

+ 0 - 233
pandora/resources/SpriteFrames.js

@@ -1,233 +0,0 @@
-/************************************************************************
- * SpriteFrames.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/>.
- *************************************************************************/
-
-/**
- * This {@code SpriteAnimation} class provides an interface to store an animation in the form
- * of a series of images.
- * 
- * ! This class has no use in the engine aside from holding the data for an animation inside a
- * ! SpriteFrames object. Its use is not recomended anywhere else.
- * 
- * @author Pedro Schneider
- * 
- * @class
- */
-class SpriteAnimation extends Resource
-{
-    /**
-     * Initialize a SpriteAnimation with the given parameters.
-     * 
-     * @param {String} name         name for the SpriteAnimation.
-     * @param {p5.Image} p5Image    p5.Image holding all the frames for the aniamtion.
-     * @param {number} rows         number of rows of frames the image has.
-     * @param {number} cols         number of columns of frames the image has.
-     * @param {Array} indices       indices of the frames from left-to-right and top-to-bottom
-     *                              that should be included in the animation.
-     * @param {number} fps          frames per second the animation should be played at.
-     * 
-     * @constructor 
-     */
-    constructor(name = "default", p5Image, rows, cols, indices, fps)
-    {
-        super(name);
-
-        this.fullP5Image = p5Image;
-        this.rows = rows;
-        this.columns = cols;
-        this.indices = indices;
-        this.numFrames = this.indices.length;
-        this.frameTime = 1 / fps;
-
-        // Extract all the requested frames from the image as individual p5.Images.
-        this.frames = [];
-        for (let i = 0; i < this.numFrames; i++)
-        {
-            this.frames.push(this.makeFrame(i));
-        }
-    }
-
-    /**
-     * Extracts a frame from the full image based on its index on the image, from left-to-right and
-     * top-to-bottom.
-     * 
-     * @param {number} idx  index of the desired frame on the full image.
-     * 
-     * @returns {p5.Image}  frame with the requested index on the full image.
-     */
-    makeFrame(idx)
-    {
-        let r = int(this.indices[idx] / this.columns);
-        let c = this.indices[idx] % this.columns;
-        let w = this.fullP5Image.width / this.columns;
-        let h = this.fullP5Image.height / this.rows;
-        let x = c * w;
-        let y = r * h;
-        return this.fullP5Image.get(x, y, w, h);
-    }
-
-    /**
-     * Sets the time between frames for the animation.
-     * 
-     * @param {number} time new time between frames for the animation.
-     */
-    setFrameTime(time)
-    {
-        this.frameTime = time;
-    }
-
-    /**
-     * Sets the frames per second for the animation.
-     * 
-     * @param {number} fps  new frames per second value for the animation.
-     */
-    setFPS(fps)
-    {
-        this.frameTime = 1 / fps;
-    }
-
-    /**
-     * Returns a frame of the animation based on its index.
-     * 
-     * @param {number} idx  index of the desired frame on the animation.
-     * 
-     * @returns {p5.Image}  frame with the requested index on the animation, or null if
-     *                      the requested index is invalid.
-     */
-    getFrame(idx)
-    {
-        if (idx >= 0 && idx < this.numFrames)
-            return this.frames[idx];
-        return null;
-    }
-
-    /**
-     * Returns the time between frames for the animation.
-     * 
-     * @returns {number}    time between frames for the aniamtion.
-     */
-    getFrameTime()
-    {
-        return this.frameTime;
-    }
-
-    /**
-     * Returns the number of frames the animation has.
-     * 
-     * @returns {number}    number of frames the animation has.
-     */
-    getNumFrames()
-    {
-        return this.numFrames;
-    }
-}
-
-/**
- * This {@code SpriteFrames} class provides an interface to store multiple related SpriteAnimations
- * inside a sigle object for use with the AnimatedSprite2D GameObject.
- * 
- * @author Pedro Schneider
- * 
- * @class
- */
-class SpriteFrames extends Resource
-{
-    /**
-     * Initializes an empty SpriteFrames.
-     * 
-     * @constructor
-     */
-    constructor()
-    {
-        super();
-        
-        this.animations = [];
-        this.numAnimations = 0;
-    }
-
-    /**
-     * Returns an animation based on its index on the list of aniamtions.
-     * 
-     * @param {number} idx          index of the desired animation.
-     * 
-     * @returns {SpriteAnimation}   animation with the requested index, or null if the
-     *                              index is invalid.
-     */
-    getAnimationByIndex(idx)
-    {
-        if (idx >= 0 && idx < this.numAnimations) return this.animations[idx];
-        return null;
-    }
-
-    /**
-     * Returns an animation baes on its name.
-     * 
-     * @param {String} name         name of the desired animation.
-     * 
-     * @returns {SpriteAnimation}   animation with the requested name, or
-     *                              null if no animation has that name. 
-     */
-    getAnimationByName(name)
-    {
-        for (let i = 0; this.numAnimations; i++)
-        {
-            if (this.animations[i].name == name)
-            {
-                return this.animations[i];
-            }
-        }
-        return null;
-    }
-
-    /**
-     * Returns the index of an animation on the list of animations based on its name.
-     * 
-     * @param {number} name name of the desired animation.
-     * @returns {number}    index on the list of animations of the animation with the requested
-     *                      name, or null if no animation has that name
-     */
-    getAnimationIndexByName(name)
-    {
-        for (let i = 0; this.numAnimations; i++)
-        {
-            if (this.animations[i].name == name)
-                return i;
-        }
-        return null;
-    }
-
-    /**
-     * Adds a new SprteAniamtion to the list of aniamtions with the given data.
-     * 
-     * @param {String} name         name for the SpriteAnimation.
-     * @param {p5.Image} p5Image    p5.Image holding all the frames for the aniamtion.
-     * @param {number} rows         number of rows of frames the image has.
-     * @param {number} cols         number of columns of frames the image has.
-     * @param {Array} indices       indices of the frames from left-to-right and top-to-bottom
-     *                              that should be included in the animation.
-     * @param {number} fps          frames per second the animation should be played at.
-     *                              Default is 24.
-     */
-    addAnimation(name, p5Image, rows, cols, indices, fps = 24)
-    {
-        this.animations.push(new SpriteAnimation(name, p5Image, rows, cols, indices, fps));
-        this.numAnimations++;
-    }
-}

+ 0 - 46
pandora/resources/TextureRes.js

@@ -1,46 +0,0 @@
-/************************************************************************
- * TextureRes.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/>.
- *************************************************************************/
-
-/**
- * This {@code TextureRes} class provides an interface to store a texture resource into
- * memory to be accessed later.
- * 
- * @author Pedro Schneider
- * 
- * @class
- */
-class TextureRes extends Resource
-{
-    /**
-     * Initializes a texture resource with the given parameters.
-     * 
-     * @param {String} name         name of the texture resource.
-     * @param {p5.Audio} p5Image     audio data for the texture resource.
-     * 
-     * @constructor
-     */
-    constructor(name = "", p5Image = null)
-    {
-        super(name);
-
-        this.P5Image = p5Image;
-    }
-}

+ 0 - 118
pandora/singletons/Collisions.js

@@ -1,118 +0,0 @@
-/************************************************************************
- * Collisions.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/>.
- *************************************************************************/
-
-/**
- * This {@code Collisions} singleton provides an interface for the engine to calculate collisions
- * with various differente shapes. They are used in the calculations of the Area2D GameObject,
- * to check collisions with the mouse. They can be utilized by the user if it fits the need.
- * 
- * @author Pedro Schneider
- * 
- * @namespace
- */
-const Collisions = {
-    /**
-     * Rotates the (x, y) vector by a degrees clockwise, around the origin.
-     * 
-     * @param {number} x    X coordinate of the vector to rotate.
-     * @param {number} y    Y coordinate of the vector to rotate.
-     * @param {number} a    angle in degrees to rotate the vector.
-     * 
-     * @returns {Array}     static array containing the tow coordinates of the rotated vector.
-     *                      Can be deconstructed. 
-     */
-    rotate(x, y, a)
-    {
-        var rotx = x,
-            roty = y;
-        var ra = radians(a)
-        if (a % 360 != 0)
-        {
-            rotx = x * cos(-ra) - y * sin(-ra);
-            roty = x * sin(-ra) + y * cos(-ra);
-        }
-
-        return Object.freeze([rotx, roty]);
-    },
-
-    /**
-     * Namespace to separate rectangle collision detection.
-     * 
-     * @namespace
-     */
-    Rect:
-    {
-        /**
-         * Calculates if a point is inside a rect.
-         * 
-         * @param {number} posx global X-axis position of the rect. 
-         * @param {number} posy global Y-axis position of the rect.
-         * @param {number} rot  global rotation in degrees of the rect.
-         * @param {number} sx   global X-axis scale of the rect.
-         * @param {number} sy   global Y-axis scale of the rect.
-         * @param {Rect} rect   Shape component with the rect data.
-         * @param {number} x    X-axis position of the point.
-         * @param {number} y    Y-axis position of the point.
-         * 
-         * @returns {boolean}   true if the point is inside the rect, false otherwise. 
-         */
-        point(posx, posy, rot, sx, sy, rect, x, y)
-        {
-            x -= posx;
-            y -= posy;
-
-            var [rotx, roty] = Collisions.rotate(x, y, rot);
-            return abs(rotx) <= rect.w / 2 * sx && abs(roty) <= rect.h / 2 * sy;
-        },
-    },
-
-    /**
-     * Namespace to separate ellipse collision detection.
-     * 
-     * @namespace
-     */
-    Ellipse:
-    {
-        /**
-         * Calculates if a point is inside a ellipse.
-         * 
-         * @param {number} posx global X-axis position of the ellipse. 
-         * @param {number} posy global Y-axis position of the ellipse.
-         * @param {number} rot  global rotation in degrees of the ellipse.
-         * @param {number} sx   global X-axis scale of the ellipse.
-         * @param {number} sy   global Y-axis scale of the ellipse.
-         * @param {Ellipse} e   Shape component with the ellipse data.
-         * @param {number} x    X-axis position of the point.
-         * @param {number} y    Y-axis position of the point.
-         * 
-         * @returns {boolean}   true if the point is inside the ellipse, false otherwise. 
-         */
-        point(posx, posy, rot, sx, sy, e, x, y)
-        {
-            x -= posx;
-            y -= posy;
-
-            var [rotx, roty] = Collisions.rotate(x, y, rot);
-            var srx = e.rx * sx, sry = e.ry * sy;
-            return (rotx * rotx) * (sry * sry) + (roty * roty) * (srx * srx) <= (srx * srx) * (sry * sry);
-        }
-    }
-}

+ 0 - 679
pandora/singletons/Easings.js

@@ -1,679 +0,0 @@
-/************************************************************************
- * Easings.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/>.
- *************************************************************************/
-
-/**
- *
- * Derived from Robert Penner's easing equations: http://robertpenner.com/easing/
- * The original copyright notice is as follows:
- * 
- * TERMS OF USE - EASING EQUATIONS
- * 
- * Open source under the BSD License.
- * 
- * Copyright © 2001 Robert Penner
- * All rights reserved.
- * 
- * Redistribution and use in source and binary forms, with or without modification,
- * are permitted provided that the following conditions are met:
- * 
- * Redistributions of source code must retain the above copyright notice, this list of
- * conditions and the following disclaimer.
- * Redistributions in binary form must reproduce the above copyright notice, this list
- * of conditions and the following disclaimer in the documentation and/or other materials
- * provided with the distribution.
- * 
- * Neither the name of the author nor the names of contributors may be used to endorse
- * or promote products derived from this software without specific prior written permission.
- * 
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY
- * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
- * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
- * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
- * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
- * GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
- * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
- * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
- * OF THE POSSIBILITY OF SUCH DAMAGE.
- *
- */
-
-/**
- * This {@code Easings} singleton provides an interface for the engine to utilize
- * various easing equations. Used mostly on the Tween GameObject. User can access this
- * API, but it is not recomended; try using tweens instead.
- * 
- * @author Pedro Schneider
- * 
- * @namespace
- */
-const Easings = {
-    // * See https://easings.net/ for more details on each type of easing.
-
-    /**
-     * Namespace to separate linear easing equations.
-     * 
-     * @namespace
-     */
-    Linear:
-    {
-        /**
-         * Calculates a linear easing.
-         * 
-         * @param {number} t    current time of the easing process.
-         * @param {number} b    beginning value of the esasing process.
-         * @param {number} c    change in vlaue during the easing process.
-         * @param {number} d    total duration of the easing process.
-         *  
-         * @returns {number}    current value in the easing process.
-         */
-        ease: function(t, b, c, d)
-        {
-            return b + (c * t / d);
-        }
-    },
-
-    /**
-     * Namespace to separate quadratic easing equations.
-     * 
-     * @namespace
-     */
-    Quad:
-    {
-        /**
-         * Calculates a quadratic ease-in.
-         * 
-         * @param {number} t    current time of the easing process.
-         * @param {number} b    beginning value of the esasing process.
-         * @param {number} c    change in vlaue during the easing process.
-         * @param {number} d    total duration of the easing process.
-         *  
-         * @returns {number}    current value in the easing process.
-         */
-        easeIn: function(t, b, c, d)
-        {
-            return c * (t /= d) * t + b;
-        },
-
-        /**
-         * Calculates a quadratic ease-out.
-         * 
-         * @param {number} t    current time of the easing process.
-         * @param {number} b    beginning value of the esasing process.
-         * @param {number} c    change in vlaue during the easing process.
-         * @param {number} d    total duration of the easing process.
-         *  
-         * @returns {number}    current value in the easing process.
-         */
-        easeOut: function(t, b, c, d)
-        {
-            return -c * (t /= d) * (t - 2) + b;
-        },
-
-        /**
-         * Calculates a quadratic ease-in and out.
-         * 
-         * @param {number} t    current time of the easing process.
-         * @param {number} b    beginning value of the esasing process.
-         * @param {number} c    change in vlaue during the easing process.
-         * @param {number} d    total duration of the easing process.
-         *  
-         * @returns {number}    current value in the easing process.
-         */
-        easeInOut: function(t, b, c, d)
-        {
-            if ((t /= d / 2) < 1) return c / 2 * t * t + b;
-            return -c / 2 * ((--t) * (t - 2) - 1) + b;
-        }
-    },
-
-    /**
-     * Namespace to separate cubic easing equations.
-     * 
-     * @namespace
-     */
-    Cubic:
-    {
-        /**
-         * Calculates a cubic ease-in.
-         * 
-         * @param {number} t    current time of the easing process.
-         * @param {number} b    beginning value of the esasing process.
-         * @param {number} c    change in vlaue during the easing process.
-         * @param {number} d    total duration of the easing process.
-         *  
-         * @returns {number}    current value in the easing process.
-         */
-        easeIn: function(t, b, c, d)
-        {
-            return c * (t /= d) * t * t + b;
-        },
-
-        /**
-         * Calculates a cubic ease-out.
-         * 
-         * @param {number} t    current time of the easing process.
-         * @param {number} b    beginning value of the esasing process.
-         * @param {number} c    change in vlaue during the easing process.
-         * @param {number} d    total duration of the easing process.
-         *  
-         * @returns {number}    current value in the easing process.
-         */
-        easeOut: function(t, b, c, d)
-        {
-            return c * ((t = t / d - 1) * t * t + 1) + b;
-        },
-
-        /**
-         * Calculates a cubic ease-in and out.
-         * 
-         * @param {number} t    current time of the easing process.
-         * @param {number} b    beginning value of the esasing process.
-         * @param {number} c    change in vlaue during the easing process.
-         * @param {number} d    total duration of the easing process.
-         *  
-         * @returns {number}    current value in the easing process.
-         */
-        easeInOut: function(t, b, c, d)
-        {
-            if ((t /= d / 2) < 1) return c / 2 * t * t * t + b;
-            return c / 2 * ((t -= 2) * t * t + 2) + b;
-        }
-    },
-
-    /**
-     * Namespace to separate quartic easing equations.
-     * 
-     * @namespace
-     */
-    Quart:
-    {
-        /**
-         * Calculates a quartic ease-in.
-         * 
-         * @param {number} t    current time of the easing process.
-         * @param {number} b    beginning value of the esasing process.
-         * @param {number} c    change in vlaue during the easing process.
-         * @param {number} d    total duration of the easing process.
-         *  
-         * @returns {number}    current value in the easing process.
-         */
-        easeIn: function(t, b, c, d)
-        {
-            return c * (t /= d) * t * t * t + b;
-        },
-
-        /**
-         * Calculates a quartic ease-out.
-         * 
-         * @param {number} t    current time of the easing process.
-         * @param {number} b    beginning value of the esasing process.
-         * @param {number} c    change in vlaue during the easing process.
-         * @param {number} d    total duration of the easing process.
-         *  
-         * @returns {number}    current value in the easing process.
-         */
-        easeOut: function(t, b, c, d)
-        {
-            return -c * ((t = t / d - 1) * t * t * t - 1) + b;
-        },
-
-        /**
-         * Calculates a quartic ease-in and out.
-         * 
-         * @param {number} t    current time of the easing process.
-         * @param {number} b    beginning value of the esasing process.
-         * @param {number} c    change in vlaue during the easing process.
-         * @param {number} d    total duration of the easing process.
-         *  
-         * @returns {number}    current value in the easing process.
-         */
-        easeInOut: function(t, b, c, d)
-        {
-            if ((t /= d / 2) < 1) return c / 2 * t * t * t * t + b;
-            return -c / 2 * ((t -= 2) * t * t * t - 2) + b;
-        }
-    },
-
-    /**
-     * Namespace to separate quintic easing equations.
-     * 
-     * @namespace
-     */
-    Quint:
-    {
-        /**
-         * Calculates a quintic ease-in.
-         * 
-         * @param {number} t    current time of the easing process.
-         * @param {number} b    beginning value of the esasing process.
-         * @param {number} c    change in vlaue during the easing process.
-         * @param {number} d    total duration of the easing process.
-         *  
-         * @returns {number}    current value in the easing process.
-         */
-        easeIn: function(t, b, c, d)
-        {
-            return c * (t /= d) * t * t * t * t + b;
-        },
-
-        /**
-         * Calculates a quintic ease-out.
-         * 
-         * @param {number} t    current time of the easing process.
-         * @param {number} b    beginning value of the esasing process.
-         * @param {number} c    change in vlaue during the easing process.
-         * @param {number} d    total duration of the easing process.
-         *  
-         * @returns {number}    current value in the easing process.
-         */
-        easeOut: function(t, b, c, d)
-        {
-            return c * ((t = t / d - 1) * t * t * t * t + 1) + b;
-        },
-
-        /**
-         * Calculates a quintic ease-in and out.
-         * 
-         * @param {number} t    current time of the easing process.
-         * @param {number} b    beginning value of the esasing process.
-         * @param {number} c    change in vlaue during the easing process.
-         * @param {number} d    total duration of the easing process.
-         *  
-         * @returns {number}    current value in the easing process.
-         */
-        easeInOut: function(t, b, c, d)
-        {
-            if ((t /= d / 2) < 1) return c / 2 * t * t * t * t * t + b;
-            return c / 2 * ((t -= 2) * t * t * t * t + 2) + b;
-        }
-    },
-
-    /**
-     * Namespace to separate senoidal easing equations.
-     * 
-     * @namespace
-     */
-    Sine:
-    {
-        /**
-         * Calculates a senoidal ease-in;
-         * 
-         * @param {number} t    current time of the easing process.
-         * @param {number} b    beginning value of the esasing process.
-         * @param {number} c    change in vlaue during the easing process.
-         * @param {number} d    total duration of the easing process.
-         *  
-         * @returns {number}    current value in the easing process.
-         */
-        easeIn: function(t, b, c, d)
-        {
-            return -c * Math.cos(t / d * (Math.PI / 2)) + c + b;
-        },
-
-        /**
-         * Calculates a senoidal ease-out.
-         * 
-         * @param {number} t    current time of the easing process.
-         * @param {number} b    beginning value of the esasing process.
-         * @param {number} c    change in vlaue during the easing process.
-         * @param {number} d    total duration of the easing process.
-         *  
-         * @returns {number}    current value in the easing process.
-         */
-        easeOut: function(t, b, c, d)
-        {
-            return c * Math.sin(t / d * (Math.PI / 2)) + b;
-        },
-
-        /**
-         * Calculates a senoidal ease-in and out.
-         * 
-         * @param {number} t    current time of the easing process.
-         * @param {number} b    beginning value of the esasing process.
-         * @param {number} c    change in vlaue during the easing process.
-         * @param {number} d    total duration of the easing process.
-         *  
-         * @returns {number}    current value in the easing process.
-         */
-        easeInOut: function(t, b, c, d)
-        {
-            return -c / 2 * (Math.cos(Math.PI * t / d) - 1) + b;
-        }
-    },
-
-    /**
-     * Namespace to separate exponential easing equations.
-     * 
-     * @namespace
-     */
-    Expo:
-    {
-        /**
-         * Calculates an exponential ease-in.
-         * 
-         * @param {number} t    current time of the easing process.
-         * @param {number} b    beginning value of the esasing process.
-         * @param {number} c    change in vlaue during the easing process.
-         * @param {number} d    total duration of the easing process.
-         *  
-         * @returns {number}    current value in the easing process.
-         */
-        easeIn: function(t, b, c, d)
-        {
-            return (t == 0) ? b : c * Math.pow(2, 10 * (t / d - 1)) + b;
-        },
-
-        /**
-         * Calculates an exponential ease-out.
-         * 
-         * @param {number} t    current time of the easing process.
-         * @param {number} b    beginning value of the esasing process.
-         * @param {number} c    change in vlaue during the easing process.
-         * @param {number} d    total duration of the easing process.
-         *  
-         * @returns {number}    current value in the easing process.
-         */
-        easeOut: function(t, b, c, d)
-        {
-            return (t == d) ? b + c : c * (-Math.pow(2, -10 * t / d) + 1) + b;
-        },
-
-        /**
-         * Calculates an exponential ease-in and out.
-         * 
-         * @param {number} t    current time of the easing process.
-         * @param {number} b    beginning value of the esasing process.
-         * @param {number} c    change in vlaue during the easing process.
-         * @param {number} d    total duration of the easing process.
-         *  
-         * @returns {number}    current value in the easing process.
-         */
-        easeInOut: function(t, b, c, d)
-        {
-            if (t == 0) return b;
-            if (t == d) return b + c;
-            if ((t /= d / 2) < 1) return c / 2 * Math.pow(2, 10 * (t - 1)) + b;
-            return c / 2 * (-Math.pow(2, -10 * --t) + 2) + b;
-        }
-    },
-
-    /**
-     * Namespace to separate circular easing equations.
-     * 
-     * @namespace
-     */
-    Circ:
-    {
-        /**
-         * Calculates a circular ease-in.
-         * 
-         * @param {number} t    current time of the easing process.
-         * @param {number} b    beginning value of the esasing process.
-         * @param {number} c    change in vlaue during the easing process.
-         * @param {number} d    total duration of the easing process.
-         *  
-         * @returns {number}    current value in the easing process.
-         */
-        easeIn: function(t, b, c, d)
-        {
-            return -c * (Math.sqrt(1 - (t /= d) * t) - 1) + b;
-        },
-
-        /**
-         * Calculates a circular ease-out.
-         * 
-         * @param {number} t    current time of the easing process.
-         * @param {number} b    beginning value of the esasing process.
-         * @param {number} c    change in vlaue during the easing process.
-         * @param {number} d    total duration of the easing process.
-         *  
-         * @returns {number}    current value in the easing process.
-         */
-        easeOut: function(t, b, c, d)
-        {
-            return c * Math.sqrt(1 - (t = t / d - 1) * t) + b;
-        },
-
-        /**
-         * Calculates a circular ease-in and out.
-         * 
-         * @param {number} t    current time of the easing process.
-         * @param {number} b    beginning value of the esasing process.
-         * @param {number} c    change in vlaue during the easing process.
-         * @param {number} d    total duration of the easing process.
-         *  
-         * @returns {number}    current value in the easing process.
-         */
-        easeInOut: function(t, b, c, d)
-        {
-            if ((t /= d / 2) < 1) return -c / 2 * (Math.sqrt(1 - t * t) - 1) + b;
-            return c / 2 * (Math.sqrt(1 - (t -= 2) * t) + 1) + b;
-        }
-    },
-
-    /**
-     * Namespace to separate elastic easing equations.
-     * 
-     * @namespace
-     */
-    Elastic:
-    {
-        /**
-         * Calculates an elastic ease-in.
-         * 
-         * @param {number} t    current time of the easing process.
-         * @param {number} b    beginning value of the esasing process.
-         * @param {number} c    change in vlaue during the easing process.
-         * @param {number} d    total duration of the easing process.
-         *  
-         * @returns {number}    current value in the easing process.
-         */
-        easeIn: function(t, b, c, d)
-        {
-            var s = 1.70158;
-            var p = 0;
-            var a = c;
-            if (t == 0) return b;
-            if ((t /= d) == 1) return b + c;
-            if (!p) p = d * .3;
-            if (a < Math.abs(c))
-            {
-                a = c;
-                var s = p / 4;
-            }
-            else var s = p / (2 * Math.PI) * Math.asin(c / a);
-            return -(a * Math.pow(2, 10 * (t -= 1)) * Math.sin((t * d - s) * (2 * Math.PI) / p)) + b;
-        },
-
-        /**
-         * Calculates an elastic ease-out.
-         * 
-         * @param {number} t    current time of the easing process.
-         * @param {number} b    beginning value of the esasing process.
-         * @param {number} c    change in vlaue during the easing process.
-         * @param {number} d    total duration of the easing process.
-         *  
-         * @returns {number}    current value in the easing process.
-         */
-        easeOut: function(t, b, c, d)
-        {
-            var s = 1.70158;
-            var p = 0;
-            var a = c;
-            if (t == 0) return b;
-            if ((t /= d) == 1) return b + c;
-            if (!p) p = d * .3;
-            if (a < Math.abs(c))
-            {
-                a = c;
-                var s = p / 4;
-            }
-            else var s = p / (2 * Math.PI) * Math.asin(c / a);
-            return a * Math.pow(2, -10 * t) * Math.sin((t * d - s) * (2 * Math.PI) / p) + c + b;
-        },
-
-        /**
-         * Calculates an elastic ease-in and out.
-         * 
-         * @param {number} t    current time of the easing process.
-         * @param {number} b    beginning value of the esasing process.
-         * @param {number} c    change in vlaue during the easing process.
-         * @param {number} d    total duration of the easing process.
-         *  
-         * @returns {number}    current value in the easing process.
-         */
-        easeInOut: function(t, b, c, d)
-        {
-            var s = 1.70158;
-            var p = 0;
-            var a = c;
-            if (t == 0) return b;
-            if ((t /= d / 2) == 2) return b + c;
-            if (!p) p = d * (.3 * 1.5);
-            if (a < Math.abs(c))
-            {
-                a = c;
-                var s = p / 4;
-            }
-            else var s = p / (2 * Math.PI) * Math.asin(c / a);
-            if (t < 1) return -.5 * (a * Math.pow(2, 10 * (t -= 1)) * Math.sin((t * d - s) * (2 * Math.PI) / p)) + b;
-            return a * Math.pow(2, -10 * (t -= 1)) * Math.sin((t * d - s) * (2 * Math.PI) / p) * .5 + c + b;
-        },
-    },
-
-    /**
-     * Namespace to separate back easing equations.
-     * 
-     * @namespace
-     */
-    Back:
-    {
-        /**
-         * Calculates a back ease-in.
-         * 
-         * @param {number} t    current time of the easing process.
-         * @param {number} b    beginning value of the esasing process.
-         * @param {number} c    change in vlaue during the easing process.
-         * @param {number} d    total duration of the easing process.
-         *  
-         * @returns {number}    current value in the easing process.
-         */
-        easeIn: function(t, b, c, d)
-        {
-            var s = 1.70158;
-            return c * (t /= d) * t * ((s + 1) * t - s) + b;
-        },
-
-        /**
-         * Calculates a back ease-out.
-         * 
-         * @param {number} t    current time of the easing process.
-         * @param {number} b    beginning value of the esasing process.
-         * @param {number} c    change in vlaue during the easing process.
-         * @param {number} d    total duration of the easing process.
-         *  
-         * @returns {number}    current value in the easing process.
-         */
-        easeOut: function(t, b, c, d)
-        {
-            var s = 1.70158;
-            return c * ((t = t / d - 1) * t * ((s + 1) * t + s) + 1) + b;
-        },
-
-        /**
-         * Calculates a back ease-in and out.
-         * 
-         * @param {number} t    current time of the easing process.
-         * @param {number} b    beginning value of the esasing process.
-         * @param {number} c    change in vlaue during the easing process.
-         * @param {number} d    total duration of the easing process.
-         *  
-         * @returns {number}    current value in the easing process.
-         */
-        easeInOut: function(t, b, c, d)
-        {
-            var s = 1.70158;
-            if ((t /= d / 2) < 1) return c / 2 * (t * t * (((s *= (1.525)) + 1) * t - s)) + b;
-            return c / 2 * ((t -= 2) * t * (((s *= (1.525)) + 1) * t + s) + 2) + b;
-        }
-    },
-
-    /**
-     * Namespace to separate bounce easing equations.
-     * 
-     * @namespace
-     */
-    Bounce:
-    {
-        /**
-         * Calculates a bounce ease-in.
-         * 
-         * @param {number} t    current time of the easing process.
-         * @param {number} b    beginning value of the esasing process.
-         * @param {number} c    change in vlaue during the easing process.
-         * @param {number} d    total duration of the easing process.
-         *  
-         * @returns {number}    current value in the easing process.
-         */
-        easeIn: function(t, b, c, d)
-        {
-            return c - Easings.Bounce.easeOut(d - t, 0, c, d) + b;
-        },
-
-        /**
-         * Calculates a bounce ease-out.
-         * 
-         * @param {number} t    current time of the easing process.
-         * @param {number} b    beginning value of the esasing process.
-         * @param {number} c    change in vlaue during the easing process.
-         * @param {number} d    total duration of the easing process.
-         *  
-         * @returns {number}    current value in the easing process.
-         */
-        easeOut: function(t, b, c, d)
-        {
-            if ((t /= d) < (1 / 2.75))
-                return c * (7.5625 * t * t) + b;
-            else if (t < (2 / 2.75))
-                return c * (7.5625 * (t -= (1.5 / 2.75)) * t + .75) + b;
-            else if (t < (2.5 / 2.75))
-                return c * (7.5625 * (t -= (2.25 / 2.75)) * t + .9375) + b;
-            else
-                return c * (7.5625 * (t -= (2.625 / 2.75)) * t + .984375) + b;
-        },
-
-        /**
-         * Calculates a bounce ease-in and out.
-         * 
-         * @param {number} t    current time of the easing process.
-         * @param {number} b    beginning value of the esasing process.
-         * @param {number} c    change in vlaue during the easing process.
-         * @param {number} d    total duration of the easing process.
-         *  
-         * @returns {number}    current value in the easing process.
-         */
-        easeInOut: function(t, b, c, d)
-        {
-            if (t < d / 2) return Easings.Bounce.easeIn(t * 2, 0, c, d) * .5 + b;
-            return Easings.Bounce.easeOut(t * 2 - d, 0, c, d) * .5 + c * .5 + b;
-        }
-    },
-}

+ 0 - 92
pandora/singletons/Enums.js

@@ -1,92 +0,0 @@
-/************************************************************************
- * Enums.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/>.
- *************************************************************************/
-
-/**
- * This {@code Enums} file provides several useful constant enumerators the engine
- * uses internaly. Users may find these useful for calling certain functions.
- * 
- * @author Pedro Schneider
- */
-
-
-/**
- * Enumerates property types.
- */
-const PROPERTY_TYPE = {
-    NUMBER: 1,
-    VECTOR2: 2,
-    COLOR: 3,
-};
-
-/**
- * Enumerates shape types.
- */
-const SHAPES = {
-    RECT: 1,
-    ELLIPSE: 2,
-};
-
-/**
- * Enumerates transition types.
- */
-const TRANS_TYPE = {
-    LINEAR: 1,
-    QUAD: 2,
-    CUBIC: 3,
-    QUART: 4,
-    QUINT: 5,
-    SINE: 6,
-    EXPONENTIAL: 7,
-    CIRCULAR: 8,
-    ELASTIC: 9,
-    BACK: 10,
-    BOUNCE: 11,
-};
-
-/**
- * Enumerates easing types.
- */
-const EASE_TYPE = {
-    IN: 1,
-    OUT: 2,
-    IN_OUT: 3,
-};
-
-
-/**
- * Enumerates render modes.
- */
-const RENDER_MODES = {
-    P2D: 1,
-    WEBGL: 2,
-};
-
-/**
- * Object to hold information about the default styling of UIOBjects.
- */
-const STYLE = {
-    DEFAULT_FONT_SIZE: 20,
-
-    DEFAULT_STYLE:
-    {
-        "font-family": "Lato",
-    },
-}