Skip to content

Commit

Permalink
Merge branch 'main' into pages
Browse files Browse the repository at this point in the history
  • Loading branch information
Kyjor committed Jan 13, 2024
2 parents d2bf8dc + 0aaa88e commit 8b5de49
Show file tree
Hide file tree
Showing 209 changed files with 47,283 additions and 1,063 deletions.
10 changes: 4 additions & 6 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -25,14 +25,12 @@ Manifest.toml

.idea/

StackManBuild/

editor/imgui.ini

imgui.ini

editor/JulGame/

editor/Editor/imgui_log.txt

src/editor/EditorBuild/

test/projects/ProfilingTest/Platformer/.vscode/settings.json

.vscode/settings.json
16 changes: 9 additions & 7 deletions Project.toml
Original file line number Diff line number Diff line change
@@ -1,25 +1,27 @@
name = "JulGame"
uuid = "4850f9bb-d191-4a1e-9f97-ee64062927c3"
repo = "https://github.com/Kyjor/JulGame.jl.git"
version = "0.0.3"
version = "0.1.0"

[deps]
SimpleDirectMediaLayer = "98e33af6-2ee5-5afd-9e75-cbc738b767c4"
CImGui = "5d785b6c-b76f-510e-a07c-3070796c7e87"
Dates = "ade2ca70-3891-5945-98fb-dc099432e06a"
ImGuiGLFWBackend = "623d79b3-9695-4e60-bd7e-2a5aabaa6933"
ImGuiOpenGLBackend = "9d0819b4-44e7-43a2-ad03-8fb999128168"
JSON3 = "0f8b85d8-7281-11e9-16c2-39a750bddbf1"
SimpleDirectMediaLayer = "98e33af6-2ee5-5afd-9e75-cbc738b767c4"
NativeFileDialog = "e1fe445b-aa65-4df4-81c1-2041507f0fd4"

[compat]
SimpleDirectMediaLayer = "0.3, 0.4"
CImGui = "~1.82"
ImGuiGLFWBackend = "0.1.2"
ImGuiOpenGLBackend = "0.1.1"
CImGui = "~1.89"
ImGuiGLFWBackend = "0.2"
ImGuiOpenGLBackend = "0.2"
JSON3 = "1"
SimpleDirectMediaLayer = "0.3, 0.4"
julia = "1.9"

[extras]
Test = "8dfed614-e22c-5e08-85e1-65c5234f0b40"

[targets]
test = ["Test"]
test = ["Test"]
6 changes: 2 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -35,10 +35,8 @@ I thought that JulGame would be a great play on Pygame. I also think it just rol

`] add https://github.com/Kyjor/JulGame.jl#develop` for develop

Either download the latest release of the editor, or run it using the Julia REPL:

`using JulGame`
`JulGame.Editor.run()`
Either download the latest release of the editor, or run it by navigating to `JulGame\src\editor\Editor\src\Editor.jl`
and run `julia Editor.jl`

## How do you use it?

Expand Down
Binary file removed examples/Testing/.DS_Store
Binary file not shown.
7 changes: 0 additions & 7 deletions examples/Testing/Testing/Project.toml

This file was deleted.

3 changes: 0 additions & 3 deletions examples/Testing/Testing/precompile_app.jl

This file was deleted.

42 changes: 0 additions & 42 deletions examples/Testing/Testing/scripts/TestScript.jl

This file was deleted.

15 changes: 0 additions & 15 deletions examples/Testing/Testing/src/Testing.jl

This file was deleted.

2 changes: 1 addition & 1 deletion src/3D/example3d.jl
Original file line number Diff line number Diff line change
Expand Up @@ -160,7 +160,7 @@ function main()
quit = true
#Handle keypress with current mouse position
elseif evt.type == SDL_KEYUP
x,y = Int[1], Int[1]
x,y = Int32[1], Int32[1]
SDL_GetMouseState(pointer(x), pointer(y))
if handleKeys(evt.key.keysym.scancode, x, y )
renderQuad = !renderQuad
Expand Down
11 changes: 6 additions & 5 deletions src/Camera.jl
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,13 @@ using JulGame
using JulGame.Math

mutable struct Camera
dimensions
offset
dimensions::Vector2
offset::Vector2f
position::Vector2f
startingCoordinates::Vector2f
target

function Camera(dimensions::Vector2, initialPosition::Vector2f, offset::Vector2f,target)
function Camera(dimensions::Vector2, initialPosition::Vector2f, offset::Vector2f, target)
this = new()

this.dimensions = dimensions
Expand All @@ -28,8 +28,8 @@ function Base.getproperty(this::Camera, s::Symbol)
end
elseif s == :update
function(newPosition = C_NULL)
SDL2.SDL_SetRenderDrawColor(MAIN.renderer, MAIN.cameraBackgroundColor[1], MAIN.cameraBackgroundColor[2], MAIN.cameraBackgroundColor[3], SDL2.SDL_ALPHA_OPAQUE );
SDL2.SDL_RenderFillRect(MAIN.renderer, Ref(SDL2.SDL_Rect(0,0,this.dimensions.x, this.dimensions.y)))
SDL2.SDL_SetRenderDrawColor(JulGame.Renderer, MAIN.cameraBackgroundColor[1], MAIN.cameraBackgroundColor[2], MAIN.cameraBackgroundColor[3], SDL2.SDL_ALPHA_OPAQUE );
SDL2.SDL_RenderFillRect(JulGame.Renderer, Ref(SDL2.SDL_Rect(0,0,this.dimensions.x, this.dimensions.y)))

