-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathsetup.js
70 lines (60 loc) · 2.31 KB
/
setup.js
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
var playerPos, frame, playerYVelocity, clicked, obstaclesPos, gameOn, coinPos, score, scrollSpeed;
async function setup() {
playerPos = [300, 350];
frame = 0;
playerYVelocity = 0;
clicked = false;
obstaclesPos = [
{
x: 800,
y: 600,
r: 20,
},
{
x: 1000,
y: 500,
r: 20,
},
{
x: 1200,
y: 400,
r: 20,
},
{
x: 1400,
y: 300,
r: 20,
},
];
gameOn = true;
coinPos = {
x: 1400,
y: 100,
r: 36,
};
score = 0;
scrollSpeed = 3;
await Photopea.runScript(window.parent, "app.documents.add(800, 700, 72, 'Flappy Ivan Kutskir')");
await Photopea.runScript(window.parent, "app.UI.fitTheArea()");
await addImageAndWait(window.parent, "https://yikuansun.github.io/photopea-flappyIvan/img/bgPlate.png");
await Photopea.runScript(window.parent, `app.activeDocument.activeLayer.name = "bgPlate";`);
await addImageAndWait(window.parent, "https://yikuansun.github.io/photopea-flappyIvan/img/ivanHead.png");
await Photopea.runScript(window.parent, `app.activeDocument.activeLayer.name = "ivanHead";`);
for (var i = 0; i < obstaclesPos.length; i++) {
await addImageAndWait(window.parent, "https://yikuansun.github.io/photopea-flappyIvan/img/dinoBill.png");
await Photopea.runScript(window.parent, `app.activeDocument.activeLayer.name = "dinoBill${i}";`);
}
await addImageAndWait(window.parent, "https://yikuansun.github.io/photopea-flappyIvan/img/photopeaCoin.png");
await Photopea.runScript(window.parent, `app.activeDocument.activeLayer.name = "photopeaCoin";`);
await Photopea.runScript(window.parent, `app.activeDocument.artLayers.add();
app.activeDocument.activeLayer.kind = LayerKind.TEXT;
app.activeDocument.activeLayer.textItem.contents = "hello world";`);
await Photopea.runScript(window.parent, `app.activeDocument.activeLayer.textItem.size = 24;`);
await Photopea.runScript(window.parent, `app.activeDocument.activeLayer.name = "scoreCounter";`);
return new Promise(function(resolve, reject) {
resolve();
});
}
document.querySelector("button").addEventListener("click", function() {
clicked = true;
});