Skip to content

Commit

Permalink
Add congratulation screen after passing all available levels
Browse files Browse the repository at this point in the history
  • Loading branch information
FoxtrotSierra6829 committed Jan 7, 2021
1 parent bc5b3ad commit 40242c2
Show file tree
Hide file tree
Showing 7 changed files with 41 additions and 8 deletions.
Binary file modified Pushy Island/House.class
Binary file not shown.
6 changes: 6 additions & 0 deletions Pushy Island/House.java
Original file line number Diff line number Diff line change
Expand Up @@ -82,8 +82,14 @@ public void nextlevel() throws Exception {

if (levelnr + 1 > maxlevel) {
bw.write(String.valueOf(maxlevel));
bw.close();
BufferedWriter mode = new BufferedWriter(
new FileWriter(System.getProperty("user.home") + "/Documents/Pushy/mode.pushy"));
mode.write("win");
mode.close();
} else {
bw.write(String.valueOf(levelnr + 1));
bw.close();
}
bw.close();
if (levelnr > highscorelevel) {
Expand Down
Binary file modified Pushy Island/MyWorld.class
Binary file not shown.
8 changes: 5 additions & 3 deletions Pushy Island/MyWorld.ctxt
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@ comment3.params=
comment3.target=void\ menu()
comment4.params=
comment4.target=void\ PushyIsland()
comment5.params=modechange
comment5.target=void\ changemode(java.lang.String)
numComments=6
comment5.params=
comment5.target=void\ win()
comment6.params=modechange
comment6.target=void\ changemode(java.lang.String)
numComments=7
27 changes: 26 additions & 1 deletion Pushy Island/MyWorld.java
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ public class MyWorld extends World {
String gotomode;
String menu = "Menu";
String pushyisland = "PushyIsland";
String win = "win";
String levelground = "";
String levelobjects = "";
String levelname = "";
Expand Down Expand Up @@ -127,7 +128,7 @@ public MyWorld() throws Exception {
}

///// PUSHY ISLAND
if (gamemode.equalsIgnoreCase(pushyisland)) {
else if (gamemode.equalsIgnoreCase(pushyisland)) {
// get maximum level
setBackground("pushy_island_loading.jpg");
int imax = 1;
Expand Down Expand Up @@ -287,6 +288,8 @@ public MyWorld() throws Exception {
Text Levelname = new Text(levelname, 30, "left", "white"); // new Text(Text, Fontsize, alignment relative to
// x, color)
addObject(Levelname, BlockSize / 4, BlockSize / 4); // Add Text(center x, center y)
} else if (gamemode.equalsIgnoreCase(win)) {
setBackground("pushy_island_win.jpg");
}

}
Expand All @@ -301,6 +304,17 @@ public void act() {
if (gamemode.equalsIgnoreCase(pushyisland)) {
PushyIsland();
}
// win
if (gamemode.equalsIgnoreCase(win)) {
win();
try {
BufferedWriter mode = new BufferedWriter(
new FileWriter(System.getProperty("user.home") + "/Documents/Pushy/mode.pushy"));
mode.write(menu);
mode.close();
} catch (Exception e) {
}
}
}

public void menu() {
Expand All @@ -321,6 +335,17 @@ public void PushyIsland() {
}
}

public void win() {
// enter changes to menu
if (Greenfoot.isKeyDown("enter")) {
changemode(menu);
}
// escape changes to menu
if (Greenfoot.isKeyDown("escape")) {
changemode(menu);
}
}

public static void changemode(String modechange) {
try {
// change mode file
Expand Down
Binary file added Pushy Island/images/pushy_island_win.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
8 changes: 4 additions & 4 deletions Pushy Island/project.greenfoot
Original file line number Diff line number Diff line change
Expand Up @@ -249,10 +249,10 @@ dependency8.type=UsesDependency
dependency9.from=MyWorld
dependency9.to=Stone
dependency9.type=UsesDependency
editor.fx.0.height=1056
editor.fx.0.width=1936
editor.fx.0.x=-8
editor.fx.0.y=-8
editor.fx.0.height=0
editor.fx.0.width=0
editor.fx.0.x=0
editor.fx.0.y=0
height=1056
package.numDependencies=77
package.numTargets=23
Expand Down

0 comments on commit 40242c2

Please sign in to comment.