Skip to content

Commit

Permalink
clean up imports, finish adding concrete type annotations (#55)
Browse files Browse the repository at this point in the history
  • Loading branch information
mrufsvold authored Jan 26, 2024
1 parent 79d0507 commit 4968f44
Show file tree
Hide file tree
Showing 8 changed files with 38 additions and 40 deletions.
8 changes: 4 additions & 4 deletions src/Camera.jl
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
using JulGame
using JulGame.Math
using .Math

mutable struct Camera
dimensions::Vector2
Expand Down Expand Up @@ -28,8 +28,8 @@ function Base.getproperty(this::Camera, s::Symbol)
end
elseif s == :update
function(newPosition = C_NULL)
SDL2.SDL_SetRenderDrawColor(JulGame.Renderer, MAIN.cameraBackgroundColor[1], MAIN.cameraBackgroundColor[2], MAIN.cameraBackgroundColor[3], SDL2.SDL_ALPHA_OPAQUE );
SDL2.SDL_RenderFillRectF(JulGame.Renderer, Ref(SDL2.SDL_FRect(0,0,this.dimensions.x, this.dimensions.y)))
SDL2.SDL_SetRenderDrawColor(Renderer, MAIN.cameraBackgroundColor[1], MAIN.cameraBackgroundColor[2], MAIN.cameraBackgroundColor[3], SDL2.SDL_ALPHA_OPAQUE );
SDL2.SDL_RenderFillRectF(Renderer, Ref(SDL2.SDL_FRect(0,0,this.dimensions.x, this.dimensions.y)))

if this.target != C_NULL && newPosition == C_NULL
targetPos = this.target.getPosition()
Expand All @@ -55,4 +55,4 @@ function Base.getproperty(this::Camera, s::Symbol)
Base.show_backtrace(stdout, catch_backtrace())
end
end
end
end
15 changes: 8 additions & 7 deletions src/JulGame.jl
Original file line number Diff line number Diff line change
Expand Up @@ -41,20 +41,21 @@ module JulGame
using .UI
export ScreenButtonModule, TextBoxModule

include("Main.jl")
using .MainLoop: Main
const MAIN = Main(Float64(1.0))
export MAIN


include("Component/Component.jl")
using .Component
export AnimationModule, AnimatorModule, ColliderModule, CircleColliderModule, RigidbodyModule, ShapeModule, SoundSourceModule, SpriteModule, TransformModule

include("Entity.jl")
using .EntityModule
export Entity

include("SceneManagement/SceneManagement.jl")
using .SceneManagement
export SceneBuilderModule, SceneLoaderModule, SceneReaderModule, SceneWriterModule
end

include("Main.jl")
using .MainLoop: Main
const MAIN = Main(Float64(1.0))
export MAIN
end
3 changes: 1 addition & 2 deletions src/Main.jl
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,7 @@ module MainLoop
isDraggingEntity::Bool
lastMousePosition::Union{Math.Vector2, Math.Vector2f}
lastMousePositionWorld::Union{Math.Vector2, Math.Vector2f}
# need to work on import order so that this can be concretely typed
level#::JulGame.SceneManagement.SceneBuilderModule.Scene
level::JulGame.SceneManagement.SceneBuilderModule.Scene
mousePositionWorld::Union{Math.Vector2, Math.Vector2f}
mousePositionWorldRaw::Union{Math.Vector2, Math.Vector2f}
optimizeSpriteRendering::Bool
Expand Down
3 changes: 1 addition & 2 deletions src/Scene.jl
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
mutable struct Scene
# Need to work on import order so this can be concretely typed or at least parametricized
camera::Union{Nothing, Any} #, JulGame.SceneManagement.SceneBuilderModule.Camera}
camera::Union{Nothing, JulGame.SceneManagement.SceneBuilderModule.Camera}
colliders::Vector{Any}
entities::Vector{Any}
rigidbodies::Vector{Any}
Expand Down
16 changes: 8 additions & 8 deletions src/SceneManagement/SceneBuilder.jl
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
module SceneBuilderModule
using ..SceneManagement.JulGame
using ..SceneManagement.JulGame.Math
using ..SceneManagement.JulGame.ColliderModule
using ..SceneManagement.JulGame.EntityModule
using ..SceneManagement.JulGame.RigidbodyModule
using ..SceneManagement.JulGame.TextBoxModule
using ..SceneManagement.SceneReaderModule
using ...JulGame
using ...Math
using ...ColliderModule
using ...EntityModule
using ...RigidbodyModule
using ...TextBoxModule
using ..SceneReaderModule

function __init__()
if isdir(joinpath(pwd(), "..", "scripts")) #dev builds
Expand Down Expand Up @@ -217,4 +217,4 @@ module SceneBuilderModule
end
end
end
end
end
6 changes: 3 additions & 3 deletions src/SceneManagement/SceneLoader.jl
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
module SceneLoaderModule
using ..SceneManagement.JulGame
using ..SceneManagement.SceneBuilderModule
using ...JulGame
using ..SceneBuilderModule

export loadScene
function loadScene(projectPath, sceneFileName, isUsingEditor = false)
Expand Down Expand Up @@ -48,4 +48,4 @@ module SceneLoaderModule
sceneFileName = split(scenePath, "\\")[end]
return sceneFileName
end
end
end
3 changes: 1 addition & 2 deletions src/SceneManagement/SceneManagement.jl
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
module SceneManagement
using ..JulGame
include("SceneReader.jl")
include("SceneWriter.jl")
include("SceneBuilder.jl")
Expand All @@ -9,4 +8,4 @@ module SceneManagement
export SceneWriterModule
export SceneBuilderModule
export SceneLoaderModule
end
end
24 changes: 12 additions & 12 deletions src/SceneManagement/SceneReader.jl
Original file line number Diff line number Diff line change
@@ -1,16 +1,16 @@
module SceneReaderModule
using JSON3
using ..SceneManagement.JulGame.AnimatorModule
using ..SceneManagement.JulGame.AnimationModule
using ..SceneManagement.JulGame.ColliderModule
using ..SceneManagement.JulGame.CircleColliderModule
using ..SceneManagement.JulGame.EntityModule
using ..SceneManagement.JulGame.Math
using ..SceneManagement.JulGame.RigidbodyModule
using ..SceneManagement.JulGame.SoundSourceModule
using ..SceneManagement.JulGame.SpriteModule
using ..SceneManagement.JulGame.UI.TextBoxModule
using ..SceneManagement.JulGame.TransformModule
using ...AnimatorModule
using ...AnimationModule
using ...ColliderModule
using ...CircleColliderModule
using ...EntityModule
using ...Math
using ...RigidbodyModule
using ...SoundSourceModule
using ...SpriteModule
using ...UI.TextBoxModule
using ...TransformModule


function scriptObj(name::String, parameters::Array)
Expand Down Expand Up @@ -152,4 +152,4 @@ module SceneReaderModule
Base.show_backtrace(stdout, catch_backtrace())
end
end
end
end

0 comments on commit 4968f44

Please sign in to comment.