Skip to content

Commit 6d1899f

Browse files
committed
Test fixes
1 parent 4398a9e commit 6d1899f

File tree

14 files changed

+488
-452
lines changed

14 files changed

+488
-452
lines changed

src/engine/SceneManagement/SceneBuilder.jl

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,11 +16,13 @@ module SceneBuilderModule
1616
println("Loading scripts in test folder...")
1717
include.(filter(contains(r".jl$"), readdir(joinpath(pwd(), "projects", "ProfilingTest", "Platformer", "scripts"); join=true)))
1818
include.(filter(contains(r".jl$"), readdir(joinpath(pwd(), "projects", "SmokeTest", "scripts"); join=true)))
19+
@info "Loaded test scripts"
1920
end
2021

2122
if isdir(joinpath(pwd(), "..", "scripts")) #dev builds
2223
# println("Loading scripts...")
2324
include.(filter(contains(r".jl$"), readdir(joinpath(pwd(), "..", "scripts"); join=true)))
25+
@info "Loaded scripts"
2426
else
2527
script_folder_name = "scripts"
2628
current_dir = pwd()
@@ -37,6 +39,7 @@ module SceneBuilderModule
3739
break # Exit loop if "scripts" folder is found in any parent folder
3840
end
3941
end
42+
@info "Loaded scripts"
4043
end
4144
end
4245

@@ -109,6 +112,7 @@ module SceneBuilderModule
109112
MAIN.scene.entities = scene[1]
110113
MAIN.scene.uiElements = scene[2]
111114
MAIN.scene.camera = scene[3]
115+
print("caMERA : $(MAIN.scene.camera)")
112116
if size.x < MAIN.scene.camera.size.x && size.x > 0
113117
MAIN.scene.camera.size = Vector2(size.x, MAIN.scene.camera.size.y)
114118
end

src/engine/UI/TextBox.jl

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,8 @@ module TextBoxModule
6262
SDL2.SDL_Point(this.position.x, this.position.y)], 5)
6363
end
6464

65-
cameraDiff = this.isWorldEntity && MAIN.scene.camera !== nothing ?
65+
camera = MAIN.scene.camera
66+
cameraDiff = this.isWorldEntity && camera !== nothing ?
6667
Math.Vector2((camera.position.x + camera.offset.x) * SCALE_UNITS, (camera.position.y + camera.offset.y) * SCALE_UNITS) :
6768
Math.Vector2(0,0)
6869

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,11 @@
1+
CameraHeight=600
2+
FrameRate=30
13
Width=800
24
Zoom=1.0
3-
CameraHeight=600
5+
AutoScaleZoom=0
46
Height=600
5-
FrameRate=30
7+
PixelsPerUnit=16
8+
IsResizable=0
69
WindowName=Default Game
7-
AutoScaleZoom=0
810
CameraWidth=800
9-
IsResizable=0
11+
Fullscreen=0
Lines changed: 17 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,24 @@
1-
mutable struct Background
2-
parent
1+
module BackgroundModule
2+
using JulGame
3+
mutable struct Background
4+
parent
35

4-
function Background()
5-
this = new()
6+
function Background()
7+
this = new()
68

7-
this.parent = C_NULL
9+
this.parent = C_NULL
810

9-
return this
11+
return this
12+
end
1013
end
11-
end
1214

13-
function JulGame.initialize(this::Background)
14-
end
15+
function JulGame.initialize(this::Background)
16+
end
1517

16-
function JulGame.update(this::Background, deltaTime)
17-
this.parent.transform.position = JulGame.Math.Vector2f(MAIN.scene.camera.position.x + 9.5, 0)
18-
end
18+
function JulGame.update(this::Background, deltaTime)
19+
this.parent.transform.position = JulGame.Math.Vector2f(MAIN.scene.camera.position.x + 9.5, 0)
20+
end
1921

