From cd9a00b683e8c585e4c89ae95118725a71b2928d Mon Sep 17 00:00:00 2001
From: Micah Rufsvold <86363075+mrufsvold@users.noreply.github.com>
Date: Tue, 6 Feb 2024 22:42:11 -0500
Subject: [PATCH 1/7] add a playground file for scratch space to gitignore

---
 .gitignore | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/.gitignore b/.gitignore
index 64335931..1c954a2a 100644
--- a/.gitignore
+++ b/.gitignore
@@ -34,3 +34,5 @@ src/editor/EditorBuild/
 test/projects/ProfilingTest/Platformer/.vscode/settings.json
 
 .vscode/settings.json
+
+playground.jl

From 8ed11117791b800010ac0f89562d0038026650c3 Mon Sep 17 00:00:00 2001
From: Micah Rufsvold <86363075+mrufsvold@users.noreply.github.com>
Date: Tue, 6 Feb 2024 22:53:49 -0500
Subject: [PATCH 2/7] move function name ownership up to component module

---
 src/Component/Animation.jl          | 13 +++----
 src/Component/Animator.jl           | 25 +++++++-------
 src/Component/CircleCollider.jl     | 25 +++++++-------
 src/Component/Collider.jl           | 53 +++++++++++++++--------------
 src/Component/Component.jl          | 21 ++++++------
 src/Component/ComponentFunctions.jl | 39 +++++++++++++++++++++
 src/Component/Rigidbody.jl          | 21 ++++++------
 src/Component/Shape.jl              | 10 +++---
 src/Component/SoundSource.jl        | 21 ++++++------
 src/Component/Sprite.jl             | 29 ++++++++--------
 src/Component/Transform.jl          | 34 +++++++++---------
 11 files changed, 170 insertions(+), 121 deletions(-)
 create mode 100644 src/Component/ComponentFunctions.jl

diff --git a/src/Component/Animation.jl b/src/Component/Animation.jl
index bcb54666..ace07b59 100644
--- a/src/Component/Animation.jl
+++ b/src/Component/Animation.jl
@@ -1,5 +1,6 @@
 module AnimationModule 
     using ..Component.JulGame
+    import ..Component
     import .JulGame: deprecated_get_property
     export Animation
     mutable struct Animation
@@ -18,25 +19,25 @@ module AnimationModule
 
     function Base.getproperty(this::Animation, s::Symbol)
         method_props = (
-            updateArrayValue = update_array_value,
-            appendArray = append_array,
-            getType = get_type
+            updateArrayValue = Component.update_array_value,
+            appendArray = Component.append_array,
+            getType = Component.get_type
         )
         deprecated_get_property(method_props, this, s)
     end
     
-    function update_array_value(this::Animation, value, field, index::Int32)
+    function Component.update_array_value(this::Animation, value, field, index::Int32)
         fieldToUpdate = getfield(this, field)
         if this.getType(value) == "_Vector4"
             fieldToUpdate[index] = Math.Vector4(value.x, value.y, value.z, value.t)
         end
     end
     
-    function append_array(this::Animation)
+    function Component.append_array(this::Animation)
         push!(this.frames, Math.Vector4(0,0,0,0))
     end
     
-    function get_type(this::Animation, item)
+    function Component.get_type(this::Animation, item)
         componentFieldType = "$(typeof(item).name.wrapper)"
         return String(split(componentFieldType, '.')[length(split(componentFieldType, '.'))])
     end
diff --git a/src/Component/Animator.jl b/src/Component/Animator.jl
index 0cf4eb7a..fafb9f7d 100644
--- a/src/Component/Animator.jl
+++ b/src/Component/Animator.jl
@@ -4,6 +4,7 @@
     using ..Component.JulGame.Math
     using ..Component.SpriteModule
     import ..Component.JulGame: deprecated_get_property
+    import ..Component
     export Animator
     struct Animator
         animations::Vector{Animation}
@@ -34,39 +35,39 @@
 
     function Base.getproperty(this::InternalAnimator, s::Symbol)
         method_props = (
-            getLastUpdate = get_last_update,
-            setLastUpdate = set_last_update,
-            update = update,
-            setSprite = set_sprite,
-            setParent = set_parent,
-            appendArray = append_array
+            getLastUpdate = Component.get_last_update,
+            setLastUpdate = Component.set_last_update,
+            update = Component.update,
+            setSprite = Component.set_sprite,
+            setParent = Component.set_parent,
+            appendArray = Component.append_array
         )
 
         deprecated_get_property(method_props, this, s)
     end
 
     
-    function get_last_update(this::InternalAnimator)
+    function Component.get_last_update(this::InternalAnimator)
         return this.lastUpdate
     end
 
-    function set_last_update(this::InternalAnimator, value)
+    function Component.set_last_update(this::InternalAnimator, value)
         this.lastUpdate = value
     end
 
-    function update(this::InternalAnimator, currentRenderTime, deltaTime)
+    function Component.update(this::InternalAnimator, currentRenderTime, deltaTime)
         Update(this, currentRenderTime, deltaTime)
     end
 
-    function set_sprite(this::InternalAnimator, sprite)
+    function Component.set_sprite(this::InternalAnimator, sprite)
         this.sprite = sprite
     end
 
-    function set_parent(this::InternalAnimator, parent)
+    function Component.set_parent(this::InternalAnimator, parent)
         this.parent = parent
     end
 
-    function append_array(this::InternalAnimator)
+    function Component.append_array(this::InternalAnimator)
         push!(this.animations, Animation([Math.Vector4(0,0,0,0)], Int32(60)))
     end
     
diff --git a/src/Component/CircleCollider.jl b/src/Component/CircleCollider.jl
index 2c5134cf..b930a2f2 100644
--- a/src/Component/CircleCollider.jl
+++ b/src/Component/CircleCollider.jl
@@ -3,6 +3,7 @@ module CircleColliderModule
     using ..Component.JulGame
     using ..Component.ColliderModule
     import ..Component.JulGame: deprecated_get_property
+    import ..Component
 
     export CircleCollider
     struct CircleCollider
@@ -47,21 +48,21 @@ module CircleColliderModule
 
     function Base.getproperty(this::CircleCollider, s::Symbol)
         method_props = (
-            getSize = get_size,
-            checkCollisions = check_collisions,
-            setParent = set_parent,
-            getParent = get_parent,
-            addCollisionEvent = add_collision_event,
-            getType = get_type
+            getSize = Component.get_size,
+            checkCollisions = Component.check_collisions,
+            setParent = Component.set_parent,
+            getParent = Component.get_parent,
+            addCollisionEvent = Component.add_collision_event,
+            getType = Component.get_type
         )
         deprecated_get_property(method_props, this, s)
     end
     
-    function get_size(this::CircleCollider)
+    function Component.get_size(this::CircleCollider)
         return this.size
     end
 
-    function check_collisions(this::CircleCollider)
+    function Component.check_collisions(this::CircleCollider)
         colliders = MAIN.scene.colliders
         #Only check the player against other colliders
         counter = 0
@@ -145,19 +146,19 @@ module CircleColliderModule
         this.currentCollisions = []
     end
 
-    function set_parent(this::CircleCollider, parent::Any)
+    function Component.set_parent(this::CircleCollider, parent::Any)
         this.parent = parent
     end
 
-    function get_parent(this::CircleCollider)
+    function Component.get_parent(this::CircleCollider)
         return this.parent
     end
 
-    function add_collision_event(this::CircleCollider, event)
+    function Component.add_collision_event(this::CircleCollider, event)
         push!(this.collisionEvents, event)
     end   
 
-    function get_type(this::CircleCollider)
+    function Component.get_type(this::CircleCollider)
         return "CircleCollider"
     end
 
