This repository was archived by the owner on Jan 8, 2025. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathsample.cdlv
100 lines (86 loc) · 3.34 KB
/
sample.cdlv
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
# This is a comment. It's not parsed by CDLV.
# Lines starting with `!` are definitions.
# `!resources_path` defines a path for loading resources.
# Without this, CDLV will only look for resources in scripts directory.
!resources_path "images/"
# Let's define resources.
# Resources are images or animations used just like variables.
# Because they will be loaded as soon as CDLV is called to play the script,
# and live for it's whole life, try not to declare too much.
# It's best to leave global resources for reserving data used by whole script/game.
# Let's reserve a name `empty` when we don't want to display anything
# and we want it to make it obvious inside our script:
!resources {
empty "white.png"
}
# Note: It's better to not write `!resources` and `!resources_path` again.
# For a script to run and display, a scene must exist.
# Scene is a special in many ways.
# For example, it's definition requires a name, e.g. `countdown` below:
!scene countdown {
# Inside a scene, you can define new `!resources_path` and `!resources`.
# These will be valid only inside this scene's scope.
# Resources defined here will be loaded as soon as the scene starts to play.
# This is the only place where you can call `!resources_path` and `!resources` again.
# `!resources_path` inside a scene is appended to the global `!resources_path`.
# Therefore, the line below will make the CDLV look for resources inside `images/scene/`:
!resources_path "scene/"
!resources {
# You can add a resource in one more way.
# You can add a resource just as a filename.
# It's name will get taken from the filename, e.g. `1`, `2`, `3` for the lines below:
"1.png"
"2.png"
"3.png"
# This works in every scope.
animation "anim.mp4"
}
# Lines starting with `@` are prompts or functions.
# Each word separated by a whitespace is it's argument.
# Currently, there is only `@bg`.
# It sets the current background resource.
# Line below sets the current background to a global resource loaded from `images/white.png`:
@bg empty
# Lines without any prefix are script lines that will be printed on screen.
I just displayed empty background.
@bg 1
It should show 1.
@bg 2
It should show 2.
@bg 3
It should show 3.
@bg empty
"Now, for the special show."
# Calls to `@bg` with one argument (a resource) just like until now
# display static image resources.
# If you want to play a loaded animation,
# you have to call `@bg resource time`, e.g.:
# `@bg resource once` for animation that plays once,
# `@bg resource loop` for looped animation.
@bg animation loop
# If you'd call `@bg animation` without `time`, it'll default to `once`.
"Do you see this?"
"Now let's try loading dynamically."
# `.` is not allowed in resource name.
# If there's a dot in resource name when calling `@bg`,
# CDLV will create a resource with that name.
# The paths it searches are the same as declared for the script.
@bg 4.png
"It should show 4."
@bg 5.png
"It should show 5."
@bg 6.png
"It should show 6."
@bg empty
"Let's load in more things dynamically."
@bg 1.png
"It should show 1."
@bg 2.png
"It should show 2."
# You can also load a .mp4 video tthe same way.
# Animation set as background at an end of scene
# will either loop till the program dies
# or end scene after finishing single loop.
@bg anim.mp4 once
# On scene's end, all it's resources are freed.
}