-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathtutorialoutline.txt
133 lines (90 loc) · 2.06 KB
/
tutorialoutline.txt
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
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
A simple program:
-
trace("hello world");
-
While loops:
-
var x = 5;
while (x<10) {
x++;
trace(x);
}
-
For loops:
-
for (i in 0 ... 100)
trace((100-i)+"bottles of beer on the wall");
-
For loops can only go up. Sorry.
More for loops:
-
var exclamation = ["I","like","big","zeedonks"];
for (s in exclamation)
trace(s);
-
<a class="tutoriallink" href="https://en.wikipedia.org/wiki/Fibonacci_number">Fibonacci number</a> printer
-
function f(n) {
if (n<2) return 1;
else return f(n-1)+f(n-2);
}
/* if you make the value at all big, */
/* your browser will explode. */
/* So don't do that! */
trace(f(5));
-
If you make an update function, it will be call every frame. That's how you draw things.
-
function update(){
Gfx.fillbox(10,10,20,20,Col.RED);
}
-
At any time, you can press ctrl/cmd+space to bring up autocomplete. Here's how to do input:
-
function update() {
if (Input.justpressed(Key.UP)){
trace("pressed up, innit");
}
}
-
Here's how you display text on-screen:
-
function update() {
Text.display(0,0,"Hello, sailor!");
}
-
Switch cases in Zeedonk look like this:
-
var animal = "zeedonk";
//Note that you can have multiple patterns,
//and that break commands are not used.
switch (animal) {
case "zebra", "donkey":
trace("zeedonkish");
case "zeedonk":
trace("zeedonk");
default:
trace ("not zeedonk");
}
-
You can use && for AND and || for OR in if statements:
-
var animal1 = "zebra";
var animal2 = "donkey";
if((animal1 == "zebra" || animal1 == "donkey") &&
(animal2 == "zebra" || animal2 == "donkey") &&
animal1 != animal2){
trace("ZEEDONK");
}else{
trace("NOT ZEEDONK");
}
-
You can use the keyword <b>null</b> to check for unset variables.
-
var nothing;
trace(nothing);
if(nothing == null) nothing = "something";
trace(nothing);
-
For more, browse the examples via the examples dropdown in <a class="tutoriallink" href="../editor.html">the editor</a>, or browse the many examples in the <a class="tutoriallink" href="index.html">library reference</a>.
Good luck!