diff --git a/src/Component/Collider.jl b/src/Component/Collider.jl
index be27f42f..90e6dd5b 100644
--- a/src/Component/Collider.jl
+++ b/src/Component/Collider.jl
@@ -2,6 +2,7 @@ module ColliderModule
     include("../Enums.jl")
     using ..Component.JulGame
     import ..Component.JulGame: deprecated_get_property
+    import ..Component 
 
     export Collider
     struct Collider
@@ -52,56 +53,56 @@ module ColliderModule
 
     function Base.getproperty(this::InternalCollider, s::Symbol)
         method_props = (
-            getSize = get_size,
-            setSize = set_size,
-            getOffset = get_offset,
-            setOffset = set_offset,
-            getTag = get_tag,
-            setTag = set_tag,
-            getParent = get_parent,
-            setParent = set_parent,
-            checkCollisions = check_collisions,
-            update = update,
-            addCollisionEvent = add_collision_event,
-            setVector2fValue = set_vector2f_value,
-            getType = get_type
+            getSize = Component.get_size,
+            setSize = Component.set_size,
+            getOffset = Component.get_offset,
+            setOffset = Component.set_offset,
+            getTag = Component.get_tag,
+            setTag = Component.set_tag,
+            getParent = Component.get_parent,
+            setParent = Component.set_parent,
+            checkCollisions = Component.check_collisions,
+            update = Component.update,
+            addCollisionEvent = Component.add_collision_event,
+            setVector2fValue = Component.set_vector2f_value,
+            getType = Component.get_type
         )
         deprecated_get_property(method_props, this, s)
     end
     
-    function get_size(this::InternalCollider)
+    function Component.get_size(this::InternalCollider)
         return this.size
     end
 
-    function set_size(this::InternalCollider, size::Math.Vector2f)
+    function Component.set_size(this::InternalCollider, size::Math.Vector2f)
         this.size = size
     end
 
-    function get_offset(this::InternalCollider)
+    function Component.get_offset(this::InternalCollider)
         return this.offset
     end
 
-    function set_offset(this::InternalCollider, offset::Math.Vector2f)
+    function Component.set_offset(this::InternalCollider, offset::Math.Vector2f)
         this.offset = offset
     end
 
-    function get_tag(this::InternalCollider)
+    function Component.get_tag(this::InternalCollider)
         return this.tag
     end
 
-    function set_tag(this::InternalCollider, tag::String)
+    function Component.set_tag(this::InternalCollider, tag::String)
         this.tag = tag
     end
 
-    function get_parent(this::InternalCollider)
+    function Component.get_parent(this::InternalCollider)
         return this.parent
     end
 
-    function set_parent(this::InternalCollider, parent::Any)
+    function Component.set_parent(this::InternalCollider, parent::Any)
         this.parent = parent
     end
 
-    function check_collisions(this::InternalCollider)
+    function Component.check_collisions(this::InternalCollider)
         colliders = MAIN.scene.colliders
         #Only check the player against other colliders
         counter = 0
@@ -203,19 +204,19 @@ module ColliderModule
         this.currentCollisions = InternalCollider[]
     end
 
-    function update(this::InternalCollider)
+    function Component.update(this::InternalCollider)
         
     end
 
-    function add_collision_event(this::InternalCollider, event)
+    function Component.add_collision_event(this::InternalCollider, event)
         push!(this.collisionEvents, event)
     end        
 
-    function set_vector2f_value(this::InternalCollider, field, x, y)
+    function Component.set_vector2f_value(this::InternalCollider, field, x, y)
         setfield!(this, field, Math.Vector2f(x,y))
     end
 
-    function get_type(this::InternalCollider)
+    function Component.get_type(this::InternalCollider)
         return "Collider"
     end
     
diff --git a/src/Component/Component.jl b/src/Component/Component.jl
index 2f8832f7..0442e6d8 100644
--- a/src/Component/Component.jl
+++ b/src/Component/Component.jl
@@ -1,14 +1,15 @@
 module Component
     using ..JulGame
-      include("Transform.jl")
-      include("Sprite.jl")
-      include("Animation.jl")
-      include("Animator.jl")
-      include("Collider.jl")
-      include("CircleCollider.jl")
-      include("Rigidbody.jl")
-      include("Shape.jl")
-      include("SoundSource.jl")
+    include("ComponentFunctions.jl")
+    include("Transform.jl")
+    include("Sprite.jl")
+    include("Animation.jl")
+    include("Animator.jl")
+    include("Collider.jl")
+    include("CircleCollider.jl")
+    include("Rigidbody.jl")
+    include("Shape.jl")
+    include("SoundSource.jl")
     
     export AnimationModule
     export AnimatorModule
@@ -19,4 +20,4 @@ module Component
     export SoundSourceModule
     export SpriteModule
     export TransformModule
-end
\ No newline at end of file
+end
diff --git a/src/Component/ComponentFunctions.jl b/src/Component/ComponentFunctions.jl
new file mode 100644
index 00000000..3b775cc8
--- /dev/null
+++ b/src/Component/ComponentFunctions.jl
@@ -0,0 +1,39 @@
+# Declare Common Functions so that they can be dispatched from ModuleExtensions
+function add_collision_event end
+function append_array end
+function append_array end
+function apply_forces end
+function check_collisions end
+function destroy end
+function draw end
+function draw end
+function flip end
+function get_last_update end
+function get_offset end
+function get_parent end
+function get_position end
+function get_rotation end
+function get_scale end
+function get_size end
+function get_tag end
+function get_type end
+function get_velocity end
+function initialize end
+function load_image end
+function load_sound end
+function set_color end
+function set_last_update end
+function set_offset end
+function set_parent end
+function set_position end
+function set_rotation end
+function set_scale end
+function set_size end
+function set_sprite end
+function set_tag end
+function set_vector2f_value end
+function stop_music end
+function toggle_sound end
+function unload_sound end
+function update end
+function update_array_value end
diff --git a/src/Component/Rigidbody.jl b/src/Component/Rigidbody.jl
index c6a8ed88..2993c859 100644
--- a/src/Component/Rigidbody.jl
+++ b/src/Component/Rigidbody.jl
@@ -1,6 +1,7 @@
 module RigidbodyModule
     using ..Component.JulGame
     import ..Component.JulGame: deprecated_get_property
+    import ..Component
     export Rigidbody
     struct Rigidbody
         mass::Float64
@@ -41,16 +42,16 @@
     function Base.getproperty(this::InternalRigidbody, s::Symbol)
         # Todo: update this based on offset and scale
         method_props = (
-            update = update,
-            applyForces = apply_forces,
-            getVelocity = get_velocity,
-            getParent = get_parent,
-            setVector2fValue = set_vector2f_value
+            update = Component.update,
+            applyForces = Component.apply_forces,
+            getVelocity = Component.get_velocity,
+            getParent = Component.get_parent,
+            setVector2fValue = Component.set_vector2f_value
         )
         deprecated_get_property(method_props, this, s)
     end
 
-    function update(this::InternalRigidbody, dt)
+    function Component.update(this::InternalRigidbody, dt)
         velocityMultiplier = Math.Vector2f(1.0, 1.0)
         transform = this.parent.transform
         currentPosition = transform.getPosition()
@@ -72,22 +73,22 @@
         end
     end
 
-    function apply_forces(this::InternalRigidbody)
+    function Component.apply_forces(this::InternalRigidbody)
         gravityAcceleration = Math.Vector2f(0.0, this.useGravity ? GRAVITY : 0.0)
         dragForce = 0.5 * this.drag * (this.velocity * this.velocity)
         dragAcceleration = dragForce / this.mass
         return gravityAcceleration - dragAcceleration
     end
 
