forked from jaammees/lvllvl
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathapi.html
More file actions
97 lines (78 loc) · 2.33 KB
/
api.html
File metadata and controls
97 lines (78 loc) · 2.33 KB
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
<html>
<head>
<style>
</style>
</head>
<body>
<div>
Hold ctrl/cmd + R for the scripting window, or select from the menu View->Scripting
</div>
<h2>Graphic API</h2>
<div>
<h3>Example</h3>
<pre>
let layer = GraphicAPI.getLayer({ path: '/screens/Untitled', layer: 'Layer 0'});
for(let x = 6; x < 21; x++) {
for(let y = 13; y < 20; y++) {
layer.setCell({x: x, y: y, t: 7, fc:5 });
}
}
let tileset = GraphicAPI.getTileset({ path: '/tile sets/petscii'});
for(let y = 0; y < 4; y++) {
for(let x = 0; x < 8; x++) {
tileset.setPixel({
t: 0,
x: x, y: y,
p: 1
});
}
}
for(let x = 0; x < 8; x++) {
for(let y = 0; y < 8; y++) {
var p = layer.getPixel({ x: x, y: y });
p = 1 - p;
layer.setPixel({
x: x,
y: y,
p: p
});
}
}
let frameCount = GraphicAPI.getFrameCount();
console.log('count = ' + frameCount);
GraphicAPI.setFrameDuration({
frame: 1,
duration: 3
});
let frameData = layer.getFrameData();
console.log(frameData);
</pre>
</div>
<h2>Editor</h2>
<div>
<h3>Example</h3>
<pre>
Editor.on('tick', () => {
let layer = GraphicAPI.getLayer({ path: '/screens/Untitled', layer: 'Layer 0'});
let tileIndex = Math.floor(Math.random() * 256);
for(let x = 6; x < 21; x++) {
for(let y = 13; y < 20; y++) {
layer.setCell({x: x, y: y, t: tileIndex, fc:5 });
}
}
});
</pre>
</div>
</body>
<!--
Editor.on('tick', () => {
const screenWidth = Screen.getWidth();
const screenHeight = Screen.getHeight();
let tileIndex = Math.floor(Math.random() * 256);
let colourIndex = Math.floor(Math.random() * 16);
let x = Math.floor(Math.random() * screenWidth);
let y = Math.floor(Math.random() * screenHeight);
Screen.setCell({ x, y, t: tileIndex, fc: colourIndex });
});
-->
</html>