Skip to content

Commit e089a15

Browse files
committed
Updated documentations
1 parent 057752e commit e089a15

12 files changed

Lines changed: 82 additions & 48 deletions

File tree

docs/3-BasicApp.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ julia> app = CruiseApp()
3131
You can now define a game loop using the `@gameloop` macro:
3232

3333
```julia
34-
julia> @gameloop max_fps=60 app begin
34+
julia> @gameloop max_fps=60 begin
3535
println("delta seconds: $(LOOP_VAR.delta_seconds)")
3636
# Simulate a 10-second delay before shutting down
3737
LOOP_VAR.frame_idx > 600 && shutdown!()

docs/API.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
```
44
CruiseApp
55
@gameloop
6+
@gamelogic
67
awake!
78
update!
89
shutdown!
@@ -17,6 +18,8 @@ add_system!
1718
add_dependency!
1819
remove_system!
1920
remove_dependency!
21+
enable_system
22+
disable_system
2023
merge_plugin!
2124
getdep
2225
isinitialized

docs/Plugins/index.md

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -130,6 +130,19 @@ end
130130

131131
Errors during update! are caught automatically and set the node status to PLUGIN_ERR.
132132

133+
---
134+
135+
## Enabling/Disabling systems
136+
137+
A system can be made active or inactive with the functions
138+
139+
```
140+
enable_system(plugin, sys_id, awake=true) # awake is whether or not `awake!` should be called on the system
141+
disable_system(plugin, sys_id, shut=false) # shut is whether or not `shutdown!` should be called on the system
142+
```
143+
144+
A disabled system will no more run but still be in the graph and can be reactivated.
145+
The benefits of this is that we can add or remove logic without modifying the graph and recomputing the topological order.
133146

134147
---
135148

docs/events.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ Now we will connect a function to it that will update our health bar object when
3232

3333
```julia
3434
connect(HP) do hp
35-
HB.current = ho
35+
HB.current = hp
3636
end
3737
```
3838

docs/examples/basic_app.jl

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,8 @@ using Cruise
22

33
app = CruiseApp()
44

5-
@gameloop max_fps=60 app begin
6-
println("delta seconds: $(LOOP_VAR.delta_seconds)")
5+
@gameloop max_fps=60 begin
6+
println("delta seconds: $(LOOP_VAR_REF[].delta_seconds)")
77
# Simulate a 10-second delay before shutting down
88
LOOP_VAR.frame_idx > 600 && shutdown!()
99
end

docs/examples/basic_drawing.jl

Lines changed: 10 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -1,28 +1,19 @@
11
using Cruise
2-
using ODPlugin
3-
using HZPlugin
2+
using Cruise.ODPlugin
3+
using Cruise.HZPlugin
4+
5+
using SDLOutdoors, SDLHorizons
46

57
app = CruiseApp()
6-
Close = Ref(false)
78

8-
merge_plugin!(app, ODPLUGIN, ODPlugin.PHASE)
9-
merge_plugin!(app, HZPLUGIN, HZPlugin.PHASE)
9+
merge_plugin!(app, ODPLUGIN)
10+
merge_plugin!(app, HZPLUGIN)
1011

1112
win = CreateWindow(SDLStyle, "My First Window", 640, 480)
12-
winptr = GetStyle(win).window
13-
14-
RegisterBackend(SDLRender, winptr, 640, 480)
15-
16-
Outdoors.connect(NOTIF_QUIT_EVENT) do
17-
Close[] = true
18-
end
13+
backend = InitBackend(SDLRender, GetStyle(win).window, 640, 480)
1914

2015
@gameloop max_fps=60 begin
21-
backend = GetBackend(winptr)
22-
if !isnothing(backend)
23-
24-
DrawPoint2D(backend, iRGBA(0, 50, 30, 8), Vec2f(50, 50))
25-
DrawLine2D(backend, iRGBA(0, 50, 30, 8), Vec2f(100, 100), Vec2f(150, 150))
26-
end
27-
Close[] && shutdown!()
16+
DrawPoint2D(backend, iRGBA(0, 50, 30, 8), Vec2f(50, 50))
17+
DrawLine2D(backend, iRGBA(0, 50, 30, 8), Vec2f(100, 100), Vec2f(150, 150))
18+
app.ShouldClose && shutdown!()
2819
end

docs/examples/creating_window.jl

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,13 @@
11
using Cruise
2-
using ODPlugin
2+
using Cruise.ODPlugin
3+
using SDLOutdoors
34

45
app = CruiseApp()
5-
Close = Ref(false)
66

7-
merge_plugin!(app, ODPLUGIN, ODPlugin.PHASE)
7+
merge_plugin!(app, ODPLUGIN)
88

99
win = CreateWindow(SDLStyle, "My First Window", 640, 480)
1010

11-
Outdoors.connect(NOTIF_QUIT_EVENT) do
12-
Close[] = true
13-
end
14-
1511
@gameloop max_fps=60 begin
16-
Close[] && shutdown!()
12+
app.ShouldClose && shutdown!()
1713
end

docs/examples/drawing_image.jl

Lines changed: 9 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,33 +1,28 @@
11
using Cruise
2-
using ODPlugin
3-
using HZPlugin
2+
using Cruise.ODPlugin
3+
using Cruise.HZPlugin
4+
5+
using SDLOutdoors, SDLHorizons
46

57
app = CruiseApp()
6-
Close = Ref(false)
78

8-
merge_plugin!(app, ODPLUGIN, ODPlugin.PHASE)
9-
merge_plugin!(app, HZPLUGIN, HZPlugin.PHASE)
9+
merge_plugin!(app, ODPLUGIN)
10+
merge_plugin!(app, HZPLUGIN)
1011

1112
win = CreateWindow(SDLStyle, "My First Window", 640, 480)
1213
winptr = GetStyle(win).window
13-
1414
backend = CreateBackend(SDLRender, winptr, 640, 480)
1515

16-
Outdoors.connect(NOTIF_QUIT_EVENT) do
17-
Close[] = true
18-
end
19-
2016
img = @crate "assets|001.png"::ImageCrate
2117

22-
added = false
2318
pos = Vec2f(0,0)
2419
texture = Texture(backend, img)
2520

2621
@gameloop max_fps=60 begin
2722

28-
Main.pos.x += IsKeyPressed(win, "RIGHT") - IsKeyPressed(win, "LEFT")
29-
Main.pos.y += IsKeyPressed(win, "DOWN") - IsKeyPressed(win, "UP")
23+
pos.x += IsKeyPressed(win, "RIGHT") - IsKeyPressed(win, "LEFT")
24+
pos.y += IsKeyPressed(win, "DOWN") - IsKeyPressed(win, "UP")
3025

3126
DrawTexture2D(backend, Main.texture, Rect2Df(pos...,1,1))
32-
Close[] && shutdown!()
27+
app.ShouldClose && shutdown!()
3328
end

docs/examples/pauser.jl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
module PausePlugin
22

33
using Cruise
4-
using ODPlugin, ..TimerPlugin
4+
using Cruise.ODPlugin, ..TimerPlugin
55

66
const PAUSEPLUGIN = CRPlugin()
77

docs/gamearch.md

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,6 @@ Each plugin can access the data of his dependencies, their states and more.
1111
This itself form dataflow based architecture when each plugin passes data to the dependent ones.
1212
For example, when the Physics plugin updates object positions,
1313
the Renderer plugin automatically gets the new data through the DAG.
14-
No boilerplate. No manual sync. Just data flowing between systems.
1514

1615
But that's not everything about it.
1716
You can make plugins for different types of architectures.

0 commit comments

Comments
 (0)