-    function get_velocity(this::InternalRigidbody)
+    function Component.get_velocity(this::InternalRigidbody)
         return this.velocity
     end
 
-    function get_parent(this::InternalRigidbody)
+    function Component.get_parent(this::InternalRigidbody)
         return this.parent
     end
 
-    function set_vector2f_value(this::InternalRigidbody, field, x, y)
+    function Component.set_vector2f_value(this::InternalRigidbody, field, x, y)
         setfield!(this, field, Math.Vector2f(x,y))
     end
 
diff --git a/src/Component/Shape.jl b/src/Component/Shape.jl
index d1480064..9d3a76e0 100644
--- a/src/Component/Shape.jl
+++ b/src/Component/Shape.jl
@@ -1,7 +1,7 @@
 module ShapeModule
     using ..Component.JulGame
     import ..Component.JulGame: deprecated_get_property
-
+    import ..Component
     export Shape
     struct Shape
         color::Math.Vector3
@@ -39,13 +39,13 @@ module ShapeModule
 
     function Base.getproperty(this::InternalShape, s::Symbol)
         method_props = (
-            draw = draw,
-            setParent = set_parent
+            draw = Component.draw,
+            setParent = Component.set_parent
         )
         deprecated_get_property(method_props, this, s)
     end
 
-    function draw(this::InternalShape)
+    function Component.draw(this::InternalShape)
         if JulGame.Renderer == C_NULL
             return                    
         end
@@ -69,7 +69,7 @@ module ShapeModule
         
     end
 
-    function set_parent(this::InternalShape, parent::Any)
+    function Component.set_parent(this::InternalShape, parent::Any)
         this.parent = parent
     end
 end
diff --git a/src/Component/SoundSource.jl b/src/Component/SoundSource.jl
index 2efde7d2..dfedfcd4 100644
--- a/src/Component/SoundSource.jl
+++ b/src/Component/SoundSource.jl
@@ -1,6 +1,7 @@
 module SoundSourceModule
     using ..JulGame
     import ..JulGame: deprecated_get_property
+    import ..Component
     
     export SoundSource
     struct SoundSource
@@ -53,16 +54,16 @@ module SoundSourceModule
     
     function Base.getproperty(this::InternalSoundSource, s::Symbol)
         method_props = (
-            toggleSound = toggle_sound,
-            stopMusic = stop_music,
-            loadSound = load_sound,
-            unloadSound = unload_sound,
-            setParent = set_parent
+            toggleSound = Component.toggle_sound,
+            stopMusic = Component.stop_music,
+            loadSound = Component.load_sound,
+            unloadSound = Component.unload_sound,
+            setParent = Component.set_parent
         )
         deprecated_get_property(method_props, this, s)
     end
 
-    function toggle_sound(this::InternalSoundSource, loops = 0)
+    function Component.toggle_sound(this::InternalSoundSource, loops = 0)
         if this.isMusic
             if SDL2.Mix_PlayingMusic() == 0
                 SDL2.Mix_PlayMusic( this.sound, Int32(-1) )
@@ -78,11 +79,11 @@ module SoundSourceModule
         end
     end
     
-    function stop_music(this::InternalSoundSource)
+    function Component.stop_music(this::InternalSoundSource)
         SDL2.Mix_HaltMusic()
     end
     
-    function load_sound(this::InternalSoundSource, soundPath::String, isMusic::Bool)
+    function Component.load_sound(this::InternalSoundSource, soundPath::String, isMusic::Bool)
         this.isMusic = isMusic
         this.sound =  this.isMusic ? SDL2.Mix_LoadMUS(joinpath(BasePath, "assets", "sounds", soundPath)) : SDL2.Mix_LoadWAV(joinpath(BasePath, "assets", "sounds", soundPath))
         error = unsafe_string(SDL2.SDL_GetError())
@@ -95,7 +96,7 @@ module SoundSourceModule
         this.path = soundPath
     end
 
-    function unload_sound(this::InternalSoundSource)
+    function Component.unload_sound(this::InternalSoundSource)
         if this.isMusic
             SDL2.Mix_FreeMusic(this.sound)
         else
@@ -104,7 +105,7 @@ module SoundSourceModule
         this.sound = C_NULL
     end
     
-    function set_parent(this::InternalSoundSource, parent::Any)
+    function Component.set_parent(this::InternalSoundSource, parent::Any)
         this.parent = parent
     end
 
diff --git a/src/Component/Sprite.jl b/src/Component/Sprite.jl
index 65399ed7..0f3f53a0 100644
--- a/src/Component/Sprite.jl
+++ b/src/Component/Sprite.jl
@@ -1,6 +1,7 @@
 module SpriteModule
     using ..Component.JulGame
     import ..Component.JulGame: deprecated_get_property
+    import ..Component
 
     export Sprite
     struct Sprite
@@ -76,17 +77,17 @@ module SpriteModule
 
     function Base.getproperty(this::InternalSprite, s::Symbol)
         method_props = (
-            draw = draw,
-            initialize = initialize,
-            flip = flip,
-            setParent = set_parent,
-            loadImage = load_image,
-            destroy = destroy,
-            setColor = set_color
+            draw = Component.draw,
+            initialize = Component.initialize,
+            flip = Component.flip,
+            setParent = Component.set_parent,
+            loadImage = Component.load_image,
+            destroy = Component.destroy,
+            setColor = Component.set_color
         )
         deprecated_get_property(method_props, this, s)
     end
-    function draw(this::InternalSprite, zoom::Float64 = 1.0)
+    function Component.draw(this::InternalSprite, zoom::Float64 = 1.0)
         if this.image == C_NULL || JulGame.Renderer == C_NULL
             return
         end
@@ -166,7 +167,7 @@ module SpriteModule
         end
     end
 
-    function initialize(this::InternalSprite)
+    function Component.initialize(this::InternalSprite)
         if this.image == C_NULL
             return
         end
@@ -174,15 +175,15 @@ module SpriteModule
         this.texture = SDL2.SDL_CreateTextureFromSurface(JulGame.Renderer, this.image)
     end
 
-    function flip(this::InternalSprite)
+    function Component.flip(this::InternalSprite)
         this.isFlipped = !this.isFlipped
     end
 
-    function set_parent(this::InternalSprite, parent::Any)
+    function Component.set_parent(this::InternalSprite, parent::Any)
         this.parent = parent
     end
 
-    function load_image(this::InternalSprite, imagePath::String)
+    function Component.load_image(this::InternalSprite, imagePath::String)
         SDL2.SDL_ClearError()
         this.image = SDL2.IMG_Load(joinpath(BasePath, "assets", "images", imagePath))
         error = unsafe_string(SDL2.SDL_GetError())
@@ -201,7 +202,7 @@ module SpriteModule
         this.setColor()
     end
 
-    function destroy(this::InternalSprite)
+    function Component.destroy(this::InternalSprite)
         if this.image == C_NULL
             return
         end
@@ -212,7 +213,7 @@ module SpriteModule
         this.texture = C_NULL
     end
 
-    function set_color(this::InternalSprite)
+    function Component.set_color(this::InternalSprite)
         SDL2.SDL_SetTextureColorMod(this.texture, UInt8(this.color.x%256), UInt8(this.color.y%256), (this.color.z%256));
     end
 end
diff --git a/src/Component/Transform.jl b/src/Component/Transform.jl
index 531ed8af..11da4454 100644
--- a/src/Component/Transform.jl
+++ b/src/Component/Transform.jl
@@ -1,6 +1,8 @@
 module TransformModule
     using ..Component.JulGame 
     import ..Component.JulGame: deprecated_get_property  
