Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -1,12 +1,11 @@
package io.exterminator3618.client.components;

import com.badlogic.gdx.graphics.Color;
import com.badlogic.gdx.math.Rectangle;
import com.badlogic.gdx.graphics.g2d.TextureRegion;
import com.badlogic.gdx.graphics.OrthographicCamera;
import com.badlogic.gdx.math.Rectangle;

import io.exterminator3618.client.Constants;
import io.exterminator3618.client.utils.Renderer;
import io.exterminator3618.client.utils.Assets;
import io.exterminator3618.client.utils.Renderer;

/**
* A simple text button with an optional 9-patch-style background frame.
Expand Down Expand Up @@ -112,4 +111,8 @@ public void draw(Renderer renderer) {
public boolean isClicked(float touchX, float touchY) {
return bounds.contains(touchX, touchY);
}

public void setText(String text) {
this.text = text;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,6 @@
import static io.exterminator3618.client.Constants.WINDOW_HEIGHT;
import static io.exterminator3618.client.Constants.WINDOW_WIDTH;
import io.exterminator3618.client.Exterminator3618;
import static io.exterminator3618.client.utils.Physics.checkPowerUpCollision;
import io.exterminator3618.client.components.Ball;
import io.exterminator3618.client.components.Brick;
import io.exterminator3618.client.components.ExtraLifePowerUp;
Expand All @@ -50,6 +49,12 @@
import io.exterminator3618.client.components.StrongBrick;
import io.exterminator3618.client.components.TextButton;
import io.exterminator3618.client.components.WidenPaddlePowerUp;
import io.exterminator3618.client.managers.SoundManager;
import io.exterminator3618.client.utils.Assets;
import io.exterminator3618.client.utils.GameSaveData;
import io.exterminator3618.client.utils.LevelLoader;
import static io.exterminator3618.client.utils.Physics.checkPowerUpCollision;
import io.exterminator3618.client.utils.Renderer;

/**
* Main LibGDX application for the Exterminator3618 client. It owns the renderer
Expand Down Expand Up @@ -431,7 +436,15 @@ public void render(float deltaTime) {
if (Gdx.input.justTouched()) {
touchPos.set(Gdx.input.getX(), Gdx.input.getY(), 0);
viewport.unproject(touchPos);

if (ball.isStuckToPaddle()) {
ball.launchFromPaddle();
}
for (Ball extraBall : extraBalls) {
if (extraBall.isStuckToPaddle()) {
extraBall.launchFromPaddle();
}
}

if (pauseButton.isClicked(touchPos.x, touchPos.y)) {
game.launchScreen(new PauseScreen(game, this));
}
Expand Down Expand Up @@ -476,7 +489,7 @@ private void gotoVictoryScreen() {
}

private void gotoWinLevelScreen(int level) {
game.launchScreen(new WinLevelScreen(game, level));
game.launchScreen(new WinLevelScreen(game, level, this));
}

private void gotoGameOverScreen() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,7 @@ public void render(float v) {
viewport.unproject(touchPos);

if (backButton.isClicked(touchPos.x, touchPos.y)) {
game.backToPreviousScreen();
SaveManager.saveGame(game, gameScreen);
game.replaceCurrentScreen(new MainMenuScreen(game));
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ public void render(float delta) {
renderer.begin(camera);
box.draw(renderer);
// Update button text to reflect current setting
enableMusicButton.text = String.format("Music: %s", (isMusicEnabled() ? "On" : "Off"));
enableMusicButton.setText(String.format("Music: %s", (isMusicEnabled() ? "On" : "Off")));
enableMusicButton.draw(renderer);
backButton.draw(renderer);
renderer.end();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,11 +14,12 @@
import io.exterminator3618.client.components.TextButton;
import io.exterminator3618.client.utils.Assets;
import io.exterminator3618.client.utils.Renderer;
import io.exterminator3618.client.utils.SaveManager;

public final class WinLevelScreen implements Screen {
private final Exterminator3618 game;
private final Renderer renderer;

private final GameScreen gameScreen;
private OrthographicCamera camera;
private Viewport viewport;
private Vector3 touchPos = new Vector3();
Expand All @@ -29,8 +30,9 @@ public final class WinLevelScreen implements Screen {
private Box box;


public WinLevelScreen(Exterminator3618 game, int level) {
public WinLevelScreen(Exterminator3618 game, int level, GameScreen gameScreen) {
this.game = game;
this.gameScreen = gameScreen;
this.renderer = game.getRenderer();
camera = new OrthographicCamera();
viewport = new FitViewport(Constants.WINDOW_WIDTH, Constants.WINDOW_HEIGHT, camera);
Expand Down Expand Up @@ -73,7 +75,8 @@ public void render(float delta) {
viewport.unproject(touchPos);

if (backButton.isClicked(touchPos.x, touchPos.y)) {
game.launchScreen(new MainMenuScreen(game));
SaveManager.saveGame(game, gameScreen);
game.replaceCurrentScreen(new MainMenuScreen(game));
}

if (playAgainButton.isClicked(touchPos.x, touchPos.y)) {
Expand All @@ -84,6 +87,7 @@ public void render(float delta) {
}
}
if (Gdx.input.isKeyJustPressed(Input.Keys.ENTER) || Gdx.input.isKeyJustPressed(Input.Keys.ESCAPE)) {
SaveManager.saveGame(game, gameScreen);
game.getSoundManager().stop(); // Stop any playing music
game.launchScreen(new MainMenuScreen(game));
}
Expand Down
Loading