20-
function JulGame.on_shutdown(this::Background)
21-
end
22+
function JulGame.on_shutdown(this::Background)
23+
end
24+
end # module
Lines changed: 39 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -1,45 +1,48 @@
1-
mutable struct Fish
2-
animator
3-
endingY::Int32
4-
isFire::Bool
5-
isMovingUp::Bool
6-
parent::JulGame.EntityModule.Entity
7-
sound::SoundSourceModule.SoundSource
8-
speed::Number
9-
startingY::Int32
1+
module FishModule
2+
using JulGame
3+
mutable struct Fish
4+
animator
5+
endingY::Int32
6+
isFire::Bool
7+
isMovingUp::Bool
8+
parent::JulGame.EntityModule.Entity
9+
sound::SoundSourceModule.SoundSource
10+
speed::Number
11+
startingY::Int32
1012

11-
function Fish(speed::Number = 5, startingY::Int32 = Int32(0), endingY::Int32 = Int32(0), isFire::Bool = false)
12-
this = new()
13+
function Fish(speed::Number = 5, startingY::Int32 = Int32(0), endingY::Int32 = Int32(0), isFire::Bool = false)
14+
this = new()
1315

14-
this.endingY = endingY
15-
this.isFire = isFire
16-
this.isMovingUp = false
17-
this.speed = speed
18-
this.startingY = startingY
16+
this.endingY = endingY
17+
this.isFire = isFire
18+
this.isMovingUp = false
19+
this.speed = speed
20+
this.startingY = startingY
1921

20-
return this
22+
return this
23+
end
2124
end
22-
end
2325

24-
function JulGame.initialize(this::Fish)
25-
this.animator = this.parent.animator
26-
this.parent.sprite.rotation = 90
27-
end
28-
function JulGame.update(this::Fish, deltaTime)
29-
if this.parent.transform.position.y >= this.startingY && !this.isMovingUp
30-
this.parent.sprite.rotation = this.isFire ? 0 : 90
31-
this.isMovingUp = true
32-
elseif this.parent.transform.position.y <= this.endingY && this.isMovingUp
33-
this.parent.sprite.rotation = this.isFire ? 180 : 270
34-
this.isMovingUp = false
26+
function JulGame.initialize(this::Fish)
27+
this.animator = this.parent.animator
28+
this.parent.sprite.rotation = 90
3529
end
30+
function JulGame.update(this::Fish, deltaTime)
31+
if this.parent.transform.position.y >= this.startingY && !this.isMovingUp
32+
this.parent.sprite.rotation = this.isFire ? 0 : 90
33+
this.isMovingUp = true
34+
elseif this.parent.transform.position.y <= this.endingY && this.isMovingUp
35+
this.parent.sprite.rotation = this.isFire ? 180 : 270
36+
this.isMovingUp = false
37+
end
3638

37-
if this.isMovingUp
38-
this.parent.transform.position = Vector2f(this.parent.transform.position.x, this.parent.transform.position.y - this.speed*deltaTime)
39-
else
40-
this.parent.transform.position = Vector2f(this.parent.transform.position.x, this.parent.transform.position.y + this.speed*deltaTime)
39+
if this.isMovingUp
40+
this.parent.transform.position = Vector2f(this.parent.transform.position.x, this.parent.transform.position.y - this.speed*deltaTime)
41+
else
42+
this.parent.transform.position = Vector2f(this.parent.transform.position.x, this.parent.transform.position.y + this.speed*deltaTime)
43+
end
4144
end
42-
end
4345