+    import ..Component
+    
     export Transform
     mutable struct Transform
         rotation::Float64
@@ -20,48 +22,48 @@ module TransformModule
 
     function Base.getproperty(this::Transform, s::Symbol)
         method_props = (
-            getPosition = get_position,
-            setPosition = set_position,
-            getScale = get_scale,
-            setScale = set_scale,
-            getRotation = get_rotation,
-            setRotation = set_rotation,
-            update = update,
-            setVector2fValue = set_vector2f_value
+            getPosition = Component.get_position,
+            setPosition = Component.set_position,
+            getScale = Component.get_scale,
+            setScale = Component.set_scale,
+            getRotation = Component.get_rotation,
+            setRotation = Component.set_rotation,
+            update = Component.update,
+            setVector2fValue = Component.set_vector2f_value
         )
         deprecated_get_property(method_props, this, s)
     end
 
 
-    function get_position(this::Transform)
+    function Component.get_position(this::Transform)
         return this.position
     end
 
-    function set_position(this::Transform, position::Math.Vector2f)
+    function Component.set_position(this::Transform, position::Math.Vector2f)
         this.position = position
     end
 
-    function get_scale(this::Transform)
+    function Component.get_scale(this::Transform)
         return this.scale
     end
 
-    function set_scale(this::Transform, scale::Math.Vector2f)
+    function Component.set_scale(this::Transform, scale::Math.Vector2f)
         this.scale = scale
     end
 
-    function get_rotation(this::Transform)
+    function Component.get_rotation(this::Transform)
         return this.rotation
     end
 
-    function set_rotation(this::Transform, rotation::Float64)
+    function Component.set_rotation(this::Transform, rotation::Float64)
         this.rotation = rotation
     end
 
-    function update(this::Transform)
+    function Component.update(this::Transform)
         #println(this.position)
     end
 
-    function set_vector2f_value(this::Transform, field, x, y)
+    function Component.set_vector2f_value(this::Transform, field, x, y)
         setfield!(this, field, Math.Vector2f(x,y))
     end
 end

From 313f7b7112b2da8829457c4d8e6722214c6cc7d6 Mon Sep 17 00:00:00 2001
From: Micah Rufsvold <86363075+mrufsvold@users.noreply.github.com>
Date: Tue, 6 Feb 2024 23:12:50 -0500
Subject: [PATCH 3/7] add multiple dispatch to UI

---
 src/UI/ScreenButton.jl | 26 ++++++++++++++++----------
 src/UI/TextBox.jl      | 40 ++++++++++++++++++++--------------------
 src/UI/UI.jl           | 16 +++++++++++++++-
 3 files changed, 51 insertions(+), 31 deletions(-)

diff --git a/src/UI/ScreenButton.jl b/src/UI/ScreenButton.jl
index dffab64f..c5bd4fb3 100644
--- a/src/UI/ScreenButton.jl
+++ b/src/UI/ScreenButton.jl
@@ -2,6 +2,7 @@ module ScreenButtonModule
     using ..UI.JulGame
     using ..UI.JulGame.Math
     import ..UI.JulGame: deprecated_get_property
+    import ..UI
 
     export ScreenButton
     mutable struct ScreenButton
@@ -46,17 +47,18 @@ module ScreenButtonModule
 
     function Base.getproperty(this::ScreenButton, s::Symbol)
         method_props = (
-            render = render,
-            initialize = initialize,
-            addClickEvent = add_click_event,
-            handleEvent = handle_event,
-            destroy = destroy
+            render = UI.render,
+            initialize = UI.initialize,
+            addClickEvent = UI.add_click_event,
+            handleEvent = UI.handle_event,
+            destroy = UI.destroy
         )
         deprecated_get_property(method_props, this, s)
     end
     
 
-    function render(this::ScreenButton)
+    render
+    function UI.render(this::ScreenButton)
         if !this.isInitialized
             this.initialize()
         end
@@ -80,7 +82,8 @@ module ScreenButtonModule
         @assert SDL2.SDL_RenderCopyF(JulGame.Renderer, this.textTexture, C_NULL, Ref(SDL2.SDL_FRect(this.position.x + this.textOffset.x, this.position.y + this.textOffset.y,this.textSize.x,this.textSize.y))) == 0 "error rendering button text: $(unsafe_string(SDL2.SDL_GetError()))"
     end
 
-    function initialize(this::ScreenButton)
+    render
+    function UI.initialize(this::ScreenButton)
         this.buttonDownTexture = CallSDLFunction(SDL2.SDL_CreateTextureFromSurface, JulGame.Renderer, this.buttonDownSprite)
         this.buttonUpTexture = CallSDLFunction(SDL2.SDL_CreateTextureFromSurface, JulGame.Renderer, this.buttonUpSprite)
         this.currentTexture = this.buttonUpTexture
@@ -98,11 +101,13 @@ module ScreenButtonModule
         this.isInitialized = true
     end
 
-    function add_click_event(this::ScreenButton, event)
+    render
+    function UI.add_click_event(this::ScreenButton, event)
         push!(this.clickEvents, event)
     end
 
-    function handle_event(this::ScreenButton, evt, x, y)
+    render
+    function UI.handle_event(this::ScreenButton, evt, x, y)
         if evt.type == evt.type == SDL2.SDL_MOUSEBUTTONDOWN
             this.currentTexture = this.buttonDownTexture
         elseif evt.type == SDL2.SDL_MOUSEBUTTONUP
@@ -115,7 +120,8 @@ module ScreenButtonModule
         end 
     end
 
-    function destroy(this::ScreenButton)
+    render
+    function UI.destroy(this::ScreenButton)
         if this.buttonDownTexture != C_NULL
             SDL2.SDL_DestroyTexture(this.buttonDownTexture)
         end
diff --git a/src/UI/TextBox.jl b/src/UI/TextBox.jl
index 090ce935..fff8c900 100644
--- a/src/UI/TextBox.jl
+++ b/src/UI/TextBox.jl
@@ -2,7 +2,7 @@ module TextBoxModule
     using ..UI.JulGame
     using ..UI.JulGame.Math
     import ..UI.JulGame: deprecated_get_property
-
+    import ..UI
     export TextBox      
     mutable struct TextBox
         alpha
@@ -51,20 +51,20 @@ module TextBoxModule
 
     function Base.getproperty(this::TextBox, s::Symbol)
         method_props = (
-            render = render,
-            initialize = initialize,
-            setPosition = set_position,
-            setParent = set_parent,
-            updateText = update_text,
-            setVector2Value = set_vector2_value,
-            setColor = set_color,
-            centerText = center_text,
-            destroy = destroy
+            render = UI.render,
+            initialize = UI.initialize,
+            setPosition = UI.set_position,
+            setParent = UI.set_parent,
+            updateText = UI.update_text,
+            setVector2Value = UI.set_vector2_value,
+            setColor = UI.set_color,
+            centerText = UI.center_text,
+            destroy = UI.destroy
         )
         deprecated_get_property(method_props, this, s)
     end
 
-    function render(this::TextBox, DEBUG)
+    function UI.render(this::TextBox, DEBUG)
         if !this.isInitialized
             Initialize(this)
         end
@@ -94,18 +94,18 @@ module TextBoxModule
         @assert SDL2.SDL_RenderCopyF(JulGame.Renderer, this.textTexture, C_NULL, Ref(SDL2.SDL_FRect(this.position.x - cameraDiff.x, this.position.y - cameraDiff.y, this.size.x, this.size.y))) == 0 "error rendering textbox text: $(unsafe_string(SDL2.SDL_GetError()))"
     end
 
-    function initialize(this::TextBox)
+    function UI.initialize(this::TextBox)
         Initialize(this)
     end
 
