Skip to content

Commit f285f74

Browse files
committed
initial commit
0 parents  commit f285f74

File tree

172 files changed

+1729
-0
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

172 files changed

+1729
-0
lines changed

Ghost1.class

1.62 KB
Binary file not shown.

Ghost1.ctxt

+11
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
#BlueJ class context
2+
comment0.target=Ghost1
3+
comment1.params=speed\ stopPointLeft\ stopPointRight
4+
comment1.target=Ghost1(int,\ int,\ int)
5+
comment2.params=
6+
comment2.target=void\ act()
7+
comment3.params=
8+
comment3.target=void\ moveHorizontally()
9+
comment4.params=
10+
comment4.target=void\ checkCollision()
11+
numComments=5

Ghost1.java

+64
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,64 @@
1+
import greenfoot.*;
2+
3+
public class Ghost1 extends Actor
4+
{
5+
private int speed;
6+
private boolean movingRight;
7+
private int stopPointLeft;
8+
private int stopPointRight;
9+
10+
public Ghost1(int speed, int stopPointLeft, int stopPointRight) {
11+
this.speed = speed;
12+
this.movingRight = true; // default ke kanan
13+
this.stopPointLeft = stopPointLeft;
14+
this.stopPointRight = stopPointRight;
15+
}
16+
17+
public void act()
18+
{
19+
if (getWorld() == null) {
20+
return; // Jika objek telah dihapus dari dunia, hentikan eksekusi
21+
}
22+
checkCollision();
23+
if (getWorld() == null) {
24+
return; // Jika objek telah dihapus dari dunia, hentikan eksekusi
25+
}
26+
moveHorizontally();
27+
}
28+
29+
public void moveHorizontally() {
30+
if (getWorld() == null) {
31+
return; // Jika objek telah dihapus dari dunia, hentikan eksekusi
32+
}
33+
checkCollision();
34+
if (getWorld() == null) {
35+
return; // Jika objek telah dihapus dari dunia, hentikan eksekusi
36+
}
37+
if (movingRight) {
38+
move(speed);
39+
if (isAtEdge() || isTouching(Platform2.class) || getX() >= stopPointRight) {
40+
movingRight = false;
41+
setImage("Ghost1-Run-Left.png");
42+
}
43+
} else {
44+
move(-speed);
45+
if (isAtEdge() || isTouching(Platform2.class) || getX() <= stopPointLeft) {
46+
movingRight = true;
47+
setImage("Ghost1-Run-Right.png");
48+
}
49+
}
50+
}
51+
52+
private void checkCollision() {
53+
skill1Charge skill1 = (skill1Charge) getOneIntersectingObject(skill1Charge.class);
54+
skill2Charge skill2 = (skill2Charge) getOneIntersectingObject(skill2Charge.class);
55+
if (skill1 != null) {
56+
Greenfoot.playSound("Magic-Explode.mp3");
57+
getWorld().removeObject(this);
58+
}
59+
if (skill2 != null) {
60+
Greenfoot.playSound("Magic-Explode.mp3");
61+
getWorld().removeObject(this);
62+
}
63+
}
64+
}

Ghost1Skill.class

320 Bytes
Binary file not shown.

Ghost1Skill.ctxt

+5
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
#BlueJ class context
2+
comment0.target=Ghost1Skill
3+
comment1.params=
4+
comment1.target=void\ act()
5+
numComments=2

Ghost1Skill.java

+9
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
import greenfoot.*;
2+
3+
public class Ghost1Skill extends Actor
4+
{
5+
public void act()
6+
{
7+
8+
}
9+
}

Ghost2.class

1.62 KB
Binary file not shown.

Ghost2.ctxt

+11
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
#BlueJ class context
2+
comment0.target=Ghost2
3+
comment1.params=speed\ stopPointLeft\ stopPointRight
4+
comment1.target=Ghost2(int,\ int,\ int)
5+
comment2.params=
6+
comment2.target=void\ act()
7+
comment3.params=
8+
comment3.target=void\ moveHorizontally()
9+
comment4.params=
10+
comment4.target=void\ checkCollision()
11+
numComments=5

Ghost2.java

