Skip to content

Commit 9641050

Browse files
committed
Merge branch 'main' of github.com:openpatch/scratch-for-java
2 parents e3cf050 + f8e9cbd commit 9641050

File tree

10 files changed

+146
-213
lines changed

10 files changed

+146
-213
lines changed
Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,14 @@
11
import org.openpatch.scratch.Stage;
22

33
public class BouncyHedgehogStage extends Stage {
4-
5-
public BouncyHedgehogStage() {
6-
this.addBackdrop("playground", "playground.jpg");
7-
this.add(new HedgehogSprite());
8-
this.add(new TrampolineSprite());
9-
}
104

11-
public static void main(String[] args) {
12-
new BouncyHedgehogStage();
13-
}
5+
public BouncyHedgehogStage() {
6+
this.addBackdrop("playground", "playground.jpg");
7+
this.add(new HedgehogSprite());
8+
this.add(new TrampolineSprite());
9+
}
10+
11+
public static void main(String[] args) {
12+
new BouncyHedgehogStage();
13+
}
1414
}

examples/archives/bouncy-hedgehog-100/HedgehogSprite.java

Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -3,23 +3,23 @@
33

44
public class HedgehogSprite extends Sprite {
55

6-
public HedgehogSprite() {
7-
this.addCostume("hedgehog", "hedgehog.png");
6+
public HedgehogSprite() {
7+
this.addCostume("hedgehog", "hedgehog.png");
88

9-
this.pointInDirection(15);
10-
this.setPosition(-180, 140);
11-
}
9+
this.pointInDirection(15);
10+
this.setPosition(-180, 140);
11+
}
1212

13-
public void run() {
14-
if (this.getY() > -120) {
15-
this.move(1);
16-
this.ifOnEdgeBounce();
13+
public void run() {
14+
if (this.getY() > -120) {
15+
this.move(1);
16+
this.ifOnEdgeBounce();
1717

18-
if (this.isTouchingSprite(TrampolineSprite.class)) {
19-
this.pointInDirection(Random.random(-45, 45));
20-
}
21-
} else {
22-
this.say("Ouch!", 2000);
23-
}
18+
if (this.isTouchingSprite(TrampolineSprite.class)) {
19+
this.pointInDirection(Random.random(-45, 45));
20+
}
21+
} else {
22+
this.say("Ouch!", 2000);
2423
}
24+
}
2525
}

examples/archives/bouncy-hedgehog-100/TrampolineSprite.java

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -2,16 +2,16 @@
22
import org.openpatch.scratch.Sprite;
33

44
public class TrampolineSprite extends Sprite {
5-
public TrampolineSprite() {
6-
this.addCostume("trampoline", "trampoline.png");
7-
this.setPosition(0, -120);
8-
}
5+
public TrampolineSprite() {
6+
this.addCostume("trampoline", "trampoline.png");
7+
this.setPosition(0, -120);
8+
}
99

10-
public void whenKeyPressed(int keyCode) {
11-
if (keyCode == KeyCode.VK_LEFT) {
12-
this.changeX(-10);
13-
} else if (keyCode == KeyCode.VK_RIGHT) {
14-
this.changeX(10);
15-
}
10+
public void whenKeyPressed(int keyCode) {
11+
if (keyCode == KeyCode.VK_LEFT) {
12+
this.changeX(-10);
13+
} else if (keyCode == KeyCode.VK_RIGHT) {
14+
this.changeX(10);
1615
}
16+
}
1717
}
Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
import org.openpatch.scratch.Stage;
22

33
public class BouncyHedgehogStage extends Stage {
4-
5-
public BouncyHedgehogStage() {
6-
this.addBackdrop("playground", "playground.jpg");
7-
}
4+
5+
public BouncyHedgehogStage() {
6+
this.addBackdrop("playground", "playground.jpg");
7+
}
88
}

examples/archives/bouncy-hedgehog/HedgehogSprite.java

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,7 @@
22

33
public class HedgehogSprite extends Sprite {
44

5-
public HedgehogSprite() {
6-
this.addCostume("hedgehog", "hedgehog.png");
7-
}
8-
5+
public HedgehogSprite() {
6+
this.addCostume("hedgehog", "hedgehog.png");
7+
}
98
}
Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import org.openpatch.scratch.Sprite;
22

33
public class TrampolineSprite extends Sprite {
4-
public TrampolineSprite() {
5-
this.addCostume("trampoline", "trampoline.png");
6-
}
4+
public TrampolineSprite() {
5+
this.addCostume("trampoline", "trampoline.png");
6+
}
77
}

examples/archives/cat/CatSprite.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,4 +17,4 @@ public void whenKeyPressed(int keyCode) {
1717
public void run() {
1818
this.move(2);
1919
}
20-
}
20+
}

examples/reference/SpriteWhenKeyPressed.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
1+
import java.awt.event.*;
12
import org.openpatch.scratch.KeyCode;
23
import org.openpatch.scratch.Sprite;
34
import org.openpatch.scratch.Stage;
45
import org.openpatch.scratch.extensions.recorder.*;
5-
import java.awt.event.*;
66

77
public class SpriteWhenKeyPressed {
88

0 commit comments

Comments
 (0)