-    function set_position(this::TextBox, position::Math.Vector2)
+    function UI.set_position(this::TextBox, position::Math.Vector2)
     end
 
-    function set_parent(this::TextBox, parent)
+    function UI.set_parent(this::TextBox, parent)
         this.parent = parent
     end
 
-    function update_text(this::TextBox, newText)
+    function UI.update_text(this::TextBox, newText)
         this.text = newText
         SDL2.SDL_FreeSurface(this.renderText)
         SDL2.SDL_DestroyTexture(this.textTexture)
@@ -120,16 +120,16 @@ module TextBoxModule
         end
     end
 
-    function set_vector2_value(this::TextBox, field, x, y)
+    function UI.set_vector2_value(this::TextBox, field, x, y)
         setfield!(this, field, Math.Vector2(x,y))
         println("set $(field) to $(getfield(this, field))")
     end
 
-    function set_color(this::TextBox, r,g,b)
+    function UI.set_color(this::TextBox, r,g,b)
         SDL2.SDL_SetTextureColorMod(this.textTexture, r%256, g%256, b%256);
     end
 
-    function center_text(this::TextBox)
+    function UI.center_text(this::TextBox)
         if this.isCenteredX
             this.position = Math.Vector2(max(MAIN.scene.camera.dimensions.x/2 - this.size.x/2, 0), this.position.y)
         end
@@ -138,7 +138,7 @@ module TextBoxModule
         end
     end
 
-    function destroy(this::TextBox)
+    function UI.destroy(this::TextBox)
         if this.textTexture == C_NULL
             return
         end
@@ -147,7 +147,7 @@ module TextBoxModule
         this.textTexture = C_NULL
     end
 
-    function Initialize(this)
+    function UI.Initialize(this)
         path = this.isDefaultFont ? joinpath(this.basePath, this.fontPath) : joinpath(this.basePath, "assets", "fonts", this.fontPath)
         # println("loading font from $(path)")
         this.font = CallSDLFunction(SDL2.TTF_OpenFont, path, this.fontSize)
diff --git a/src/UI/UI.jl b/src/UI/UI.jl
index b5f92033..811a41f7 100644
--- a/src/UI/UI.jl
+++ b/src/UI/UI.jl
@@ -1,8 +1,22 @@
 module UI
     using ..JulGame
+
+    function add_click_event end
+    function center_text end
+    function destroy end
+    function handle_event end
+    function initialize end
+    function render end
+    function set_color end
+    function set_parent end
+    function set_position end
+    function set_vector2_value end
+    function update_text end
+
+
     include("ScreenButton.jl")
     include("TextBox.jl")
     
     export ScreenButtonModule
     export TextBoxModule
-end
\ No newline at end of file
+end

From 32c1d4427255320cd2193421c82868903536f11d Mon Sep 17 00:00:00 2001
From: Micah Rufsvold <86363075+mrufsvold@users.noreply.github.com>
Date: Tue, 6 Feb 2024 23:25:56 -0500
Subject: [PATCH 4/7] refactor camera and entity call sites

---
 src/Camera.jl          |  5 +++--
 src/Entity.jl          |  5 +++--
 src/UI/ScreenButton.jl |  8 +-------
 src/UI/TextBox.jl      | 44 +++++++++++++++++++-----------------------
 4 files changed, 27 insertions(+), 35 deletions(-)

diff --git a/src/Camera.jl b/src/Camera.jl
index 496a1176..9000e589 100644
--- a/src/Camera.jl
+++ b/src/Camera.jl
@@ -1,6 +1,7 @@
 using JulGame
 using .Math
 import JulGame: deprecated_get_property
+import JulGame.Component: get_position, get_scale
 
 mutable struct Camera
     dimensions::Vector2
@@ -47,9 +48,9 @@ function update(this::Camera, newPosition = C_NULL)
     SDL2.SDL_RenderFillRectF(Renderer, Ref(SDL2.SDL_FRect(this.windowPos.x, this.windowPos.y, this.dimensions.x, this.dimensions.y)))
 
     if this.target != C_NULL && newPosition == C_NULL
-        targetPos = this.target.getPosition()
+        targetPos = get_position(this.target)
         center =  Vector2f(this.dimensions.x/SCALE_UNITS/2, this.dimensions.y/SCALE_UNITS/2)
-        targetScale = this.target.getScale()
+        targetScale = get_scale(this.target)
         this.position = targetPos - center + 0.5 * targetScale + this.offset
         return
     end
diff --git a/src/Entity.jl b/src/Entity.jl
index 940ba8ce..7bccbcc7 100644
--- a/src/Entity.jl
+++ b/src/Entity.jl
@@ -10,6 +10,7 @@ module EntityModule
     using ..JulGame.SpriteModule
     using ..JulGame.TransformModule
     import ..JulGame: deprecated_get_property
+    import ..JulGame: Component
 
     export Entity
     mutable struct Entity
@@ -99,7 +100,7 @@ module EntityModule
 
         this.animator = InternalAnimator(this::Entity, animator.animations)
         if this.sprite != C_NULL 
-            this.animator.setSprite(this.sprite)
+            Component.set_sprite(this.animator, this.sprite)
         end
 
         return this.animator
@@ -162,7 +163,7 @@ module EntityModule
 
         this.sprite = InternalSprite(this::Entity, sprite.imagePath, sprite.crop, sprite.isFlipped, sprite.color, isCreatedInEditor; pixelsPerUnit=sprite.pixelsPerUnit, isWorldEntity=sprite.isWorldEntity, position=sprite.position, rotation=sprite.rotation, layer=sprite.layer)
         if this.animator != C_NULL
-            this.animator.setSprite(this.sprite)
+            Component.set_sprite(this.animator, this.sprite)
         end
         this.sprite.initialize()
 
diff --git a/src/UI/ScreenButton.jl b/src/UI/ScreenButton.jl
index c5bd4fb3..b288fe96 100644
--- a/src/UI/ScreenButton.jl
+++ b/src/UI/ScreenButton.jl
@@ -56,8 +56,6 @@ module ScreenButtonModule
         deprecated_get_property(method_props, this, s)
     end
     
-
-    render
     function UI.render(this::ScreenButton)
         if !this.isInitialized
             this.initialize()
@@ -82,7 +80,6 @@ module ScreenButtonModule
         @assert SDL2.SDL_RenderCopyF(JulGame.Renderer, this.textTexture, C_NULL, Ref(SDL2.SDL_FRect(this.position.x + this.textOffset.x, this.position.y + this.textOffset.y,this.textSize.x,this.textSize.y))) == 0 "error rendering button text: $(unsafe_string(SDL2.SDL_GetError()))"
     end
 
-    render
     function UI.initialize(this::ScreenButton)
         this.buttonDownTexture = CallSDLFunction(SDL2.SDL_CreateTextureFromSurface, JulGame.Renderer, this.buttonDownSprite)
         this.buttonUpTexture = CallSDLFunction(SDL2.SDL_CreateTextureFromSurface, JulGame.Renderer, this.buttonUpSprite)
@@ -101,12 +98,10 @@ module ScreenButtonModule
         this.isInitialized = true
     end
 
-    render
     function UI.add_click_event(this::ScreenButton, event)
         push!(this.clickEvents, event)
     end
 
-    render
     function UI.handle_event(this::ScreenButton, evt, x, y)
         if evt.type == evt.type == SDL2.SDL_MOUSEBUTTONDOWN
             this.currentTexture = this.buttonDownTexture
@@ -119,8 +114,7 @@ module ScreenButtonModule
             #println("mouse move")
         end 
     end
-
-    render
+    
     function UI.destroy(this::ScreenButton)
         if this.buttonDownTexture != C_NULL
             SDL2.SDL_DestroyTexture(this.buttonDownTexture)
