Commit 0d3c1854 authored by Tor Martin Frøberg Wang's avatar Tor Martin Frøberg Wang
Browse files

Changed the time limit of the fruit slicer minigame. Renamed some files and...

Changed the time limit of the fruit slicer minigame. Renamed some files and fields to better describe their use. Completes issue #103
parent f0354b92
......@@ -4,6 +4,8 @@ import com.badlogic.gdx.Gdx;
import com.badlogic.gdx.graphics.Texture;
import com.badlogic.gdx.graphics.g2d.SpriteBatch;
// This is the "Loading..." text that can be seen throughout the application
public class LoadingText extends Sprite {
private boolean isLoading = false;
private boolean firstUpdateFinished = false;
......
......@@ -7,6 +7,8 @@ import com.badlogic.gdx.math.Vector3;
import javax.xml.soap.Text;
// This is the pause button that is accessible in all minigames
public class PauseButton extends Sprite {
private Texture blackButtonTexture;
private Texture whiteButtonTexture;
......
......@@ -12,6 +12,8 @@ import com.gameware.game.sprites.Sprite;
import java.util.ArrayList;
import java.util.Random;
// This is the bubble seen in the Bubble Wrap minigame
public class Bubble extends Sprite {
private boolean textureChanged = false;
private ArrayList<Texture> poppedTextures;
......
......@@ -8,6 +8,8 @@ import com.badlogic.gdx.math.Vector3;
import com.gameware.game.GameWare;
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 {
private Texture mainTexture;
private Texture disabledTexture;
......
......@@ -6,6 +6,8 @@ import com.badlogic.gdx.graphics.g2d.SpriteBatch;
import com.badlogic.gdx.math.Vector3;
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 {
private int nextHeight;
private Vector3 velocity;
......
......@@ -7,6 +7,7 @@ import com.badlogic.gdx.graphics.g2d.TextureRegion;
import com.badlogic.gdx.math.Vector3;
import com.gameware.game.sprites.Sprite;
// This is the fruit that can be chopped in the Fruit Slicer minigame
public class Fruit extends Sprite {
private Vector3 cutPosition1;
......
......@@ -6,6 +6,8 @@ import com.badlogic.gdx.graphics.g2d.SpriteBatch;
import com.badlogic.gdx.math.Vector3;
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 {
private Texture slicingVFX;
private int originalWidth;
......
......@@ -6,6 +6,8 @@ import com.badlogic.gdx.graphics.g2d.SpriteBatch;
import com.badlogic.gdx.math.Vector3;
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 {
private Texture boxTexture;
......
......@@ -7,12 +7,14 @@ import com.badlogic.gdx.graphics.glutils.ShapeRenderer;
import com.badlogic.gdx.math.Vector3;
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 Vector3 velocity;
private ShapeRenderer sr;
public PauseCircle(){
public PauseBackgroundCircle(){
this.position = new Vector3();
this.velocity = new Vector3();
......
......@@ -5,6 +5,8 @@ import com.badlogic.gdx.graphics.g2d.SpriteBatch;
import com.badlogic.gdx.math.Vector3;
import com.gameware.game.sprites.Sprite;
// This is the button used for "Resume" and "Exit" in the pause state
public class PauseMenuButton extends Sprite {
private Texture buttonTexture;
......
......@@ -7,7 +7,7 @@ import com.badlogic.gdx.graphics.g2d.SpriteBatch;
import com.gameware.game.GameWare;
import com.gameware.game.sprites.pauseStateSprites.ConfirmationBox;
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.states.games.PlayStateUnion;
......@@ -42,7 +42,7 @@ public class PauseState extends State {
private boolean needsConfirmation;
// Widgets
private List<PauseCircle> pauseCircles;
private List<PauseBackgroundCircle> pauseBackgroundCircles;
private ConfirmationBox confirmationBox;
private PauseMenuButton resumeButton;
private PauseMenuButton exitButton;
......@@ -63,7 +63,7 @@ public class PauseState extends State {
this.countdownDurationLeft = 3f;
this.countdownStarted = false;
this.pauseCircles = new ArrayList<PauseCircle>();
this.pauseBackgroundCircles = new ArrayList<PauseBackgroundCircle>();
this.pausedGame = pausedGame;
this.originalFontColor = new Color(this.pausedGame.getFontColor());
......@@ -85,7 +85,7 @@ public class PauseState extends State {
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 {
// If the user has pressed the resume button the countdown has started
if(this.countdownStarted){
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(this.countdownDurationLeft <= 0){
......@@ -157,7 +157,7 @@ public class PauseState extends State {
}
}
for(PauseCircle pc : this.pauseCircles){
for(PauseBackgroundCircle pc : this.pauseBackgroundCircles){
pc.update(dt);
}
}
......@@ -173,7 +173,7 @@ public class PauseState extends State {
// Animated circles
for(PauseCircle pc : pauseCircles){
for(PauseBackgroundCircle pc : pauseBackgroundCircles){
pc.draw(sb);
}
......@@ -213,7 +213,7 @@ public class PauseState extends State {
@Override
public void dispose() {
for(PauseCircle pc : pauseCircles){
for(PauseBackgroundCircle pc : pauseBackgroundCircles){
pc.dispose();
}
......
......@@ -28,7 +28,7 @@ public class BubbleWrapState extends PlayStateUnion {
public BubbleWrapState(GameStateManager gsm) {
super(gsm);
super.setPauseButtonWhite();
super.setTotalGameTime(20f);
super.setTotalTimeLimit(20f);
super.setFontColorWhite();
super.setThumbnail(new Texture(Gdx.files.internal("gameTextures/BubbleWrap/bubbleWrapPhotoEdit.png")));
......@@ -62,7 +62,7 @@ public class BubbleWrapState extends PlayStateUnion {
// 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.
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{
score = this.poppedBubbles;
......
......@@ -27,7 +27,7 @@ public class ColorRushState extends PlayStateUnion {
public ColorRushState(GameStateManager gsm){
super(gsm);
super.setThumbnail(new Texture(Gdx.files.internal("gameTextures/ColorRush/colorRushPhotoEdit.png")));
super.setTotalGameTime(30f);
super.setTotalTimeLimit(30f);
// Creates the background
this.background = new Texture(Gdx.files.internal("gameTextures/ColorRush/ColorRushBackground.jpg"));
......
......@@ -33,7 +33,7 @@ public class FruitSlicerState extends PlayStateUnion {
public FruitSlicerState(GameStateManager gsm) {
super(gsm);
super.setTotalGameTime(60f);
super.setTotalTimeLimit(45f);
super.setThumbnail(new Texture(Gdx.files.internal("gameTextures/FruitSlicer/FruitSlicerPhotoEdit.png")));
super.setFontColorWhite();
super.setPauseButtonWhite();
......@@ -108,7 +108,7 @@ public class FruitSlicerState extends PlayStateUnion {
this.timeSinceLastEmit += dt;
// 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
if(this.timeSinceLastEmit > currentFrequency){
......
......@@ -47,7 +47,7 @@ public abstract class PlayStateUnion extends State {
// Game values
private int score;
protected float totalGameTime = 0f;
protected float totalTimeLimit = 0f;
protected float currentDuration = 0f;
// Game objects
......@@ -90,13 +90,13 @@ public abstract class PlayStateUnion extends State {
this.loadingText.update(dt);
// 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
// after a while
this.currentDuration += dt;
// 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();
return;
}
......@@ -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
public void renderText(SpriteBatch sb){
// 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();
// 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();
}
......@@ -254,8 +254,8 @@ public abstract class PlayStateUnion extends State {
this.font.setColor(color);
}
public void setTotalGameTime(float totalGameTime){
this.totalGameTime = totalGameTime;
public void setTotalTimeLimit(float totalTimeLimit){
this.totalTimeLimit = totalTimeLimit;
}
public void setCurrentDuration(float currentDuration){
......@@ -276,8 +276,8 @@ public abstract class PlayStateUnion extends State {
return this.currentDuration;
}
public float getTotalGameTime(){
return this.totalGameTime;
public float getTotalTimeLimit(){
return this.totalTimeLimit;
}
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