Commit 4333456d authored by Turid Cecilie Dahl's avatar Turid Cecilie Dahl
Browse files

Merge branch '103-reduce-fruit-slicer-time-limit' into 'dev'

Resolve "Reduce fruit slicer time limit"

Closes #103

See merge request tobiasio/progark-gruppe-3!110
parents f0354b92 83b7c539
...@@ -4,6 +4,8 @@ import com.badlogic.gdx.Gdx; ...@@ -4,6 +4,8 @@ import com.badlogic.gdx.Gdx;
import com.badlogic.gdx.graphics.Texture; import com.badlogic.gdx.graphics.Texture;
import com.badlogic.gdx.graphics.g2d.SpriteBatch; import com.badlogic.gdx.graphics.g2d.SpriteBatch;
// This is the "Loading..." text that can be seen throughout the application
public class LoadingText extends Sprite { public class LoadingText extends Sprite {
private boolean isLoading = false; private boolean isLoading = false;
private boolean firstUpdateFinished = false; private boolean firstUpdateFinished = false;
......
...@@ -7,6 +7,8 @@ import com.badlogic.gdx.math.Vector3; ...@@ -7,6 +7,8 @@ import com.badlogic.gdx.math.Vector3;
import javax.xml.soap.Text; import javax.xml.soap.Text;
// This is the pause button that is accessible in all minigames
public class PauseButton extends Sprite { public class PauseButton extends Sprite {
private Texture blackButtonTexture; private Texture blackButtonTexture;
private Texture whiteButtonTexture; private Texture whiteButtonTexture;
......
...@@ -12,6 +12,8 @@ import com.gameware.game.sprites.Sprite; ...@@ -12,6 +12,8 @@ import com.gameware.game.sprites.Sprite;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Random; import java.util.Random;
// This is the bubble seen in the Bubble Wrap minigame
public class Bubble extends Sprite { public class Bubble extends Sprite {
private boolean textureChanged = false; private boolean textureChanged = false;
private ArrayList<Texture> poppedTextures; private ArrayList<Texture> poppedTextures;
......
...@@ -8,6 +8,8 @@ import com.badlogic.gdx.math.Vector3; ...@@ -8,6 +8,8 @@ import com.badlogic.gdx.math.Vector3;
import com.gameware.game.GameWare; import com.gameware.game.GameWare;
import com.gameware.game.sprites.Sprite; import com.gameware.game.sprites.Sprite;
// These are the buttons that needs to be pressed according to the matching color of the target in the Color Rush minigame
public class ColorRushButton extends Sprite { public class ColorRushButton extends Sprite {
private Texture mainTexture; private Texture mainTexture;
private Texture disabledTexture; private Texture disabledTexture;
......
...@@ -6,6 +6,8 @@ import com.badlogic.gdx.graphics.g2d.SpriteBatch; ...@@ -6,6 +6,8 @@ import com.badlogic.gdx.graphics.g2d.SpriteBatch;
import com.badlogic.gdx.math.Vector3; import com.badlogic.gdx.math.Vector3;
import com.gameware.game.sprites.Sprite; import com.gameware.game.sprites.Sprite;
// This is the block that you need to press the matching color to remove in the Color Rush minigame
public class ColorRushTarget extends Sprite { public class ColorRushTarget extends Sprite {
private int nextHeight; private int nextHeight;
private Vector3 velocity; private Vector3 velocity;
......
...@@ -7,6 +7,7 @@ import com.badlogic.gdx.graphics.g2d.TextureRegion; ...@@ -7,6 +7,7 @@ import com.badlogic.gdx.graphics.g2d.TextureRegion;
import com.badlogic.gdx.math.Vector3; import com.badlogic.gdx.math.Vector3;
import com.gameware.game.sprites.Sprite; import com.gameware.game.sprites.Sprite;
// This is the fruit that can be chopped in the Fruit Slicer minigame
public class Fruit extends Sprite { public class Fruit extends Sprite {
private Vector3 cutPosition1; private Vector3 cutPosition1;
...@@ -132,6 +133,7 @@ public class Fruit extends Sprite { ...@@ -132,6 +133,7 @@ public class Fruit extends Sprite {
@Override @Override
public void dispose() { public void dispose() {
// Nothing to dispose
} }
public boolean isDisposable() { public boolean isDisposable() {
......
...@@ -6,6 +6,8 @@ import com.badlogic.gdx.graphics.g2d.SpriteBatch; ...@@ -6,6 +6,8 @@ import com.badlogic.gdx.graphics.g2d.SpriteBatch;
import com.badlogic.gdx.math.Vector3; import com.badlogic.gdx.math.Vector3;
import com.gameware.game.sprites.Sprite; import com.gameware.game.sprites.Sprite;
// This is the circle trail that are left when slicing in the Fruit Slicer minigame
public class SlicingCircle extends Sprite { public class SlicingCircle extends Sprite {
private Texture slicingVFX; private Texture slicingVFX;
private int originalWidth; private int originalWidth;
......
...@@ -6,6 +6,8 @@ import com.badlogic.gdx.graphics.g2d.SpriteBatch; ...@@ -6,6 +6,8 @@ import com.badlogic.gdx.graphics.g2d.SpriteBatch;
import com.badlogic.gdx.math.Vector3; import com.badlogic.gdx.math.Vector3;
import com.gameware.game.sprites.Sprite; import com.gameware.game.sprites.Sprite;
// This is the confirmation box when trying to exit a minigame when in the pause state
public class ConfirmationBox extends Sprite { public class ConfirmationBox extends Sprite {
private Texture boxTexture; private Texture boxTexture;
......
...@@ -7,12 +7,14 @@ import com.badlogic.gdx.graphics.glutils.ShapeRenderer; ...@@ -7,12 +7,14 @@ import com.badlogic.gdx.graphics.glutils.ShapeRenderer;
import com.badlogic.gdx.math.Vector3; import com.badlogic.gdx.math.Vector3;
import com.gameware.game.sprites.Sprite; import com.gameware.game.sprites.Sprite;
public class PauseCircle extends Sprite { // These are the animated circles that can be seen in the background of the pause state
public class PauseBackgroundCircle extends Sprite {
private int radius; private int radius;
private Vector3 velocity; private Vector3 velocity;
private ShapeRenderer sr; private ShapeRenderer sr;
public PauseCircle(){ public PauseBackgroundCircle(){
this.position = new Vector3(); this.position = new Vector3();
this.velocity = new Vector3(); this.velocity = new Vector3();
......
...@@ -5,6 +5,8 @@ import com.badlogic.gdx.graphics.g2d.SpriteBatch; ...@@ -5,6 +5,8 @@ import com.badlogic.gdx.graphics.g2d.SpriteBatch;
import com.badlogic.gdx.math.Vector3; import com.badlogic.gdx.math.Vector3;
import com.gameware.game.sprites.Sprite; import com.gameware.game.sprites.Sprite;
// This is the button used for "Resume" and "Exit" in the pause state
public class PauseMenuButton extends Sprite { public class PauseMenuButton extends Sprite {
private Texture buttonTexture; private Texture buttonTexture;
......
...@@ -7,7 +7,7 @@ import com.badlogic.gdx.graphics.g2d.SpriteBatch; ...@@ -7,7 +7,7 @@ import com.badlogic.gdx.graphics.g2d.SpriteBatch;
import com.gameware.game.GameWare; import com.gameware.game.GameWare;
import com.gameware.game.sprites.pauseStateSprites.ConfirmationBox; import com.gameware.game.sprites.pauseStateSprites.ConfirmationBox;
import com.gameware.game.sprites.LoadingText; import com.gameware.game.sprites.LoadingText;
import com.gameware.game.sprites.pauseStateSprites.PauseCircle; import com.gameware.game.sprites.pauseStateSprites.PauseBackgroundCircle;
import com.gameware.game.sprites.pauseStateSprites.PauseMenuButton; import com.gameware.game.sprites.pauseStateSprites.PauseMenuButton;
import com.gameware.game.states.games.PlayStateUnion; import com.gameware.game.states.games.PlayStateUnion;
...@@ -42,7 +42,7 @@ public class PauseState extends State { ...@@ -42,7 +42,7 @@ public class PauseState extends State {
private boolean needsConfirmation; private boolean needsConfirmation;
// Widgets // Widgets
private List<PauseCircle> pauseCircles; private List<PauseBackgroundCircle> pauseBackgroundCircles;
private ConfirmationBox confirmationBox; private ConfirmationBox confirmationBox;
private PauseMenuButton resumeButton; private PauseMenuButton resumeButton;
private PauseMenuButton exitButton; private PauseMenuButton exitButton;
...@@ -63,7 +63,7 @@ public class PauseState extends State { ...@@ -63,7 +63,7 @@ public class PauseState extends State {
this.countdownDurationLeft = 3f; this.countdownDurationLeft = 3f;
this.countdownStarted = false; this.countdownStarted = false;
this.pauseCircles = new ArrayList<PauseCircle>(); this.pauseBackgroundCircles = new ArrayList<PauseBackgroundCircle>();
this.pausedGame = pausedGame; this.pausedGame = pausedGame;
this.originalFontColor = new Color(this.pausedGame.getFontColor()); this.originalFontColor = new Color(this.pausedGame.getFontColor());
...@@ -85,7 +85,7 @@ public class PauseState extends State { ...@@ -85,7 +85,7 @@ public class PauseState extends State {
for(int i = 0; i<25; i++){ for(int i = 0; i<25; i++){
this.pauseCircles.add(new PauseCircle()); this.pauseBackgroundCircles.add(new PauseBackgroundCircle());
} }
} }
...@@ -146,7 +146,7 @@ public class PauseState extends State { ...@@ -146,7 +146,7 @@ public class PauseState extends State {
// If the user has pressed the resume button the countdown has started // If the user has pressed the resume button the countdown has started
if(this.countdownStarted){ if(this.countdownStarted){
this.countdownDurationLeft -= dt; this.countdownDurationLeft -= dt;
this.countdownNumberTexture = this.countdownNumbers.get(Math.min(Math.max((int) (this.countdownDurationLeft),0), 3)); this.countdownNumberTexture = this.countdownNumbers.get(Math.min(Math.max((int) (this.countdownDurationLeft),0), 2));
// If the countdown has finished we resume the game // If the countdown has finished we resume the game
if(this.countdownDurationLeft <= 0){ if(this.countdownDurationLeft <= 0){
...@@ -157,7 +157,7 @@ public class PauseState extends State { ...@@ -157,7 +157,7 @@ public class PauseState extends State {
} }
} }
for(PauseCircle pc : this.pauseCircles){ for(PauseBackgroundCircle pc : this.pauseBackgroundCircles){
pc.update(dt); pc.update(dt);
} }
} }
...@@ -173,7 +173,7 @@ public class PauseState extends State { ...@@ -173,7 +173,7 @@ public class PauseState extends State {
// Animated circles // Animated circles
for(PauseCircle pc : pauseCircles){ for(PauseBackgroundCircle pc : pauseBackgroundCircles){
pc.draw(sb); pc.draw(sb);
} }
...@@ -213,7 +213,7 @@ public class PauseState extends State { ...@@ -213,7 +213,7 @@ public class PauseState extends State {
@Override @Override
public void dispose() { public void dispose() {
for(PauseCircle pc : pauseCircles){ for(PauseBackgroundCircle pc : pauseBackgroundCircles){
pc.dispose(); pc.dispose();
} }
......
...@@ -28,7 +28,7 @@ public class BubbleWrapState extends PlayStateUnion { ...@@ -28,7 +28,7 @@ public class BubbleWrapState extends PlayStateUnion {
public BubbleWrapState(GameStateManager gsm) { public BubbleWrapState(GameStateManager gsm) {
super(gsm); super(gsm);
super.setPauseButtonWhite(); super.setPauseButtonWhite();
super.setTotalGameTime(20f); super.setTotalTimeLimit(20f);
super.setFontColorWhite(); super.setFontColorWhite();
super.setThumbnail(new Texture(Gdx.files.internal("gameTextures/BubbleWrap/bubbleWrapPhotoEdit.png"))); super.setThumbnail(new Texture(Gdx.files.internal("gameTextures/BubbleWrap/bubbleWrapPhotoEdit.png")));
...@@ -62,7 +62,7 @@ public class BubbleWrapState extends PlayStateUnion { ...@@ -62,7 +62,7 @@ public class BubbleWrapState extends PlayStateUnion {
// Keeps score consistent // Keeps score consistent
// One point per bubble popped, plus three points for each second of remaining time. Time bonus is only given if the player pops all the bubbles. // One point per bubble popped, plus three points for each second of remaining time. Time bonus is only given if the player pops all the bubbles.
if(this.poppedBubbles == this.bubbles.size()){ if(this.poppedBubbles == this.bubbles.size()){
score = this.poppedBubbles + Math.max(Math.round((super.getTotalGameTime() - super.getCurrentDuration())*3), 0); score = this.poppedBubbles + Math.max(Math.round((super.getTotalTimeLimit() - super.getCurrentDuration())*3), 0);
} }
else{ else{
score = this.poppedBubbles; score = this.poppedBubbles;
......
...@@ -27,7 +27,7 @@ public class ColorRushState extends PlayStateUnion { ...@@ -27,7 +27,7 @@ public class ColorRushState extends PlayStateUnion {
public ColorRushState(GameStateManager gsm){ public ColorRushState(GameStateManager gsm){
super(gsm); super(gsm);
super.setThumbnail(new Texture(Gdx.files.internal("gameTextures/ColorRush/colorRushPhotoEdit.png"))); super.setThumbnail(new Texture(Gdx.files.internal("gameTextures/ColorRush/colorRushPhotoEdit.png")));
super.setTotalGameTime(30f); super.setTotalTimeLimit(30f);
// Creates the background // Creates the background
this.background = new Texture(Gdx.files.internal("gameTextures/ColorRush/ColorRushBackground.jpg")); this.background = new Texture(Gdx.files.internal("gameTextures/ColorRush/ColorRushBackground.jpg"));
......
...@@ -33,7 +33,7 @@ public class FruitSlicerState extends PlayStateUnion { ...@@ -33,7 +33,7 @@ public class FruitSlicerState extends PlayStateUnion {
public FruitSlicerState(GameStateManager gsm) { public FruitSlicerState(GameStateManager gsm) {
super(gsm); super(gsm);
super.setTotalGameTime(60f); super.setTotalTimeLimit(45f);
super.setThumbnail(new Texture(Gdx.files.internal("gameTextures/FruitSlicer/FruitSlicerPhotoEdit.png"))); super.setThumbnail(new Texture(Gdx.files.internal("gameTextures/FruitSlicer/FruitSlicerPhotoEdit.png")));
super.setFontColorWhite(); super.setFontColorWhite();
super.setPauseButtonWhite(); super.setPauseButtonWhite();
...@@ -108,7 +108,7 @@ public class FruitSlicerState extends PlayStateUnion { ...@@ -108,7 +108,7 @@ public class FruitSlicerState extends PlayStateUnion {
this.timeSinceLastEmit += dt; this.timeSinceLastEmit += dt;
// Increases the emiting frequency towards the endingEmitFrequency as the game gets closer to the end // Increases the emiting frequency towards the endingEmitFrequency as the game gets closer to the end
float currentFrequency = (float) (this.startingEmitFrequency - (this.startingEmitFrequency - this.endingEmitFrequency) * Math.min(super.getCurrentDuration() / (super.getTotalGameTime() * 0.6), 1)); float currentFrequency = (float) (this.startingEmitFrequency - (this.startingEmitFrequency - this.endingEmitFrequency) * Math.min(super.getCurrentDuration() / (super.getTotalTimeLimit() * 0.6), 1));
// Emits a new fruit // Emits a new fruit
if(this.timeSinceLastEmit > currentFrequency){ if(this.timeSinceLastEmit > currentFrequency){
......
...@@ -47,7 +47,7 @@ public abstract class PlayStateUnion extends State { ...@@ -47,7 +47,7 @@ public abstract class PlayStateUnion extends State {
// Game values // Game values
private int score; private int score;
protected float totalGameTime = 0f; protected float totalTimeLimit = 0f;
protected float currentDuration = 0f; protected float currentDuration = 0f;
// Game objects // Game objects
...@@ -90,13 +90,13 @@ public abstract class PlayStateUnion extends State { ...@@ -90,13 +90,13 @@ public abstract class PlayStateUnion extends State {
this.loadingText.update(dt); this.loadingText.update(dt);
// If the game has a total game time (if the game is time-based) // If the game has a total game time (if the game is time-based)
if(this.totalGameTime > 0f) { if(this.totalTimeLimit > 0f) {
// Increases the current duration, used to keep track of the play duration and stop the game // Increases the current duration, used to keep track of the play duration and stop the game
// after a while // after a while
this.currentDuration += dt; this.currentDuration += dt;
// Set score and start rendering the loading text if the game is over // Set score and start rendering the loading text if the game is over
if (this.currentDuration > this.totalGameTime) { if (this.currentDuration > this.totalTimeLimit) {
this.setGameFinished(); this.setGameFinished();
return; return;
} }
...@@ -137,10 +137,10 @@ public abstract class PlayStateUnion extends State { ...@@ -137,10 +137,10 @@ public abstract class PlayStateUnion extends State {
// Renders the text - This is used by this class' render method as well as by the PauseState // Renders the text - This is used by this class' render method as well as by the PauseState
public void renderText(SpriteBatch sb){ public void renderText(SpriteBatch sb){
// Shows the current duration if it's supposed to be visible and the game is time-based // Shows the current duration if it's supposed to be visible and the game is time-based
if(this.timeLeftVisible && this.totalGameTime > 0f) { if(this.timeLeftVisible && this.totalTimeLimit > 0f) {
sb.begin(); sb.begin();
// Time left // Time left
this.font.draw(sb, "Time: " + String.valueOf(Math.max(Math.round((this.totalGameTime - this.currentDuration) * 100), 0.00) / 100.0), Gdx.graphics.getWidth() / 40, Gdx.graphics.getHeight() - Gdx.graphics.getHeight() / 20); this.font.draw(sb, "Time: " + String.valueOf(Math.max(Math.round((this.totalTimeLimit - this.currentDuration) * 100), 0.00) / 100.0), Gdx.graphics.getWidth() / 40, Gdx.graphics.getHeight() - Gdx.graphics.getHeight() / 20);
sb.end(); sb.end();
} }
...@@ -254,8 +254,8 @@ public abstract class PlayStateUnion extends State { ...@@ -254,8 +254,8 @@ public abstract class PlayStateUnion extends State {
this.font.setColor(color); this.font.setColor(color);
} }
public void setTotalGameTime(float totalGameTime){ public void setTotalTimeLimit(float totalTimeLimit){
this.totalGameTime = totalGameTime; this.totalTimeLimit = totalTimeLimit;
} }
public void setCurrentDuration(float currentDuration){ public void setCurrentDuration(float currentDuration){
...@@ -276,8 +276,8 @@ public abstract class PlayStateUnion extends State { ...@@ -276,8 +276,8 @@ public abstract class PlayStateUnion extends State {
return this.currentDuration; return this.currentDuration;
} }
public float getTotalGameTime(){ public float getTotalTimeLimit(){
return this.totalGameTime; return this.totalTimeLimit;
} }
public Texture getThumbnail(){ public Texture getThumbnail(){
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment