Skip to content
Snippets Groups Projects
Commit 00cdab5f authored by Turid Cecilie Dahl's avatar Turid Cecilie Dahl
Browse files

Merge branch '94-change-name-of-playstatetemplate-to-playstatecomposite' into 'dev'

Resolve "Change name of PlayStateTemplate to PlayStateComposite"

Closes #94

See merge request !94
parents 0298e3d7 7957f204
No related branches found
No related tags found
1 merge request!94Resolve "Change name of PlayStateTemplate to PlayStateComposite"
...@@ -16,7 +16,7 @@ import com.gameware.game.models.Player; ...@@ -16,7 +16,7 @@ import com.gameware.game.models.Player;
import com.gameware.game.states.GameStateManager; import com.gameware.game.states.GameStateManager;
import com.gameware.game.states.LoginState; import com.gameware.game.states.LoginState;
import com.gameware.game.states.MenuState; import com.gameware.game.states.MenuState;
import com.gameware.game.states.PlayStateTemplate; import com.gameware.game.states.PlayStateComposite;
import java.io.IOException; import java.io.IOException;
import java.lang.reflect.Constructor; import java.lang.reflect.Constructor;
...@@ -44,7 +44,7 @@ public class GameWare extends ApplicationAdapter { ...@@ -44,7 +44,7 @@ public class GameWare extends ApplicationAdapter {
private Player player; private Player player;
private List<Game> games = new ArrayList<>(); private List<Game> games = new ArrayList<>();
private Map<String, PlayStateTemplate> gameIdToPlayState = new HashMap<>(); private Map<String, PlayStateComposite> gameIdToPlayState = new HashMap<>();
//Singleton (lazy initialization) //Singleton (lazy initialization)
private GameWare(){ } private GameWare(){ }
...@@ -121,11 +121,11 @@ public class GameWare extends ApplicationAdapter { ...@@ -121,11 +121,11 @@ public class GameWare extends ApplicationAdapter {
return games; return games;
} }
public Map<String, PlayStateTemplate> getGameIdToPlayState(){ public Map<String, PlayStateComposite> getGameIdToPlayState(){
return gameIdToPlayState; return gameIdToPlayState;
} }
public void updateGameMap(String id, PlayStateTemplate state){ public void updateGameMap(String id, PlayStateComposite state){
gameIdToPlayState.put(id, state); gameIdToPlayState.put(id, state);
} }
...@@ -201,7 +201,7 @@ public class GameWare extends ApplicationAdapter { ...@@ -201,7 +201,7 @@ public class GameWare extends ApplicationAdapter {
try { try {
Class cl = Class.forName(className); Class cl = Class.forName(className);
Constructor con = cl.getConstructor(GameStateManager.class); Constructor con = cl.getConstructor(GameStateManager.class);
PlayStateTemplate state = (PlayStateTemplate) con.newInstance(gsm); PlayStateComposite state = (PlayStateComposite) con.newInstance(gsm);
gameIdToPlayState.put(id, state); gameIdToPlayState.put(id, state);
} catch (Exception e) { } catch (Exception e) {
e.printStackTrace(); e.printStackTrace();
......
...@@ -7,7 +7,7 @@ import com.gameware.game.sprites.Bubble; ...@@ -7,7 +7,7 @@ import com.gameware.game.sprites.Bubble;
import java.util.ArrayList; import java.util.ArrayList;
public class BubbleWrapState extends PlayStateTemplate { public class BubbleWrapState extends PlayStateComposite {
private Texture background; private Texture background;
private Texture unpopped; private Texture unpopped;
private Texture popped1; private Texture popped1;
......
...@@ -9,7 +9,7 @@ import java.util.ArrayList; ...@@ -9,7 +9,7 @@ import java.util.ArrayList;
import java.util.Collections; import java.util.Collections;
import java.util.List; import java.util.List;
public class ColorRushState extends PlayStateTemplate { public class ColorRushState extends PlayStateComposite {
private List<ColorRushTarget> activeTargets; private List<ColorRushTarget> activeTargets;
private List<ColorRushTarget> previousTargets; private List<ColorRushTarget> previousTargets;
......
...@@ -12,7 +12,7 @@ import com.gameware.game.sprites.SlicingCircle; ...@@ -12,7 +12,7 @@ import com.gameware.game.sprites.SlicingCircle;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.List; import java.util.List;
public class FruitSlicerState extends PlayStateTemplate { public class FruitSlicerState extends PlayStateComposite {
private int totalFruitsCut = 0; private int totalFruitsCut = 0;
private float startingEmitFrequency = 1f; private float startingEmitFrequency = 1f;
private float endingEmitFrequency = 0.2f; private float endingEmitFrequency = 0.2f;
...@@ -52,12 +52,13 @@ public class FruitSlicerState extends PlayStateTemplate { ...@@ -52,12 +52,13 @@ public class FruitSlicerState extends PlayStateTemplate {
if(Gdx.input.isTouched()) { if(Gdx.input.isTouched()) {
int touchX = Gdx.input.getX(); int touchX = Gdx.input.getX();
int touchY = Gdx.input.getY(); int touchY = Gdx.input.getY();
float deltaTime = Gdx.graphics.getDeltaTime();
boolean didCut = false; boolean didCut = false;
this.lengthMoved = (float) Math.sqrt(Math.pow((touchX - this.oldTouchPosition.x), 2) + Math.pow((touchY - this.oldTouchPosition.y), 2)); this.lengthMoved = (float) Math.sqrt(Math.pow((touchX - this.oldTouchPosition.x), 2) + Math.pow((touchY - this.oldTouchPosition.y), 2));
// If the user moved fast enough (sliced fast enough) // If the user moved fast enough (sliced fast enough)
if(lengthMoved >= this.slicingSpeedThreshold * (0.016 / Gdx.graphics.getDeltaTime())) { if(lengthMoved >= this.slicingSpeedThreshold * (0.01 / deltaTime)) {
for (Fruit fruit : this.emittedFruits) { for (Fruit fruit : this.emittedFruits) {
if (fruit.isPressed(touchX, touchY)) { if (fruit.isPressed(touchX, touchY)) {
this.totalFruitsCut++; this.totalFruitsCut++;
...@@ -96,7 +97,7 @@ public class FruitSlicerState extends PlayStateTemplate { ...@@ -96,7 +97,7 @@ public class FruitSlicerState extends PlayStateTemplate {
} }
// Disposes the oldest slicing circle if it is disposable // Disposes the oldest slicing circle if it is disposable
if(slicingCircles.size() > 0 && slicingCircles.get(0).isDisposable()){ while(slicingCircles.size() > 0 && slicingCircles.get(0).isDisposable()){
this.slicingCircles.remove(0).dispose(); this.slicingCircles.remove(0).dispose();
} }
......
...@@ -24,7 +24,7 @@ public class PauseState extends State { ...@@ -24,7 +24,7 @@ public class PauseState extends State {
private PauseMenuButton resumeButton; private PauseMenuButton resumeButton;
private PauseMenuButton exitButton; private PauseMenuButton exitButton;
private boolean needsConfirmation; private boolean needsConfirmation;
private PlayStateTemplate pausedGame; private PlayStateComposite pausedGame;
private LoadingText loadingText; private LoadingText loadingText;
private boolean userExited; private boolean userExited;
private Color originalFontColor; private Color originalFontColor;
...@@ -33,7 +33,7 @@ public class PauseState extends State { ...@@ -33,7 +33,7 @@ public class PauseState extends State {
private boolean countdownStarted = false; private boolean countdownStarted = false;
private Texture countdownNumberTexture; private Texture countdownNumberTexture;
public PauseState(GameStateManager gsm, PlayStateTemplate pausedGame) { public PauseState(GameStateManager gsm, PlayStateComposite pausedGame) {
super(gsm); super(gsm);
this.background = new Texture(Gdx.files.internal("pause/PauseBackground.jpg")); this.background = new Texture(Gdx.files.internal("pause/PauseBackground.jpg"));
......
...@@ -19,7 +19,7 @@ import java.io.IOException; ...@@ -19,7 +19,7 @@ import java.io.IOException;
import java.util.List; import java.util.List;
public abstract class PlayStateTemplate extends State { public abstract class PlayStateComposite extends State {
private int score; private int score;
private Round round = null; private Round round = null;
private Tournament tournament = null; private Tournament tournament = null;
...@@ -35,7 +35,7 @@ public abstract class PlayStateTemplate extends State { ...@@ -35,7 +35,7 @@ public abstract class PlayStateTemplate extends State {
protected Texture screenshot = null; protected Texture screenshot = null;
protected float currentDuration = 0f; protected float currentDuration = 0f;
public PlayStateTemplate(GameStateManager gsm){ public PlayStateComposite(GameStateManager gsm){
super(gsm); super(gsm);
// Default pause button (black color) // Default pause button (black color)
......
...@@ -123,7 +123,7 @@ public class SinglePlayerSelectGameState extends State { ...@@ -123,7 +123,7 @@ public class SinglePlayerSelectGameState extends State {
@Override @Override
public void clicked(InputEvent event, float x, float y) { public void clicked(InputEvent event, float x, float y) {
Map<String, PlayStateTemplate> map = GameWare.getInstance().getGameIdToPlayState(); Map<String, PlayStateComposite> map = GameWare.getInstance().getGameIdToPlayState();
State s = map.get(game.getId()); State s = map.get(game.getId());
handleGameBtnClick(s); handleGameBtnClick(s);
}; };
......
...@@ -97,7 +97,7 @@ public class ViewTournamentState extends State { ...@@ -97,7 +97,7 @@ public class ViewTournamentState extends State {
currentRoundTable.pad(padding); currentRoundTable.pad(padding);
currentRoundTable.setBackground(backgroundTableBlueRounded); currentRoundTable.setBackground(backgroundTableBlueRounded);
currentRoundTable.add(new Label("This round:\n\n"+gameName,skin)).space(spacingLittle); currentRoundTable.add(new Label("This round:\n\n"+gameName,skin)).space(spacingLittle);
PlayStateTemplate state = GameWare.getInstance().getGameIdToPlayState().get(round.getGameId()); PlayStateComposite state = GameWare.getInstance().getGameIdToPlayState().get(round.getGameId());
currentRoundTable.add(new Image(state.screenshot)).width(imageWidthAndHeigh).height(imageWidthAndHeigh).spaceBottom(spacingMedium).colspan(2); currentRoundTable.add(new Image(state.screenshot)).width(imageWidthAndHeigh).height(imageWidthAndHeigh).spaceBottom(spacingMedium).colspan(2);
rootTable.add(currentRoundTable).maxHeight(Gdx.graphics.getHeight()/5).colspan(2); rootTable.add(currentRoundTable).maxHeight(Gdx.graphics.getHeight()/5).colspan(2);
rootTable.row(); rootTable.row();
...@@ -262,7 +262,7 @@ public class ViewTournamentState extends State { ...@@ -262,7 +262,7 @@ public class ViewTournamentState extends State {
private void handlePlayBtnClick(){ private void handlePlayBtnClick(){
if(GameWare.getInstance().isSoundEffectsOn()){ buttonPressSound.play(); } if(GameWare.getInstance().isSoundEffectsOn()){ buttonPressSound.play(); }
PlayStateTemplate state = GameWare.getInstance().getGameIdToPlayState().get(round.getGameId()); PlayStateComposite state = GameWare.getInstance().getGameIdToPlayState().get(round.getGameId());
state.setTournament(tournament); state.setTournament(tournament);
state.setRound(round); state.setRound(round);
gsm.set(state); gsm.set(state);
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment