diff --git a/core/assets/Leaderboard.csv b/core/assets/Leaderboard.csv new file mode 100644 index 0000000..95d65ce --- /dev/null +++ b/core/assets/Leaderboard.csv @@ -0,0 +1,11 @@ +Level 2,1200.0, +Level 3,1700.0, +Level 4,1400.0, +Level 1,1100, +Level 2,1200, +Level 3,1700, +Level 4,1400, +Level 5,1300, +Level 6,1800, +Level 7,1300, +Level 8,1200, diff --git a/core/assets/levels/level1.tmx b/core/assets/levels/level1.tmx index d673cf4..51b3f5b 100644 --- a/core/assets/levels/level1.tmx +++ b/core/assets/levels/level1.tmx @@ -23,7 +23,7 @@ - eJxjYBgFwx2wIGEmAniwAWS3kwKYkfBAA1LdTg4gNx5ZcGBscsQARjyYkDpK3YtNLSmAVLcQq45SgMvPgwEDALPDAS4= + eJxjYBgFwx2wIGEmAniwAWS3kwKYkfBAA1LdTg4gNx5ZcGBs8sQARjyYkDpquBddLSmAVLcQq45SgMvPgwEDAKszASo= diff --git a/core/assets/spritesheets/uiskin.json b/core/assets/spritesheets/uiskin.json index 520abbb..b485296 100644 --- a/core/assets/spritesheets/uiskin.json +++ b/core/assets/spritesheets/uiskin.json @@ -7,6 +7,7 @@ com.badlogic.gdx.graphics.Color: { }, com.badlogic.gdx.scenes.scene2d.ui.TextButton$TextButtonStyle: { default: { down: null, up: null, font: default-font, fontColor: white, overFontColor: red } + intro: { down: null, up: null, font: default-font, fontColor: green, overFontColor: red } }, com.badlogic.gdx.scenes.scene2d.ui.Label$LabelStyle: { default: { font: default-font, fontColor: white } diff --git a/core/assets/textures/intros/level10Intro.png b/core/assets/textures/intros/level10Intro.png index 4964153..e22d075 100644 Binary files a/core/assets/textures/intros/level10Intro.png and b/core/assets/textures/intros/level10Intro.png differ diff --git a/core/assets/textures/intros/level3Intro.png b/core/assets/textures/intros/level3Intro.png index ae49869..62e98bb 100644 Binary files a/core/assets/textures/intros/level3Intro.png and b/core/assets/textures/intros/level3Intro.png differ diff --git a/core/assets/textures/intros/level4Intro.png b/core/assets/textures/intros/level4Intro.png index 2da1916..73a18d4 100644 Binary files a/core/assets/textures/intros/level4Intro.png and b/core/assets/textures/intros/level4Intro.png differ diff --git a/core/assets/textures/intros/level5Intro.png b/core/assets/textures/intros/level5Intro.png index 95d6997..656585b 100644 Binary files a/core/assets/textures/intros/level5Intro.png and b/core/assets/textures/intros/level5Intro.png differ diff --git a/core/assets/textures/intros/level6Intro.png b/core/assets/textures/intros/level6Intro.png index 1875740..8af67de 100644 Binary files a/core/assets/textures/intros/level6Intro.png and b/core/assets/textures/intros/level6Intro.png differ diff --git a/core/assets/textures/intros/level7Intro.png b/core/assets/textures/intros/level7Intro.png index ba9fed7..78d7f4b 100644 Binary files a/core/assets/textures/intros/level7Intro.png and b/core/assets/textures/intros/level7Intro.png differ diff --git a/core/assets/textures/intros/level9Intro.png b/core/assets/textures/intros/level9Intro.png index be899fb..1503181 100644 Binary files a/core/assets/textures/intros/level9Intro.png and b/core/assets/textures/intros/level9Intro.png differ diff --git a/core/src/com/game/Actor/Enemy.java b/core/src/com/game/Actor/Enemy.java index 5ecfb9f..3fb5fab 100644 --- a/core/src/com/game/Actor/Enemy.java +++ b/core/src/com/game/Actor/Enemy.java @@ -89,5 +89,9 @@ public class Enemy extends Base { public void setAlive(boolean isAlive) { this.isAlive = isAlive; } + public boolean isAlive(){ + return isAlive; + } + public Array getFixtures() { return body.getFixtureList(); } } diff --git a/core/src/com/game/Screens/Leaderboard.java b/core/src/com/game/Screens/Leaderboard.java index 31a55d0..24fb1fa 100644 --- a/core/src/com/game/Screens/Leaderboard.java +++ b/core/src/com/game/Screens/Leaderboard.java @@ -11,6 +11,12 @@ import com.badlogic.gdx.scenes.scene2d.utils.ClickListener; import com.game.App; import com.game.managers.ScreenManager; +import java.io.File; +import java.io.FileNotFoundException; +import java.lang.reflect.Array; +import java.util.ArrayList; +import java.util.Scanner; + /** * Created by Ash on 11/02/2016. */ @@ -23,6 +29,9 @@ public class Leaderboard extends AbstractScreen { private TextButton butBack; + //Score + private ArrayList leaderboardValues = new ArrayList<>(); + public Leaderboard(App app) { super(app); @@ -33,10 +42,22 @@ public class Leaderboard extends AbstractScreen { @Override public void show() { super.show(); - + leaderboardValues = new ArrayList<>(); skin.add("default-font", app.assets.get("badaboom45.ttf", BitmapFont.class)); skin.load(Gdx.files.internal("spritesheets/uiskin.json")); + try { + Scanner scanner = new Scanner(new File("Leaderboard.csv")); + scanner.useDelimiter(","); + while(scanner.hasNext()){ + leaderboardValues.add(scanner.next()); + } + + System.out.println(leaderboardValues); + + } catch (FileNotFoundException e) { + e.printStackTrace(); + } initButtons(); } @@ -51,6 +72,14 @@ public class Leaderboard extends AbstractScreen { app.sb.begin(); app.sb.draw(app.assets.get("textures/backgrounds/leaderboardBackground.jpg", Texture.class), 0, 0); + + int count = 0; + for(int col = 0; col < leaderboardValues.size()/2; col++){ + for(int row = 0; row < 2; row ++){ + app.assets.get("badaboom45.ttf", BitmapFont.class).draw(app.sb, leaderboardValues.get(count++), 100 + (400 * row), 500 + (-50 * col)); + } + } + app.sb.end(); stage.draw(); diff --git a/core/src/com/game/Screens/LevelSelect.java b/core/src/com/game/Screens/LevelSelect.java index d3768a4..7a6b12e 100644 --- a/core/src/com/game/Screens/LevelSelect.java +++ b/core/src/com/game/Screens/LevelSelect.java @@ -14,6 +14,8 @@ import com.game.misc.levelSelectClickListener; import java.util.ArrayList; +import static com.badlogic.gdx.scenes.scene2d.actions.Actions.*; + /** * Created by Ash on 11/02/2016. */ @@ -107,6 +109,7 @@ public class LevelSelect extends AbstractScreen { @Override public void clicked (com.badlogic.gdx.scenes.scene2d.InputEvent event, float x, float y) { //app.sm.setScreen(ScreenManager.Screen.ENDLESSMODE); TODO, finish this ;) + butEndless.addAction(forever(moveBy(20, 3))); } }); diff --git a/core/src/com/game/Screens/Loading.java b/core/src/com/game/Screens/Loading.java index f374b10..568312e 100644 --- a/core/src/com/game/Screens/Loading.java +++ b/core/src/com/game/Screens/Loading.java @@ -16,6 +16,9 @@ import com.badlogic.gdx.math.Rectangle; import com.game.App; import com.game.managers.ScreenManager; +import java.io.FileWriter; +import java.io.IOException; + /** * Created by Ash on 11/02/2016. */ @@ -131,6 +134,15 @@ public class Loading extends AbstractScreen { // Sound app.assets.load("sounds/jumping.mp3", Sound.class); app.assets.load("sounds/colourchange.mp3", Sound.class); + try { + FileWriter leaderboard = new FileWriter("Leaderboard.csv", true); + + leaderboard.flush(); + leaderboard.close(); + } catch (IOException e) { + e.printStackTrace(); + } + } private void loadFont(String fontFileName, int size, Color borderColour) diff --git a/core/src/com/game/Screens/Play.java b/core/src/com/game/Screens/Play.java index 5132938..f94321f 100644 --- a/core/src/com/game/Screens/Play.java +++ b/core/src/com/game/Screens/Play.java @@ -35,6 +35,9 @@ import com.game.misc.utils.myWindow; import com.game.misc.utils.Box2dUtils; import com.game.misc.utils.CameraUtils; +import java.io.File; +import java.io.FileWriter; +import java.io.IOException; import java.util.ArrayList; import java.util.HashMap; @@ -87,6 +90,10 @@ public class Play extends AbstractScreen { private float progressX; private Image uiRedImage, uiGreenImage, uiBlueImage; + //Score + private int score = 0; + private float scoreYPos = 100; + public Play(App app, int levelNumber) { super(app); this.levelNumber = levelNumber; @@ -186,6 +193,7 @@ public class Play extends AbstractScreen { uiGreenImage.draw(app.sb, 1f); uiBlueImage.draw(app.sb, 1f); app.sb.draw(progressTexture, progressX, progressRect.y, 30, 30); + app.assets.get("badaboom60.ttf", BitmapFont.class).draw(app.sb, "Score: " + score, 500, scoreYPos); app.sb.end(); } else @@ -297,8 +305,8 @@ public class Play extends AbstractScreen { TextureMapObject tmo = (TextureMapObject)enemyObjs.get(i); MapProperties mp = tmo.getProperties(); - if(mp.get("Colour").equals("RED")) { enemies.add(new Enemy(world, new Vector2(tmo.getX(), tmo.getY()), new Vector2(64, 64), Base.Colours.RED, BIT_ALL, BIT_PLAYER)); } - else if(mp.get("Colour").equals("GREEN")) { enemies.add(new Enemy(world, new Vector2(tmo.getX(), tmo.getY()), new Vector2(64, 64), Base.Colours.GREEN, BIT_ALL, BIT_PLAYER)); } + if(mp.get("Colour").equals("RED")) { enemies.add(new Enemy(world, new Vector2(tmo.getX() + 32, tmo.getY() + 32), new Vector2(64, 64), Base.Colours.RED, BIT_ALL, BIT_PLAYER)); } + else if(mp.get("Colour").equals("GREEN")) { enemies.add(new Enemy(world, new Vector2(tmo.getX() + 32, tmo.getY() + 32), new Vector2(64, 64), Base.Colours.GREEN, BIT_ALL, BIT_PLAYER)); } else if(mp.get("Colour").equals("BLUE")) { enemies.add(new Enemy(world, new Vector2(tmo.getX() + 32, tmo.getY() + 32), new Vector2(64, 64), Base.Colours.GREEN, BIT_ALL, BIT_PLAYER)); } } @@ -356,7 +364,7 @@ public class Play extends AbstractScreen { // Init INTRO buttons myWindow tempWindow = windows.get(GameState.INTRO); - tempWindow.addButton(new myButton("Continue", new Vector2((tempWindow.getX() * 2) - 5, tempWindow.getHeight() - 50), skin, "default", new ClickListener() { + tempWindow.addButton(new myButton("Continue", new Vector2((tempWindow.getX() * 2) - 5, tempWindow.getHeight() - 50), skin, "intro", new ClickListener() { @Override public void clicked(com.badlogic.gdx.scenes.scene2d.InputEvent event, float x, float y) { setCurGameState(GameState.PLAYING); @@ -438,6 +446,21 @@ public class Play extends AbstractScreen { curGameState = newGameState; System.out.println("Showing: " + curGameState.name() + " window"); windows.get(curGameState).setVisible(true); // show new window + if(curGameState == GameState.SUCCESS){ + scoreYPos = 650; + + try { + FileWriter leaderboard = new FileWriter("Leaderboard.csv", true); + + leaderboard.append("Level " + levelNumber + "," + score + ",\n"); + + leaderboard.flush(); + leaderboard.close(); + + } catch (IOException e) { + e.printStackTrace(); + } + } } // Contact Listener @@ -466,8 +489,12 @@ public class Play extends AbstractScreen { { if(e.getFixtures().contains(fa, false) || e.getFixtures().contains(fb, false)) { - e.setAlive(false); - e.setCurColour(e.getCurColour()); + if(e.isAlive()) { + e.setAlive(false); + e.setCurColour(e.getCurColour()); + score += 100; + System.out.println(score); + } } } } @@ -475,6 +502,7 @@ public class Play extends AbstractScreen { if(fa.getUserData().equals("PLAYER") && fb.getUserData().equals("PASSBOUNDARY") || fb.getUserData().equals("PLAYER") && fa.getUserData().equals("PASSBOUNDARY")) { + score += 1000; setCurGameState(GameState.SUCCESS); System.out.println("SUCCESS"); return; diff --git a/desktop/src/com/game/desktop/DesktopLauncher.java b/desktop/src/com/game/desktop/DesktopLauncher.java index 8dec18d..907959a 100644 --- a/desktop/src/com/game/desktop/DesktopLauncher.java +++ b/desktop/src/com/game/desktop/DesktopLauncher.java @@ -18,5 +18,6 @@ public class DesktopLauncher { config.addIcon("spritesheets/icon.jpg", Files.FileType.Internal); config.foregroundFPS = (int)Vars.FRAMERATE; config.backgroundFPS = (int)Vars.FRAMERATE; + config.samples = 4; } }