+64
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,64 @@
1+
import greenfoot.*;
2+
3+
public class Ghost2 extends Actor
4+
{
5+
private int speed;
6+
private boolean movingRight;
7+
private int stopPointLeft;
8+
private int stopPointRight;
9+
10+
public Ghost2(int speed, int stopPointLeft, int stopPointRight) {
11+
this.speed = speed;
12+
this.movingRight = true; // default ke kanan
13+
this.stopPointLeft = stopPointLeft;
14+
this.stopPointRight = stopPointRight;
15+
}
16+
17+
public void act()
18+
{
19+
if (getWorld() == null) {
20+
return; // Jika objek telah dihapus dari dunia, hentikan eksekusi
21+
}
22+
checkCollision();
23+
if (getWorld() == null) {
24+
return; // Jika objek telah dihapus dari dunia, hentikan eksekusi
25+
}
26+
moveHorizontally();
27+
}
28+
29+
public void moveHorizontally() {
30+
if (getWorld() == null) {
31+
return; // Jika objek telah dihapus dari dunia, hentikan eksekusi
32+
}
33+
checkCollision();
34+
if (getWorld() == null) {
35+
return; // Jika objek telah dihapus dari dunia, hentikan eksekusi
36+
}
37+
if (movingRight) {
38+
move(speed);
39+
if (isAtEdge() || isTouching(Platform2.class) || getX() >= stopPointRight) {
40+
movingRight = false;
41+
setImage("Ghost2-Walk-Left.png");
42+
}
43+
} else {
44+
move(-speed);
45+
if (isAtEdge() || isTouching(Platform2.class) || getX() <= stopPointLeft) {
46+
movingRight = true;
47+
setImage("Ghost2-Walk-Right.png");
48+
}
49+
}
50+
}
51+
52+
private void checkCollision() {
53+
skill1Charge skill1 = (skill1Charge) getOneIntersectingObject(skill1Charge.class);
54+
skill2Charge skill2 = (skill2Charge) getOneIntersectingObject(skill2Charge.class);
55+
if (skill1 != null) {
56+
Greenfoot.playSound("Magic-Explode.mp3");
57+
getWorld().removeObject(this);
58+
}
59+
if (skill2 != null) {
60+
Greenfoot.playSound("Magic-Explode.mp3");
61+
getWorld().removeObject(this);
62+
}
63+
}
64+
}

Level1.class

2.64 KB
Binary file not shown.

Level1.ctxt

+7
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
#BlueJ class context
2+
comment0.target=Level1
3+
comment1.params=
4+
comment1.target=Level1()
5+
comment2.params=
6+
comment2.target=void\ prepare()
7+
numComments=3

Level1.java

+103
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,103 @@
1+
import greenfoot.*;
2+
3+
public class Level1 extends World
4+
{
5+
public Level1()
6+
{
7+
super(900, 600, 1);
8+
prepare();
9+
}
10+
11+
private void prepare()
12+
{
13+
scoreBoard score = new scoreBoard();
14+
addObject(score, 90, 30);
15+
16+
Platform1 platform1 = new Platform1();
17+
addObject(platform1, 200, 589);
18+
19+
Platform2 platform2 = new Platform2();
20+
addObject(platform2, 700, 565);
21+
22+
int[][] platform3Positions = {
23+
{655, 400},
24+
{300, 450},
25+
{200, 270},
26+
{75, 130},
27+
{800, 110}
28+
};
29+
for (int[] plat : platform3Positions) {
30+
Platform3 pl3 = new Platform3();
31+
addObject(pl3, plat[0], plat[1]);
32+
}
33+
34+
35+
int[][] platform4Positions = {
36+
{865, 459},
37+
{800, 300},
38+
{665, 265},
39+
{470, 350},
40+
{125, 400},
41+
{34, 350},
42+
{275, 175},
43+
{380, 125},
44+
{500, 110},
45+
{620, 110},
46+
};
47+
for (int[] plat : platform4Positions) {
48+
Platform4 pl4 = new Platform4();
49+
addObject(pl4, plat[0], plat[1]);
50+
}
51+
52+
int[][] platform5Positions = {
53+
{596, 200}
54+
};
55+
for (int[] plat : platform5Positions) {
56+
Platform5 pl5 = new Platform5();
57+
addObject(pl5, plat[0], plat[1]);
58+
}
59+
60+
Wizard wizard = new Wizard();
61+
addObject(wizard, 10, 545);
62+
63+
Ghost1 brownGhost1 = new Ghost1(3, 500, 800);
64+
addObject(brownGhost1, 700, 480);
65+
66+
Ghost2 redGhost1 = new Ghost2(2, 20, 150);
67+
addObject(redGhost1, 75, 82);
68+
69+
Ghost2 redGhost2 = new Ghost2(1, 100, 260);
70+
addObject(redGhost2, 200, 222);
71+
72+
int[][] item1Positions = {
73+
{250, 565},
74+
{870, 91},
75+
{885, 519}
76+
};
77+
for (int[] pos : item1Positions) {
78+
item1 item = new item1();
79+
addObject(item, pos[0], pos[1]);
80+
}
81+
82+
int[][] item2Positions = {
83+
{300, 432},
84+
{15, 112},
85+
{570, 382},
86+
{500, 92},
87+
};
88+
for (int[] pos : item2Positions) {
89+
item2 item = new item2();
90+
addObject(item, pos[0], pos[1]);
91+
}
92+
93+
int[][] item3Positions = {
94+
{20, 329},
95+
{596, 180},
96+
{800, 280},
97+
};
98+
for (int[] pos : item3Positions) {
99+
item3 item = new item3();
100+
addObject(item, pos[0], pos[1]);
101+
}
102+
}
103+
}

