forked from martin-pabst/Online-IDE-new-compiler
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathembedded_scratch.html
More file actions
103 lines (92 loc) · 2.99 KB
/
Copy pathembedded_scratch.html
File metadata and controls
103 lines (92 loc) · 2.99 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
98
99
100
101
102
103
<!DOCTYPE html>
<html>
<head>
<meta charset='utf-8'>
<title>Scratch-Test</title>
<meta name='viewport' content='width=device-width, initial-scale=1'>
<script type="module" src="/src/client/embedded/EmbeddedStarter.ts"></script>
</head>
<body>
<h1>Scratch for Java — test</h1>
<div class="java-online" style="width: calc(100% - 10px); height: 560px; margin-left: 5px" data-java-online="{
'id': 'scratchtest',
'speed': 'max',
'withFileList': true,
'hideEditor': false,
'hideStartPanel': false,
'libraries': ['scratch']
}">
<script type="text/plain" title="MyStage.java" data-type="java">
new Level1();
// Two stages in one program. Bühne 2 is built right away but waits off screen
// until transitionToStage() fades over to it; while it waits, nothing on it runs.
class Level1 extends Stage {
Level2 zwei;
Laeufer laeufer;
boolean gewechselt = false;
public Level1() {
super(480, 360);
this.setColor(0, 0, 180);
this.laeufer = new Laeufer();
this.add(this.laeufer);
this.laeufer.setPosition(-80, 0);
Text t = new Text("Bühne 1", -220, 160, 200);
this.add(t);
t.showText("Bühne 1");
this.zwei = new Level2(this.laeufer);
print("Bühne 1 ist aktiv: " + (Window.getInstance().getStage() == this));
print("Laeufer kennt seine Bühne: " + (this.laeufer.getStage() == this));
}
public void run() {
if (!this.gewechselt && Timer.millis() > 2500) {
this.gewechselt = true;
print("Schritte auf Bühne 1 beim Wechsel: " + this.laeufer.schritte);
Window.getInstance().transitionToStage(this.zwei, 150);
}
}
}
class Level2 extends Stage {
Laeufer alter;
Karotte karotte;
boolean gemeldet = false;
public Level2(Laeufer alter) {
super(480, 360);
this.alter = alter;
this.setColor(255, 140, 0);
this.karotte = new Karotte();
this.add(this.karotte);
Text t = new Text("Bühne 2", -220, 160, 200);
this.add(t);
t.showText("Bühne 2");
}
public void run() {
this.karotte.turnRight(4);
if (!this.gemeldet && Timer.millis() > 4500) {
this.gemeldet = true;
print("Bühne 2 ist aktiv: " + (Window.getInstance().getStage() == this));
print("Schritte auf Bühne 1 danach (soll gleich sein): " + this.alter.schritte);
print("Karotte kennt ihre Bühne: " + (this.karotte.getStage() == this));
}
}
}
class Laeufer extends Sprite {
public int schritte = 0;
public void whenAddedToStage() {
this.addCostume("bunny1_stand");
this.setSize(120);
}
public void run() {
this.schritte = this.schritte + 1;
this.turnRight(3);
}
}
class Karotte extends Sprite {
public void whenAddedToStage() {
this.addCostume("carrot");
this.setSize(200);
}
}
</script>
</div>
</body>
</html>