if this.target != C_NULL && newPosition == C_NULL
targetPos = this.target.getPosition()
Expand All @@ -52,6 +52,7 @@ function Base.getproperty(this::Camera, s::Symbol)
getfield(this, s)
catch e
println(e)
Base.show_backtrace(stdout, catch_backtrace())
end
end
end
52 changes: 9 additions & 43 deletions src/Component/Animation.jl
Original file line number Diff line number Diff line change
Expand Up @@ -3,47 +3,25 @@ module AnimationModule

export Animation
mutable struct Animation
animatedFPS::Integer # public
frames::Array{Math.Vector4} # public
parent::Any # public
test # private
animatedFPS::Int32
frames::Vector{Math.Vector4}

function Animation(frames, animatedFPS)
function Animation(frames::Vector{Math.Vector4}, animatedFPS::Int32)
this = new()

this.animatedFPS = animatedFPS
this.frames = frames
this.parent = C_NULL
this.test = "test"

return this
end
end

function Base.getproperty(this::Animation, s::Symbol, caller::Symbol)
try
if caller == Symbol(":$(@__MODULE__)")
getfield(this, s)
else
throw(UndefVarError(s))
end
catch e
println(e)
end
end

function Base.getproperty(this::Animation, s::Symbol)
public_props = (:animatedFPS, :frames, :parent)

if s == :setParent
function(parent)
this.parent = parent
end
elseif s == :updateArrayValue
function(value, field, index)
if s == :updateArrayValue
function(value, field, index::Int32)
fieldToUpdate = getfield(this, field)
if this.getType(value) == "Vector4"
fieldToUpdate[index] = Math.Vector4(value.x, value.y, value.w, value.h)
if this.getType(value) == "_Vector4"
fieldToUpdate[index] = Math.Vector4(value.x, value.y, value.z, value.t)
end
end
elseif s == :appendArray
Expand All @@ -57,23 +35,11 @@ module AnimationModule
end
else
try
if s in public_props
getfield(this, s)
else
throw(UndefVarError(s))
end
getfield(this, s)
catch e
println(e)
Base.show_backtrace(stdout, catch_backtrace())
end
end
end

export GetAnimationTest
"""
GetAnimationTest(anim)
Gets the value of test
"""
function GetAnimationTest(anim::Animation)
@atomic Symbol(":$(@__MODULE__)") anim.test
end
end
33 changes: 20 additions & 13 deletions src/Component/Animator.jl
Original file line number Diff line number Diff line change
Expand Up @@ -2,31 +2,37 @@
using ..Component.AnimationModule
using ..Component.JulGame
using ..Component.JulGame.Math
using ..Component.SpriteModule

export Animator
mutable struct Animator
animations::Array{Animation}
struct Animator
animations::Vector{Animation}
end

export InternalAnimator
mutable struct InternalAnimator
animations::Vector{Animation}
currentAnimation::Animation
lastFrame::Integer
lastFrame::Int32
lastUpdate::UInt64
parent::Any
sprite::Any
sprite::Union{InternalSprite, Ptr{Nothing}}

function Animator(animations = [])
function InternalAnimator(parent::Any, animations::Vector{Animation} = Animation[])
this = new()

this.animations = animations
this.currentAnimation = length(this.animations) > 0 ? this.animations[1] : C_NULL
this.lastFrame = 1
this.lastUpdate = SDL2.SDL_GetTicks()
this.parent = C_NULL
this.parent = parent
this.sprite = C_NULL

return this
end
end

function Base.getproperty(this::Animator, s::Symbol)
function Base.getproperty(this::InternalAnimator, s::Symbol)
if s == :getLastUpdate
function()
return this.lastUpdate
Expand All @@ -49,34 +55,35 @@
end
elseif s == :appendArray
function()
push!(this.animations, Animation([Math.Vector4(0,0,0,0)], 60))
push!(this.animations, Animation([Math.Vector4(0,0,0,0)], Int32(60)))
end
else
try
getfield(this, s)
catch e
println(e)
Base.show_backtrace(stdout, catch_backtrace())
end
end
end


"""
ForceFrameUpdate(this::Animator, frameIndex::Integer)
ForceFrameUpdate(this::InternalAnimator, frameIndex::Int32)
Updates the sprite crop of the animator to the specified frame index.
# Arguments
- `this::Animator`: The animator object.
- `frameIndex::Integer`: The index of the frame to update the sprite crop to.
- `this::InternalAnimator`: The animator object.
- `frameIndex::Int32`: The index of the frame to update the sprite crop to.
# Example
```
animator = Animator([Animation([Math.Vector4(0,0,0,0)], 60)])
ForceFrameUpdate(animator, 1)
```
"""
function ForceFrameUpdate(this::Animator, frameIndex::Integer)
function ForceFrameUpdate(this::InternalAnimator, frameIndex::Int32)
this.sprite.crop = this.currentAnimation.frames[frameIndex]
end
export ForceFrameUpdate
Expand All @@ -97,7 +104,7 @@
Update(animator, SDL2.SDL_GetTicks(), 1000)
```
"""
function Update(this::Animator, currentRenderTime, deltaTime)
function Update(this::InternalAnimator, currentRenderTime, deltaTime)
if this.currentAnimation.animatedFPS < 1
return
end
Expand Down
Loading

0 comments on commit 8b5de49

Please sign in to comment.