Level2.class

2.66 KB
Binary file not shown.

Level2.ctxt

+11
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
#BlueJ class context
2+
comment0.target=Level2
3+
comment1.params=
4+
comment1.target=Level2()
5+
comment2.params=
6+
comment2.target=void\ platform()
7+
comment3.params=
8+
comment3.target=void\ callActor()
9+
comment4.params=
10+
comment4.target=void\ prepare()
11+
numComments=5

Level2.java

+104
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,104 @@
1+
import greenfoot.*;
2+
3+
public class Level2 extends World
4+
{
5+
public Level2()
6+
{
7+
super(900, 600, 1);
8+
prepare();
9+
platform();
10+
callActor();
11+
}
12+
13+
private void platform() {
14+
PlatformL2_1 platform1 = new PlatformL2_1();
15+
addObject(platform1, 152, 555);
16+
17+
PlatformL2_2 platform2 = new PlatformL2_2();
18+
addObject(platform2, 576, 595);
19+
20+
PlatformL2_4 platform3 = new PlatformL2_4();
21+
addObject(platform3, 870, 595);
22+
23+
int[][] platform4Positions = {
24+
{750, 500},
25+
{600, 450},
26+
{450, 370},
27+
{285, 330},
28+
{190, 330},
29+
{100, 330},
30+
{40, 330},
31+
{230, 230},
32+
{390, 170},
33+
{480, 170}
34+
};
35+
36+
for (int[] plat : platform4Positions) {
37+
PlatformL2_5 pl4 = new PlatformL2_5();
38+
addObject(pl4, plat[0], plat[1]);
39+
}
40+
41+
int[][] platform6Positions = {
42+
{800, 120}
43+
};
44+
for (int[] plat : platform6Positions) {
45+
PlatformL2_3 pl5 = new PlatformL2_3();
46+
addObject(pl5, plat[0], plat[1]);
47+
}
48+
49+
}
50+
51+
private void callActor() {
52+
Wizard wizard = new Wizard();
53+
addObject(wizard, 10, 475);
54+
55+
Ghost1 brownGhost1 = new Ghost1(3, 340, 600);
56+
addObject(brownGhost1, 700, 535);
57+
58+
Ghost1 brownGhost2 = new Ghost1(3, 615, 800);
59+
addObject(brownGhost2, 700, 55);
60+
61+
Ghost2 redGhost1 = new Ghost2(2, 20, 150);
62+
addObject(redGhost1, 75, 280);
63+
64+
Ghost2 redGhost2 = new Ghost2(1, 350, 490);
65+
addObject(redGhost2, 350, 122);
66+
67+
int[][] item1Positions = {
68+
{200, 497},
69+
{200, 497},
70+
{870, 85},
71+
};
72+
for (int[] pos : item1Positions) {
73+
item1 item = new item1();
74+
addObject(item, pos[0], pos[1]);
75+
}
76+
77+
int[][] item2Positions = {
78+
{800, 575},
79+
{15, 311},
80+
{470, 350},
81+
{470, 350},
82+
};
83+
for (int[] pos : item2Positions) {
84+
item2 item = new item2();
85+
addObject(item, pos[0], pos[1]);
86+
}
87+
88+
int[][] item3Positions = {
89+
{200, 210},
90+
{400, 150},
91+
{400, 150},
92+
};
93+
for (int[] pos : item3Positions) {
94+
item3 item = new item3();
95+
addObject(item, pos[0], pos[1]);
96+
}
97+
}
98+
99+
private void prepare()
100+
{
101+
scoreBoard score = new scoreBoard();
102+
addObject(score, 90, 30);
103+
}
104+
}

MenuAbout.class

482 Bytes
Binary file not shown.

0 commit comments

Comments
 (0)