44-
function JulGame.on_shutdown(this::Fish)
45-
end
46+
function JulGame.on_shutdown(this::Fish)
47+
end
48+
end # module
Lines changed: 55 additions & 52 deletions
Original file line numberDiff line numberDiff line change
@@ -1,56 +1,59 @@
1-
mutable struct GameManager
2-
currentLevel::Int32
3-
currentMusic
4-
soundBank
5-
starCount::Int32
6-
parent
7-
8-
function GameManager()
9-
this = new()
10-
11-
this.currentLevel = 1
12-
this.parent = C_NULL
13-
this.soundBank = [
14-
"water-ambience.mp3",
15-
"lava.wav",
16-
"strong-wind.wav",
17-
]
18-
this.starCount = 3
19-
20-
return this
21-
end
22-
end
23-
24-
function JulGame.initialize(this::GameManager)
25-
MAIN.scene.camera.offset = JulGame.Math.Vector2f(0, -2.75)
26-
#todo: MAIN.cameraBackgroundColor = (0, 0, 0)
27-
MAIN.optimizeSpriteRendering = true
28-
29-
JulGame.add_shape(this.parent, JulGame.ShapeModule.Shape(Math.Vector3(0,0,0), true, false, 0, Math.Vector2f(0,0), Math.Vector2f(1.2175,0.5), Math.Vector2f(10,5)))
30-
coinUI = JulGame.SceneModule.get_entity_by_id(MAIN.scene, "44e5d671-cf93-4862-9048-9900f55be3dc")
31-
livesUI = JulGame.SceneModule.get_entity_by_name(MAIN.scene, "LivesUI")
32-
33-
# coinUI.persistentBetweenScenes = true
34-
# coinUI.sprite.isWorldEntity = false
35-
# coinUI.sprite.position = JulGame.Math.Vector2f(-.1, 1)
36-
37-
livesUI.persistentBetweenScenes = true
38-
livesUI.sprite.isWorldEntity = false
39-
livesUI.sprite.position = JulGame.Math.Vector2f(-.1, .25)
40-
41-
this.parent.persistentBetweenScenes = true
42-
if this.currentLevel > 1
43-
# JulGame.Component.unload_sound(this.currentMusic)
1+
module GameManagerModule
2+
using JulGame
3+
mutable struct GameManager
4+
currentLevel::Int32
5+
currentMusic
6+
soundBank
7+
starCount::Int32
8+
parent
9+
10+
function GameManager()
11+
this = new()
12+
13+
this.currentLevel = 1
14+
this.parent = C_NULL
15+
this.soundBank = [
16+
"water-ambience.mp3",
17+
"lava.wav",
18+
"strong-wind.wav",
19+
]
20+
this.starCount = 3
21+
22+
return this
23+
end
4424
end
4525

46-
# this.currentMusic = JulGame.create_sound_source(this.parent, JulGame.SoundSourceModule.SoundSource(Int32(-1), true, this.soundBank[this.currentLevel], Int32(25)))
47-
# JulGame.Component.toggle_sound(this.currentMusic)
48-
49-
JulGame.UI.update_text(MAIN.scene.uiElements[2], string(this.starCount))
50-
end
26+
function JulGame.initialize(this::GameManager)
27+
MAIN.scene.camera.offset = JulGame.Math.Vector2f(0, -2.75)
28+
#todo: MAIN.cameraBackgroundColor = (0, 0, 0)
29+
MAIN.optimizeSpriteRendering = true
30+
31+
JulGame.add_shape(this.parent, JulGame.ShapeModule.Shape(Math.Vector3(0,0,0), true, false, 0, Math.Vector2f(0,0), Math.Vector2f(1.2175,0.5), Math.Vector2f(10,5)))
32+
coinUI = JulGame.SceneModule.get_entity_by_id(MAIN.scene, "44e5d671-cf93-4862-9048-9900f55be3dc")
33+
livesUI = JulGame.SceneModule.get_entity_by_name(MAIN.scene, "LivesUI")
34+
35+
# coinUI.persistentBetweenScenes = true
36+
# coinUI.sprite.isWorldEntity = false
37+
# coinUI.sprite.position = JulGame.Math.Vector2f(-.1, 1)
38+
39+
livesUI.persistentBetweenScenes = true
40+
livesUI.sprite.isWorldEntity = false
41+
livesUI.sprite.position = JulGame.Math.Vector2f(-.1, .25)
42+
43+
this.parent.persistentBetweenScenes = true
44+
if this.currentLevel > 1
45+
# JulGame.Component.unload_sound(this.currentMusic)
46+
end
47+
48+
# this.currentMusic = JulGame.create_sound_source(this.parent, JulGame.SoundSourceModule.SoundSource(Int32(-1), true, this.soundBank[this.currentLevel], Int32(25)))
49+
# JulGame.Component.toggle_sound(this.currentMusic)
50+
51+
JulGame.UI.update_text(MAIN.scene.uiElements[2], string(this.starCount))
52+
end
5153

52-
function JulGame.update(this::GameManager, deltaTime)
53-
end
54+
function JulGame.update(this::GameManager, deltaTime)
55+
end
5456

55-
function JulGame.on_shutdown(this::GameManager)
56-
end
57+
function JulGame.on_shutdown(this::GameManager)
58+
end
59+
end # module

0 commit comments

Comments
 (0)