Skip to content

Commit

Permalink
Merge pull request #24 from m4mbo/the-end
Browse files Browse the repository at this point in the history
The end
  • Loading branch information
m4mbo authored Feb 22, 2024
2 parents 5af504b + c2802ca commit afff971
Show file tree
Hide file tree
Showing 14 changed files with 39 additions and 25 deletions.
Binary file removed assets/Art/LevelsScreen.png
Binary file not shown.
Binary file added assets/Art/LevelsScreen1.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added assets/Art/LevelsScreen2.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added assets/Art/LevelsScreen3.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added assets/Art/LevelsScreen4.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added assets/Art/LevelsScreen5.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified assets/Buttons/ClickedControlsButton.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified assets/Buttons/UnclickedControlsButton.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
6 changes: 5 additions & 1 deletion core/src/com/mygdx/Game/MindWeaver.java
Original file line number Diff line number Diff line change
Expand Up @@ -142,7 +142,11 @@ public void loadSprites() {
//Art
resourceManager.loadTexture("Art/Mind.png", "mind");
resourceManager.loadTexture("Art/Weaver.png", "weaver");
resourceManager.loadTexture("Art/LevelsScreen.png", "LevelsScreen");
resourceManager.loadTexture("Art/LevelsScreen1.png", "LevelsScreen1");
resourceManager.loadTexture("Art/LevelsScreen2.png", "LevelsScreen2");
resourceManager.loadTexture("Art/LevelsScreen3.png", "LevelsScreen3");
resourceManager.loadTexture("Art/LevelsScreen4.png", "LevelsScreen4");
resourceManager.loadTexture("Art/LevelsScreen5.png", "LevelsScreen5");
resourceManager.loadTexture("Art/levels_background.png", "levels_bg");
resourceManager.loadTexture("Art/start_background.png", "start_bg");
resourceManager.loadTexture("Art/translucent_background.png", "translucent_bg");
Expand Down
2 changes: 1 addition & 1 deletion core/src/com/mygdx/Helpers/Constants.java
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ public enum ASTATE {
}

public enum SCREEN_OP {
START, RESUME, LEVELS, LEVEL_1, LEVEL_2, LEVEL_3, LEVEL_4, LEVEL_5, MENU, LEVEL_COMPLETE, EXIT, RESTART, CONTROLS
START, RESUME, LEVELS, LEVEL_1, LEVEL_2, LEVEL_3, LEVEL_4, LEVEL_5, MENU, EXIT, RESTART, CONTROLS

}

Expand Down
2 changes: 1 addition & 1 deletion core/src/com/mygdx/Listeners/MyContactListener.java
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ public void beginContact(Contact contact) {
}
else if (fa.getUserData().equals("end") || fb.getUserData().equals("end")) {
resourceManager.getSound("level_complete").play(1);
screenManager.setLevelProgression(level);
screenManager.setLevelProgression(level+1);
screenManager.pushScreen(SCREEN_OP.LEVELS, "sliding_left");
}
}
Expand Down
36 changes: 29 additions & 7 deletions core/src/com/mygdx/Screens/LevelsScreen.java
Original file line number Diff line number Diff line change
Expand Up @@ -22,12 +22,15 @@ public class LevelsScreen extends ManagedScreen {
private final ShapeRenderer shapeRenderer;
private Array<Polygon> levels;
private boolean wasClicked;
private Texture levelsTexture;
private final int currLevel;

public LevelsScreen(MyResourceManager resourceManager, ScreenManager screenManager, int levelProgression) {

this.screenManager = screenManager;
this.stage = new Stage(new ScreenViewport());
Gdx.input.setInputProcessor(null);
currLevel = levelProgression;

shapeRenderer = new ShapeRenderer();

Expand All @@ -44,7 +47,26 @@ public void initLevelsScreen(MyResourceManager resourceManager) {
levelsBGImage.setSize(levelsBGImage.getWidth() * 7.5f, levelsBGImage.getHeight() * 7.5f);
stage.addActor(levelsBGImage);

Texture levelsTexture = resourceManager.getTexture("LevelsScreen");
switch (currLevel) {
case 1:
levelsTexture = resourceManager.getTexture("LevelsScreen1");
break;
case 2:
levelsTexture = resourceManager.getTexture("LevelsScreen2");
break;
case 3:
levelsTexture = resourceManager.getTexture("LevelsScreen3");
break;
case 4:
levelsTexture = resourceManager.getTexture("LevelsScreen4");
break;
case 5:
levelsTexture = resourceManager.getTexture("LevelsScreen5");
break;
default:
break;
}

Image levelsImage = new Image(levelsTexture);
levelsImage.setPosition((float) (Gdx.graphics.getWidth() - levelsTexture.getWidth()) / 2, (float) (Gdx.graphics.getHeight() - levelsTexture.getHeight()) / 2);
levelsImage.setSize(levelsTexture.getWidth(), levelsTexture.getHeight());
Expand All @@ -66,7 +88,7 @@ public void initLevelsScreen(MyResourceManager resourceManager) {
levelVertices = new float[]{width/1.575f, height/2f, width/1.475f, height/1.825f, width/1.475f, height/1.575f, width/1.575f, height/1.475f, width/1.69f, height/1.575f, width/1.69f, height/1.825f};
levels.add(new Polygon(levelVertices));

levelVertices = new float[]{width/1.292f, height/3.3f, width/1.226f, height/2.9f, width/1.226f, height/2.3f, width/1.292f, height/2.1f, width/1.37f, height/2.3f, width/1.37f, height/2.9f};
levelVertices = new float[]{width/1.292f, height/3.3f, width/1.226f, height/2.9f, width/1.226f, height/2.3f, width/1.292f, height/2.1f, width/1.373f, height/2.3f, width/1.373f, height/2.9f};
levels.add(new Polygon(levelVertices));
}

Expand Down Expand Up @@ -99,23 +121,23 @@ public void handleInput() {
float touchX = touchPoint.x;
float touchY = touchPoint.y;

if (Intersector.isPointInPolygon(levels.get(0).getTransformedVertices(), 0, levels.get(0).getVertices().length, touchX, touchY)) {
if ((currLevel>=1) && (Intersector.isPointInPolygon(levels.get(0).getTransformedVertices(), 0, levels.get(0).getVertices().length, touchX, touchY))) {
wasClicked = true;
screenManager.pushScreen(Constants.SCREEN_OP.LEVEL_1, "slide_up");
}
if (Intersector.isPointInPolygon(levels.get(1).getTransformedVertices(), 0, levels.get(1).getVertices().length, touchX, touchY)) {
if ((currLevel>=2) && (Intersector.isPointInPolygon(levels.get(1).getTransformedVertices(), 0, levels.get(1).getVertices().length, touchX, touchY))) {
wasClicked = true;
screenManager.pushScreen(Constants.SCREEN_OP.LEVEL_2, "slide_up");
}
if (Intersector.isPointInPolygon(levels.get(2).getTransformedVertices(), 0, levels.get(2).getVertices().length, touchX, touchY)) {
if ((currLevel>=3) && (Intersector.isPointInPolygon(levels.get(2).getTransformedVertices(), 0, levels.get(2).getVertices().length, touchX, touchY))) {
wasClicked = true;
screenManager.pushScreen(Constants.SCREEN_OP.LEVEL_3, "slide_up");
}
if (Intersector.isPointInPolygon(levels.get(3).getTransformedVertices(), 0, levels.get(3).getVertices().length, touchX, touchY)) {
if ((currLevel>=4) && (Intersector.isPointInPolygon(levels.get(3).getTransformedVertices(), 0, levels.get(3).getVertices().length, touchX, touchY))) {
wasClicked = true;
screenManager.pushScreen(Constants.SCREEN_OP.LEVEL_4, "slide_up");
}
if (Intersector.isPointInPolygon(levels.get(4).getTransformedVertices(), 0, levels.get(4).getVertices().length, touchX, touchY)) {
if ((currLevel>=5) && (Intersector.isPointInPolygon(levels.get(4).getTransformedVertices(), 0, levels.get(4).getVertices().length, touchX, touchY))) {
wasClicked = true;
screenManager.pushScreen(Constants.SCREEN_OP.LEVEL_5, "slide_up");
}
Expand Down
8 changes: 3 additions & 5 deletions core/src/com/mygdx/Screens/ScreenManager.java
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,7 @@ public void pushScreen(Constants.SCREEN_OP screenType, String flag) {
currScreen = new GameScreen(game, level, resourceManager, this, musicManager);
break;
case LEVELS:
musicManager.setVolume(1);
currScreen = new LevelsScreen(resourceManager, this, levelProgression);
break;
case LEVEL_1:
Expand All @@ -100,13 +101,10 @@ public void pushScreen(Constants.SCREEN_OP screenType, String flag) {
currScreen = new GameScreen(game, 5, resourceManager, this, musicManager);
break;
case MENU:
musicManager.setVolume(0.2f);;
musicManager.setVolume(0.2f);
assert currScreen != null;
currScreen = new MenuScreen(resourceManager, this, currScreen.screenToTexture(fb));
break;
case LEVEL_COMPLETE:
currScreen = new LevelCompleteScreen(resourceManager, this);
break;
case EXIT:
resourceManager.disposeAll();
Gdx.app.exit();
Expand Down Expand Up @@ -150,7 +148,7 @@ public void render(float delta) {
}

public void setLevelProgression(int progression) {
if (levelProgression < progression) {
if (progression > levelProgression) {
levelProgression = progression;
}
}
Expand Down
10 changes: 0 additions & 10 deletions core/src/com/mygdx/Tools/MyResourceManager.java
Original file line number Diff line number Diff line change
Expand Up @@ -25,11 +25,6 @@ public Texture getTexture(String key) {
return textures.get(key);
}

public void disposeTexture(String key) {
Texture texture = textures.get(key);
if (texture != null) texture.dispose();
}

public void loadSound(String path, String key) {
Sound sound = Gdx.audio.newSound(Gdx.files.internal(path));
sounds.put(key, sound);
Expand All @@ -39,11 +34,6 @@ public Sound getSound(String key) {
return sounds.get(key);
}

public void disposeSound(String key) {
Sound sound = sounds.get(key);
if (sound != null) sound.dispose();
}

public void disposeAll() {
for (Sound sound : sounds.values()) {
sound.dispose();
Expand Down

0 comments on commit afff971

Please sign in to comment.