diff --git a/src/UI/TextBox.jl b/src/UI/TextBox.jl
index fff8c900..23cd0ace 100644
--- a/src/UI/TextBox.jl
+++ b/src/UI/TextBox.jl
@@ -66,7 +66,7 @@ module TextBoxModule
 
     function UI.render(this::TextBox, DEBUG)
         if !this.isInitialized
-            Initialize(this)
+            UI.initialize(this)
         end
 
         if this.textTexture == C_NULL
@@ -95,7 +95,25 @@ module TextBoxModule
     end
 
     function UI.initialize(this::TextBox)
-        Initialize(this)
+        path = this.isDefaultFont ? joinpath(this.basePath, this.fontPath) : joinpath(this.basePath, "assets", "fonts", this.fontPath)
+        # println("loading font from $(path)")
+        this.font = CallSDLFunction(SDL2.TTF_OpenFont, path, this.fontSize)
+        if this.font == C_NULL
+            return
+        end
+
+        this.renderText = CallSDLFunction(SDL2.TTF_RenderUTF8_Blended, this.font, this.text, SDL2.SDL_Color(255,255,255,this.alpha))
+        
+        surface = unsafe_wrap(Array, this.renderText, 10; own = false)
+        this.size = Math.Vector2(surface[1].w, surface[1].h)
+        
+        this.textTexture = CallSDLFunction(SDL2.SDL_CreateTextureFromSurface, JulGame.Renderer, this.renderText)
+
+        if !this.isWorldEntity
+            this.centerText()
+        end
+
+        this.isInitialized = true
     end
 
     function UI.set_position(this::TextBox, position::Math.Vector2)
@@ -147,26 +165,4 @@ module TextBoxModule
         this.textTexture = C_NULL
     end
 
-    function UI.Initialize(this)
-        path = this.isDefaultFont ? joinpath(this.basePath, this.fontPath) : joinpath(this.basePath, "assets", "fonts", this.fontPath)
-        # println("loading font from $(path)")
-        this.font = CallSDLFunction(SDL2.TTF_OpenFont, path, this.fontSize)
-        if this.font == C_NULL
-            return
-        end
-
-        this.renderText = CallSDLFunction(SDL2.TTF_RenderUTF8_Blended, this.font, this.text, SDL2.SDL_Color(255,255,255,this.alpha))
-        
-        surface = unsafe_wrap(Array, this.renderText, 10; own = false)
-        this.size = Math.Vector2(surface[1].w, surface[1].h)
-        
-        this.textTexture = CallSDLFunction(SDL2.SDL_CreateTextureFromSurface, JulGame.Renderer, this.renderText)
-
-        if !this.isWorldEntity
-            this.centerText()
-        end
-
-        this.isInitialized = true
-    end
-
 end

From 0108ee8e5791f09641b4de8f60f198a6912bf8bd Mon Sep 17 00:00:00 2001
From: Micah Rufsvold <86363075+mrufsvold@users.noreply.github.com>
Date: Tue, 6 Feb 2024 23:51:26 -0500
Subject: [PATCH 5/7] move func defs up another level

---
 src/CommonFunctions.jl              | 43 ++++++++++++++++
 src/Component/ComponentFunctions.jl | 76 ++++++++++++++---------------
 src/JulGame.jl                      |  1 +
 src/Main.jl                         | 15 ++++--
 src/UI/UI.jl                        | 24 ++++-----
 5 files changed, 104 insertions(+), 55 deletions(-)
 create mode 100644 src/CommonFunctions.jl

diff --git a/src/CommonFunctions.jl b/src/CommonFunctions.jl
new file mode 100644
index 00000000..2cd3463b
--- /dev/null
+++ b/src/CommonFunctions.jl
@@ -0,0 +1,43 @@
+function add_click_event end
+function add_collision_event end
+function append_array end
+function append_array end
+function apply_forces end
+function center_text end
+function check_collisions end
+function destroy end
+function draw end
+function flip end
+function get_last_update end
+function get_offset end
+function get_parent end
+function get_position end
+function get_rotation end
+function get_scale end
+function get_size end
+function get_tag end
+function get_type end
+function get_velocity end
+function handle_event end
+function initialize end
+function load_image end
+function load_sound end
+function render end
+function set_color end
+function set_last_update end
+function set_offset end
+function set_parent end
+function set_position end
+function set_rotation end
+function set_scale end
+function set_size end
+function set_sprite end
+function set_tag end
+function set_vector2_value end
+function set_vector2f_value end
+function stop_music end
+function toggle_sound end
+function unload_sound end
+function update end
+function update_array_value end
+function update_text end
diff --git a/src/Component/ComponentFunctions.jl b/src/Component/ComponentFunctions.jl
index 3b775cc8..f62427ef 100644
--- a/src/Component/ComponentFunctions.jl
+++ b/src/Component/ComponentFunctions.jl
@@ -1,39 +1,39 @@
 # Declare Common Functions so that they can be dispatched from ModuleExtensions
-function add_collision_event end
-function append_array end
-function append_array end
-function apply_forces end
-function check_collisions end
-function destroy end
-function draw end
-function draw end
-function flip end
-function get_last_update end
-function get_offset end
-function get_parent end
-function get_position end
-function get_rotation end
-function get_scale end
-function get_size end
-function get_tag end
-function get_type end
-function get_velocity end
-function initialize end
-function load_image end
-function load_sound end
-function set_color end
-function set_last_update end
-function set_offset end
-function set_parent end
-function set_position end
-function set_rotation end
-function set_scale end
-function set_size end
-function set_sprite end
-function set_tag end
-function set_vector2f_value end
-function stop_music end
-function toggle_sound end
-function unload_sound end
-function update end
-function update_array_value end
+import ..JulGame: add_collision_event,
+    append_array,
+    append_array,
+    apply_forces,
+    check_collisions,
+    destroy,
+    draw,
+    draw,
+    flip,
+    get_last_update,
+    get_offset,
+    get_parent,
+    get_position,
+    get_rotation,
+    get_scale,
+    get_size,
+    get_tag,
+    get_type,
+    get_velocity,
+    initialize,
+    load_image,
+    load_sound,
+    set_color,
+    set_last_update,
+    set_offset,
+    set_parent,
+    set_position,
+    set_rotation,
+    set_scale,
+    set_size,
+    set_sprite,
+    set_tag,
+    set_vector2f_value,
+    stop_music,
+    toggle_sound,
+    unload_sound,
+    update,
+    update_array_value
diff --git a/src/JulGame.jl b/src/JulGame.jl
index b870fcdf..30a59775 100644
--- a/src/JulGame.jl
+++ b/src/JulGame.jl
@@ -1,4 +1,5 @@
 module JulGame
+    include("CommonFunctions.jl")
     using SimpleDirectMediaLayer
     const SDL2 = SimpleDirectMediaLayer
 
diff --git a/src/Main.jl b/src/Main.jl
index 7d78e916..d9be5910 100644
--- a/src/Main.jl
+++ b/src/Main.jl
@@ -1,7 +1,8 @@
 module MainLoop
 	using ..JulGame
 	using ..JulGame: Input, Math, UI
-    import ..JulGame: deprecated_get_property
+    import ..JulGame: deprecated_get_property, Component
+    import ..JulGame.SceneManagement: SceneBuilderModule
 	include("Enums.jl")
 	include("Constants.jl")
 	include("Scene.jl")
@@ -101,7 +102,7 @@ module MainLoop
         end
     end
     function initialize_new_scene(this::Main, isUsingEditor::Bool = false)
-        this.level.changeScene(isUsingEditor)
+        SceneBuilderModule.change_scene(this.level, isUsingEditor)
         InitializeScriptsAndComponents(this, false)
 
         if !isUsingEditor
@@ -251,17 +252,21 @@ module MainLoop
         this.scene.camera.update(cameraPosition)
         return cameraPosition
     end
+
     function create_new_entity(this::Main)
-        this.level.createNewEntity()
+        SceneBuilderModule.create_new_entity(this.level)
     end
+
     function create_new_text_box(this::Main, fontPath)
-        this.level.createNewTextBox(fontPath)
+        SceneBuilderModule.create_new_text_box(this.level, fontPath)
     end
+
     function select_entity_with_click(this::Main)
         entityIndex = 0
         for entity in this.scene.entities
             entityIndex += 1
-            size = entity.collider != C_NULL ? entity.collider.getSize() : entity.transform.getScale()
+            
+            size = entity.collider != C_NULL ? Component.get_size(entity.collider) : entity.transform.getScale()
             if this.mousePositionWorldRaw.x >= entity.transform.getPosition().x && this.mousePositionWorldRaw.x <= entity.transform.getPosition().x + size.x && this.mousePositionWorldRaw.y >= entity.transform.getPosition().y && this.mousePositionWorldRaw.y <= entity.transform.getPosition().y + size.y
                 if this.selectedEntityIndex == entityIndex
                     continue
diff --git a/src/UI/UI.jl b/src/UI/UI.jl
index 811a41f7..ff291273 100644
--- a/src/UI/UI.jl
+++ b/src/UI/UI.jl
@@ -1,17 +1,17 @@
 module UI
     using ..JulGame
-
-    function add_click_event end
-    function center_text end
-    function destroy end
-    function handle_event end
-    function initialize end
-    function render end
-    function set_color end
-    function set_parent end
-    function set_position end
-    function set_vector2_value end
-    function update_text end
+    import ..JulGame: 
+        add_click_event,
+        center_text,
+        destroy,
+        handle_event,
+        initialize,
+        render,
+        set_color,
+        set_parent,
+        set_position,
+        set_vector2_value,
+        update_text
 
 
     include("ScreenButton.jl")

From 59988a375e199990e99a4842fc13128f6aaa9df1 Mon Sep 17 00:00:00 2001
From: Micah Rufsvold <86363075+mrufsvold@users.noreply.github.com>
Date: Wed, 7 Feb 2024 00:07:21 -0500
Subject: [PATCH 6/7] add entity to common dispatch

---
 src/CommonFunctions.jl | 10 +++++++++-
 src/Entity.jl          | 41 +++++++++++++++++++++--------------------
 2 files changed, 30 insertions(+), 21 deletions(-)

diff --git a/src/CommonFunctions.jl b/src/CommonFunctions.jl
index 2cd3463b..a24a7c32 100644
--- a/src/CommonFunctions.jl
+++ b/src/CommonFunctions.jl
@@ -1,10 +1,18 @@
+function add_animator end
+function add_circle_collider end
 function add_click_event end
+function add_collider end
 function add_collision_event end
-function append_array end
+function add_rigidbody end
+function add_script end
+function add_shape end
+function add_sound_source end
+function add_sprite end
 function append_array end
 function apply_forces end
 function center_text end
 function check_collisions end
+function create_sound_source end
 function destroy end
 function draw end
 function flip end
diff --git a/src/Entity.jl b/src/Entity.jl
index 7bccbcc7..b8ea1e8b 100644
--- a/src/Entity.jl
+++ b/src/Entity.jl
@@ -11,6 +11,7 @@ module EntityModule
     using ..JulGame.TransformModule
     import ..JulGame: deprecated_get_property
     import ..JulGame: Component
+    import ..JulGame
 
     export Entity
     mutable struct Entity
@@ -54,22 +55,22 @@ module EntityModule
 
     function Base.getproperty(this::Entity, s::Symbol)
         method_props = (
-            addScript = add_script,
-            update = update,
-            addAnimator = add_animator,
-            addCollider = add_collider,
-            addCircleCollider = add_circle_collider,
-            addRigidbody = add_rigidbody,
-            addSoundSource = add_sound_source,
-            createSoundSource = create_sound_source,
-            addSprite = add_sprite,
-            addShape = add_shape
+            addScript = JulGame.add_script,
+            update = JulGame.update,
+            addAnimator = JulGame.add_animator,
+            addCollider = JulGame.add_collider,
+            addCircleCollider = JulGame.add_circle_collider,
+            addRigidbody = JulGame.add_rigidbody,
+            addSoundSource = JulGame.add_sound_source,
+            createSoundSource = JulGame.create_sound_source,
+            addSprite = JulGame.add_sprite,
+            addShape = JulGame.add_shape
         )
         deprecated_get_property(method_props, this, s)
     end
 
 
-    function add_script(this::Entity, script)
+    function JulGame.add_script(this::Entity, script)
         #println(string("Adding script of type: ", typeof(script), " to entity named " , this.name))
         push!(this.scripts, script)
         script.setParent(this)
@@ -81,7 +82,7 @@ module EntityModule
         end
     end
 
-    function update(this::Entity, deltaTime)
+    function JulGame.update(this::Entity, deltaTime)
         for script in this.scripts
             try
                 script.update(deltaTime)
@@ -92,7 +93,7 @@ module EntityModule
         end
     end
 
-    function add_animator(this::Entity, animator::Animator = Animator(Animation[Animation(Vector4[Vector4(0,0,0,0)], Int32(60))]))
+    function JulGame.add_animator(this::Entity, animator::Animator = Animator(Animation[Animation(Vector4[Vector4(0,0,0,0)], Int32(60))]))
         if this.animator != C_NULL
             println("Animator already exists on entity named ", this.name)
             return
@@ -106,7 +107,7 @@ module EntityModule
         return this.animator
     end
 
-    function add_collider(this::Entity, collider::Collider = Collider(true, false, false, Vector2f(0,0), Vector2f(1,1), "Default"))
+    function JulGame.add_collider(this::Entity, collider::Collider = Collider(true, false, false, Vector2f(0,0), Vector2f(1,1), "Default"))
         if this.collider != C_NULL || this.circleCollider != C_NULL
             println("Collider already exists on entity named ", this.name)
             return
@@ -117,7 +118,7 @@ module EntityModule
         return this.collider
     end
 
-    function add_circle_collider(this::Entity, collider::CircleCollider = CircleCollider(1.0, true, false, Vector2f(0,0), "Default"))
+    function JulGame.add_circle_collider(this::Entity, collider::CircleCollider = CircleCollider(1.0, true, false, Vector2f(0,0), "Default"))
         if this.collider != C_NULL || this.circleCollider != C_NULL
             println("Collider already exists on entity named ", this.name)
             return
@@ -128,7 +129,7 @@ module EntityModule
         return this.circleCollider
     end
 
-    function add_rigidbody(this::Entity, rigidbody::Rigidbody = Rigidbody())
+    function JulGame.add_rigidbody(this::Entity, rigidbody::Rigidbody = Rigidbody())
         if this.rigidbody != C_NULL
             println("Rigidbody already exists on entity named ", this.name)
             return
@@ -139,7 +140,7 @@ module EntityModule
         return this.rigidbody
     end
 
-    function add_sound_source(this::Entity, soundSource::SoundSource = SoundSource(Int32(-1), false, "", Int32(50)))
+    function JulGame.add_sound_source(this::Entity, soundSource::SoundSource = SoundSource(Int32(-1), false, "", Int32(50)))
         if this.soundSource != C_NULL
             println("SoundSource already exists on entity named ", this.name)
             return
@@ -150,12 +151,12 @@ module EntityModule
         return this.soundSource
     end
 
-    function create_sound_source(this::Entity, soundSource::SoundSource = SoundSource(Int32(-1), false, "", Int32(50)))
+    function JulGame.create_sound_source(this::Entity, soundSource::SoundSource = SoundSource(Int32(-1), false, "", Int32(50)))
         newSoundSource::InternalSoundSource = InternalSoundSource(this::Entity, soundSource.path, soundSource.channel, soundSource.volume, soundSource.isMusic)
         return newSoundSource
     end
 
-    function add_sprite(this::Entity, isCreatedInEditor::Bool = false, sprite::Sprite = Sprite(Math.Vector3(255, 255, 255), C_NULL, false, "", true, 0, Math.Vector2f(0,0), Math.Vector2f(0,0), 0, -1))
+    function JulGame.add_sprite(this::Entity, isCreatedInEditor::Bool = false, sprite::Sprite = Sprite(Math.Vector3(255, 255, 255), C_NULL, false, "", true, 0, Math.Vector2f(0,0), Math.Vector2f(0,0), 0, -1))
         if this.sprite != C_NULL
             println("Sprite already exists on entity named ", this.name)
             return
@@ -170,7 +171,7 @@ module EntityModule
         return this.sprite
     end
 
-    function add_shape(this::Entity, shape::Shape = Shape(Math.Vector3(255,0,0), Math.Vector2f(1,1), true, false, Math.Vector2f(0,0), Math.Vector2f(0,0)))
+    function JulGame.add_shape(this::Entity, shape::Shape = Shape(Math.Vector3(255,0,0), Math.Vector2f(1,1), true, false, Math.Vector2f(0,0), Math.Vector2f(0,0)))
         if this.shape != C_NULL
             println("Shape already exists on entity named ", this.name)
             return

From edec5786ced453d782e90e1a3fdcc96adf73a6f3 Mon Sep 17 00:00:00 2001
From: Micah Rufsvold <86363075+mrufsvold@users.noreply.github.com>
Date: Wed, 7 Feb 2024 00:07:35 -0500
Subject: [PATCH 7/7] move all of main loop to functional calls

---
 src/Main.jl | 29 +++++++++++++++--------------
 1 file changed, 15 insertions(+), 14 deletions(-)

diff --git a/src/Main.jl b/src/Main.jl
index d9be5910..d5e7d3af 100644
--- a/src/Main.jl
+++ b/src/Main.jl
@@ -366,10 +366,10 @@ function InitializeScriptsAndComponents(this::Main, isUsingEditor::Bool = false)
 	end
 
 	for textBox in this.scene.textBoxes
-		textBox.initialize()
+        JulGame.initialize(textBox)
 	end
 	for screenButton in this.scene.screenButtons
-		screenButton.initialize()
+        JulGame.initialize(screenButton)
 	end
 
 	this.lastMousePosition = Math.Vector2(0, 0)
@@ -439,8 +439,7 @@ function ChangeScene(sceneFileName::String)
 			skipcount += 1
 			continue
 		end
-
-	 	textBox.destroy()
+        JulGame.destroy(textBox)
 	end
 	
 	persistentScreenButtons = []
@@ -658,7 +657,7 @@ function GameLoop(this, startTime::Ref{UInt64} = Ref(UInt64(0)), lastPhysicsTime
 				end
 				for rigidbody in this.scene.rigidbodies
 					try
-						rigidbody.update(deltaTime)
+						JulGame.update(rigidbody, deltaTime)
 					catch e
 						println(rigidbody.parent.name, " with id: ", rigidbody.parent.id, " has a problem with it's rigidbody")
 						rethrow(e)
@@ -683,7 +682,7 @@ function GameLoop(this, startTime::Ref{UInt64} = Ref(UInt64(0)), lastPhysicsTime
 
 				if !isEditor
 					try
-						entity.update(deltaTime)
+                        JulGame.update(entity, deltaTime)
 						if this.close
 							return
 						end
@@ -693,7 +692,7 @@ function GameLoop(this, startTime::Ref{UInt64} = Ref(UInt64(0)), lastPhysicsTime
 					end
 					entityAnimator = entity.animator
 					if entityAnimator != C_NULL
-						entityAnimator.update(currentRenderTime, deltaTime)
+                        JulGame.update(entityAnimator, currentRenderTime, deltaTime)
 					end
 				end
 			end
@@ -766,13 +765,13 @@ function GameLoop(this, startTime::Ref{UInt64} = Ref(UInt64(0)), lastPhysicsTime
 					colliderRenderCount += 1
 					collider = entity.collider
 					zoomMultiplier = (isEditor && update == C_NULL) ? this.zoom : 1.0
-					if collider.getType() == "CircleCollider"
+					if JulGame.get_type(collider) == "CircleCollider"
 						SDL2E.SDL_RenderDrawCircle(
 							round(Int32, (pos.x - this.scene.camera.position.x) * SCALE_UNITS - ((entity.transform.getScale().x * SCALE_UNITS - SCALE_UNITS) / 2)), 
 							round(Int32, (pos.y - this.scene.camera.position.y) * SCALE_UNITS - ((entity.transform.getScale().y * SCALE_UNITS - SCALE_UNITS) / 2)), 
 							round(Int32, collider.diameter/2 * SCALE_UNITS))
 					else
-						colSize = collider.getSize()
+						colSize = JulGame.get_size(collider)
 						colSize = Math.Vector2f(colSize.x * zoomMultiplier, colSize.y * zoomMultiplier)
 						colOffset = collider.offset
 						colOffset = Math.Vector2f(colOffset.x * zoomMultiplier, colOffset.y * zoomMultiplier)
@@ -795,7 +794,7 @@ function GameLoop(this, startTime::Ref{UInt64} = Ref(UInt64(0)), lastPhysicsTime
 			end
 
 			for textBox in this.scene.textBoxes
-				textBox.render(DEBUG)
+                JulGame.render(textBox, DEBUG)
 			end
 			#endregion ============= UI
 
@@ -812,7 +811,8 @@ function GameLoop(this, startTime::Ref{UInt64} = Ref(UInt64(0)), lastPhysicsTime
 
 						zoomMultiplier = (isEditor && update == C_NULL) ? this.zoom : 1.0
 						pos = selectedEntity.transform.getPosition()
-						size = selectedEntity.collider != C_NULL ? selectedEntity.collider.getSize() : selectedEntity.transform.getScale()
+                        
+						size = selectedEntity.collider != C_NULL ? JulGame.get_size(selectedEntity.collider) : selectedEntity.transform.getScale()
 						size = Math.Vector2f(size.x * zoomMultiplier, size.y * zoomMultiplier)
 						offset = selectedEntity.collider != C_NULL ? selectedEntity.collider.offset : Math.Vector2f()
 						offset = Math.Vector2f(offset.x * zoomMultiplier, offset.y * zoomMultiplier)
@@ -850,12 +850,13 @@ function GameLoop(this, startTime::Ref{UInt64} = Ref(UInt64(0)), lastPhysicsTime
 					for i = 1:length(statTexts)
 						textBox = UI.TextBoxModule.TextBox("Debug text", fontPath, 40, Math.Vector2(0, 35 * i), statTexts[i], false, false, true)
 						push!(this.debugTextBoxes, textBox)
-						textBox.initialize()
+                        JulGame.initialize(textBox)
 					end
 				else
 					for i = 1:length(this.debugTextBoxes)
-						this.debugTextBoxes[i].updateText(statTexts[i])
-						this.debugTextBoxes[i].render(false)
+                        db_textbox = this.debugTextBoxes[i]
+                        JulGame.update_text(db_textbox, statTexts[i])
+                        JulGame.render(db_textbox, false)
 					end
 				end
 			end