Commit f0354b92 authored by Turid Cecilie Dahl's avatar Turid Cecilie Dahl
Browse files

Merge branch '102-font-scale-on-device-width' into 'dev'

Resolve "Font scale on device width"

Closes #102

See merge request tobiasio/progark-gruppe-3!109
parents d401db70 e5299357
package com.gameware.game.sprites;
package com.gameware.game.sprites.bubbleWrapSprites;
import com.badlogic.gdx.Gdx;
import com.badlogic.gdx.audio.Sound;
......@@ -7,6 +7,8 @@ import com.gameware.game.GameWare;
import com.badlogic.gdx.graphics.g2d.SpriteBatch;
import com.badlogic.gdx.math.Vector3;
import com.gameware.game.sprites.Sprite;
import java.util.ArrayList;
import java.util.Random;
......
package com.gameware.game.sprites;
package com.gameware.game.sprites.colorRushSprites;
import com.badlogic.gdx.Gdx;
import com.badlogic.gdx.audio.Sound;
......@@ -6,8 +6,9 @@ import com.badlogic.gdx.graphics.Texture;
import com.badlogic.gdx.graphics.g2d.SpriteBatch;
import com.badlogic.gdx.math.Vector3;
import com.gameware.game.GameWare;
import com.gameware.game.sprites.Sprite;
public class ColorRushButton extends Sprite{
public class ColorRushButton extends Sprite {
private Texture mainTexture;
private Texture disabledTexture;
private int colorNum;
......
package com.gameware.game.sprites;
package com.gameware.game.sprites.colorRushSprites;
import com.badlogic.gdx.Gdx;
import com.badlogic.gdx.graphics.Texture;
import com.badlogic.gdx.graphics.g2d.SpriteBatch;
import com.badlogic.gdx.math.Vector3;
import com.gameware.game.sprites.Sprite;
public class ColorRushTarget extends Sprite{
public class ColorRushTarget extends Sprite {
private int nextHeight;
private Vector3 velocity;
private Texture mainTexture;
......
package com.gameware.game.sprites;
package com.gameware.game.sprites.fruitSlicerSprites;
import com.badlogic.gdx.Gdx;
import com.badlogic.gdx.graphics.Texture;
import com.badlogic.gdx.graphics.g2d.SpriteBatch;
import com.badlogic.gdx.graphics.g2d.TextureRegion;
import com.badlogic.gdx.math.Vector3;
import com.gameware.game.sprites.Sprite;
public class Fruit extends Sprite {
......
package com.gameware.game.sprites;
package com.gameware.game.sprites.fruitSlicerSprites;
import com.badlogic.gdx.Gdx;
import com.badlogic.gdx.graphics.Texture;
import com.badlogic.gdx.graphics.g2d.SpriteBatch;
import com.badlogic.gdx.math.Vector3;
import com.gameware.game.sprites.Sprite;
public class SlicingCircle extends Sprite {
private Texture slicingVFX;
......
package com.gameware.game.sprites;
package com.gameware.game.sprites.pauseStateSprites;
import com.badlogic.gdx.Gdx;
import com.badlogic.gdx.graphics.Texture;
import com.badlogic.gdx.graphics.g2d.SpriteBatch;
import com.badlogic.gdx.math.Vector3;
import com.gameware.game.sprites.Sprite;
public class ConfirmationBox extends Sprite {
private Texture boxTexture;
......
package com.gameware.game.sprites;
package com.gameware.game.sprites.pauseStateSprites;
import com.badlogic.gdx.Gdx;
import com.badlogic.gdx.graphics.Color;
import com.badlogic.gdx.graphics.g2d.SpriteBatch;
import com.badlogic.gdx.graphics.glutils.ShapeRenderer;
import com.badlogic.gdx.math.Vector3;
import com.gameware.game.sprites.Sprite;
public class PauseCircle extends Sprite {
private int radius;
......
package com.gameware.game.sprites;
package com.gameware.game.sprites.pauseStateSprites;
import com.badlogic.gdx.graphics.Texture;
import com.badlogic.gdx.graphics.g2d.SpriteBatch;
import com.badlogic.gdx.math.Vector3;
import com.gameware.game.sprites.Sprite;
public class PauseMenuButton extends Sprite {
private Texture buttonTexture;
......
......@@ -5,10 +5,10 @@ import com.badlogic.gdx.graphics.Color;
import com.badlogic.gdx.graphics.Texture;
import com.badlogic.gdx.graphics.g2d.SpriteBatch;
import com.gameware.game.GameWare;
import com.gameware.game.sprites.ConfirmationBox;
import com.gameware.game.sprites.pauseStateSprites.ConfirmationBox;
import com.gameware.game.sprites.LoadingText;
import com.gameware.game.sprites.PauseCircle;
import com.gameware.game.sprites.PauseMenuButton;
import com.gameware.game.sprites.pauseStateSprites.PauseCircle;
import com.gameware.game.sprites.pauseStateSprites.PauseMenuButton;
import com.gameware.game.states.games.PlayStateUnion;
import java.util.ArrayList;
......@@ -231,5 +231,9 @@ public class PauseState extends State {
}
@Override
public void reset() { }
public void reset() {
this.needsConfirmation = false;
this.countdownStarted = false;
this.countdownDurationLeft = 3f;
}
}
......@@ -3,7 +3,7 @@ package com.gameware.game.states.games;
import com.badlogic.gdx.Gdx;
import com.badlogic.gdx.graphics.Texture;
import com.badlogic.gdx.graphics.g2d.SpriteBatch;
import com.gameware.game.sprites.Bubble;
import com.gameware.game.sprites.bubbleWrapSprites.Bubble;
import com.gameware.game.states.GameStateManager;
import java.util.ArrayList;
......@@ -30,7 +30,7 @@ public class BubbleWrapState extends PlayStateUnion {
super.setPauseButtonWhite();
super.setTotalGameTime(20f);
super.setFontColorWhite();
super.screenshot = new Texture(Gdx.files.internal("gameTextures/BubbleWrap/bubbleWrapPhotoEdit.png"));
super.setThumbnail(new Texture(Gdx.files.internal("gameTextures/BubbleWrap/bubbleWrapPhotoEdit.png")));
background = new Texture(Gdx.files.internal("gameTextures/BubbleWrap/bubblewrap_background.jpg"));
unpopped = new Texture(Gdx.files.internal("gameTextures/BubbleWrap/bubble_unpopped_1.png"));
......
......@@ -2,8 +2,8 @@ package com.gameware.game.states.games;
import com.badlogic.gdx.Gdx;
import com.badlogic.gdx.graphics.Texture;
import com.badlogic.gdx.graphics.g2d.SpriteBatch;
import com.gameware.game.sprites.ColorRushButton;
import com.gameware.game.sprites.ColorRushTarget;
import com.gameware.game.sprites.colorRushSprites.ColorRushButton;
import com.gameware.game.sprites.colorRushSprites.ColorRushTarget;
import com.gameware.game.states.GameStateManager;
import java.util.ArrayList;
......@@ -26,7 +26,7 @@ public class ColorRushState extends PlayStateUnion {
public ColorRushState(GameStateManager gsm){
super(gsm);
super.screenshot = new Texture(Gdx.files.internal("gameTextures/ColorRush/colorRushPhotoEdit.png"));
super.setThumbnail(new Texture(Gdx.files.internal("gameTextures/ColorRush/colorRushPhotoEdit.png")));
super.setTotalGameTime(30f);
// Creates the background
......
......@@ -6,8 +6,8 @@ import com.badlogic.gdx.graphics.Texture;
import com.badlogic.gdx.graphics.g2d.SpriteBatch;
import com.badlogic.gdx.math.Vector3;
import com.gameware.game.GameWare;
import com.gameware.game.sprites.Fruit;
import com.gameware.game.sprites.SlicingCircle;
import com.gameware.game.sprites.fruitSlicerSprites.Fruit;
import com.gameware.game.sprites.fruitSlicerSprites.SlicingCircle;
import com.gameware.game.states.GameStateManager;
import java.util.ArrayList;
......@@ -34,7 +34,9 @@ public class FruitSlicerState extends PlayStateUnion {
public FruitSlicerState(GameStateManager gsm) {
super(gsm);
super.setTotalGameTime(60f);
super.screenshot = new Texture(Gdx.files.internal("gameTextures/FruitSlicer/FruitSlicerPhotoEdit.png"));
super.setThumbnail(new Texture(Gdx.files.internal("gameTextures/FruitSlicer/FruitSlicerPhotoEdit.png")));
super.setFontColorWhite();
super.setPauseButtonWhite();
this.sliceWhooshSound = Gdx.audio.newSound(Gdx.files.internal("sfx/FruitSlicerWhooshSound.mp3"));
this.sliceSquishSound = Gdx.audio.newSound(Gdx.files.internal("sfx/FruitSlicerSquishSound.mp3"));
......@@ -78,6 +80,12 @@ public class FruitSlicerState extends PlayStateUnion {
this.oldTouchPosition.x = touchX;
this.oldTouchPosition.y = touchY;
}
// Adds new slicing circles if the user is touching
if(Gdx.input.isTouched()) {
this.slicingCircles.add(new SlicingCircle(Gdx.input.getX(), Gdx.graphics.getHeight() - Gdx.input.getY(), this.slicingCircleVFX));
}
}
@Override
......@@ -87,11 +95,6 @@ public class FruitSlicerState extends PlayStateUnion {
this.handleInput();
// Adds new slicing circles if the user is touching
if(Gdx.input.isTouched()) {
this.slicingCircles.add(new SlicingCircle(Gdx.input.getX(), Gdx.graphics.getHeight() - Gdx.input.getY(), this.slicingCircleVFX));
}
// Updates the slicing circles
for(SlicingCircle slicingCircle : this.slicingCircles){
slicingCircle.update(dt);
......@@ -165,7 +168,7 @@ public class FruitSlicerState extends PlayStateUnion {
// Four different emit modes: from left, from right, from entire bottom, and from bottom center with different velocity angles
int emitMode = (int) (Math.random() * 4);
Fruit fruit;
Texture fruitTexture = this.fruitTextures.get((int) (Math.random() * 20));
Texture fruitTexture = this.fruitTextures.get((int) (Math.random() * this.fruitTextures.size()));
Vector3 velocity = new Vector3(Gdx.graphics.getWidth() * 3 / 4, 0, 0);
int x, y, emitAngle;
......
......@@ -51,7 +51,7 @@ public abstract class PlayStateUnion extends State {
protected float currentDuration = 0f;
// Game objects
protected Texture screenshot = null;
private Texture thumbnail = new Texture(Gdx.files.internal("gameTextures/placeholderThumbnail.png"));
private PauseButton pauseButton;
private LoadingText loadingText = new LoadingText();
private BitmapFont font;
......@@ -71,7 +71,7 @@ public abstract class PlayStateUnion extends State {
// Default font (black color)
font = new BitmapFont();
font.setColor(Color.BLACK);
font.getData().setScale((float) (Gdx.graphics.getWidth()/GameWare.WIDTH*1.75));
font.getData().setScale((float) (Gdx.graphics.getWidth()/GameWare.WIDTH*2.5));
}
// Override methods
......@@ -127,6 +127,7 @@ public abstract class PlayStateUnion extends State {
this.loadingText.dispose();
this.pauseButton.dispose();
this.font.dispose();
this.thumbnail.dispose();
}
@Override
......@@ -139,12 +140,13 @@ public abstract class PlayStateUnion extends State {
if(this.timeLeftVisible && this.totalGameTime > 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() / 40 - Gdx.graphics.getHeight() / 60);
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);
sb.end();
}
if(this.currentScoreVisible){
sb.begin();
//Score
this.font.draw(sb, "Score: " + String.valueOf(this.score), Gdx.graphics.getWidth() / 40, Gdx.graphics.getHeight() - Gdx.graphics.getHeight() / 100);
sb.end();
......@@ -260,6 +262,11 @@ public abstract class PlayStateUnion extends State {
this.currentDuration = currentDuration;
}
public void setThumbnail(Texture thumbnailTexture){
this.thumbnail.dispose();
this.thumbnail = thumbnailTexture;
}
// Getters
public Color getFontColor(){
return this.font.getColor();
......@@ -273,8 +280,8 @@ public abstract class PlayStateUnion extends State {
return this.totalGameTime;
}
public Texture getScreenshot(){
return screenshot;
public Texture getThumbnail(){
return thumbnail;
}
// Hide and show methods:
......
......@@ -187,7 +187,7 @@ public class CreateNewTournamentState extends MenuStateUnion {
continue;
}
innerTable.add(new Image(GameWare.getInstance().getGameIdToPlayState().get(g.getId()).getScreenshot())).width(imageWidthAndHeigh).height(imageWidthAndHeigh);
innerTable.add(new Image(GameWare.getInstance().getGameIdToPlayState().get(g.getId()).getThumbnail())).width(imageWidthAndHeigh).height(imageWidthAndHeigh);
Table innerInnerTable = new Table();
innerInnerTable.defaults().space(spacingLittle);
......
......@@ -34,9 +34,10 @@ import com.gameware.game.states.State;
public abstract class MenuStateUnion extends State {
// Font
protected final float fontScale = 3f;
protected final float tinierTitleFontBigScale = 1.5f;
protected final float titleFontBigScale = 2.5f;
protected final float scaleRatio = Float.valueOf(Gdx.graphics.getWidth()) / 1080f;
protected final float fontScale = 3f * scaleRatio;
protected final float tinierTitleFontBigScale = 1.5f * scaleRatio;
protected final float titleFontBigScale = 2.5f * scaleRatio;
// Spacing
protected final float spacingLittle = Gdx.graphics.getHeight()/50;
......@@ -73,7 +74,10 @@ public abstract class MenuStateUnion extends State {
public MenuStateUnion(GameStateManager gsm){
super(gsm);
// Scales the font according to the ratio between the screen width and the default 1080 width
skin.getFont("font").getData().setScale(fontScale);
skin.getFont("font-big").getData().setScale(this.scaleRatio);
// Add sound effects
this.checkBoxSound = Gdx.audio.newSound(Gdx.files.internal("sfx/check_box.ogg"));
......
......@@ -91,7 +91,7 @@ public class SinglePlayerSelectGameState extends MenuStateUnion {
if(GameWare.getInstance().getGameIdToPlayState().get(g.getId()) == null){
continue;
}
innerTable.add(new Image(GameWare.getInstance().getGameIdToPlayState().get(g.getId()).getScreenshot())).width(imageWidthAndHeigh).height(imageWidthAndHeigh).pad(spacingLittle);
innerTable.add(new Image(GameWare.getInstance().getGameIdToPlayState().get(g.getId()).getThumbnail())).width(imageWidthAndHeigh).height(imageWidthAndHeigh).pad(spacingLittle);
Table innerInnerTable = new Table();
innerInnerTable.add(makeTableWithLabelAndQuestionIcon(new Label(g.getName(), skin), makeQuestionIconDialog(new Label(g.getExplanation().replaceAll("\\\\n", "\n"), skin)))).spaceBottom(spacingLittle);
......
......@@ -97,7 +97,7 @@ public class ViewHighScoreState extends MenuStateUnion {
if(GameWare.getInstance().getGameIdToPlayState().get(g.getId()) == null){
continue;
}
innerTable.add(new Image(GameWare.getInstance().getGameIdToPlayState().get(g.getId()).getScreenshot())).width(imageWidthAndHeigh).height(imageWidthAndHeigh).pad(spacingLittle);
innerTable.add(new Image(GameWare.getInstance().getGameIdToPlayState().get(g.getId()).getThumbnail())).width(imageWidthAndHeigh).height(imageWidthAndHeigh).pad(spacingLittle);
Table innerInnerTable = new Table();
innerInnerTable.add(makeTableWithLabelAndQuestionIcon(new Label(g.getName(), skin), makeQuestionIconDialog(new Label(g.getExplanation().replaceAll("\\\\n", "\n"), skin)))).spaceBottom(spacingLittle);
......
......@@ -121,7 +121,7 @@ public class ViewTournamentState extends MenuStateUnion {
currentRoundTable.setBackground(backgroundTableBlueRounded);
currentRoundTable.add(new Label("This round:\n\n"+gameName,skin)).space(spacingLittle);
PlayStateUnion state = GameWare.getInstance().getGameIdToPlayState().get(round.getGameId());
currentRoundTable.add(new Image(state.getScreenshot())).width(imageWidthAndHeigh).height(imageWidthAndHeigh).spaceBottom(spacingMedium).colspan(2);
currentRoundTable.add(new Image(state.getThumbnail())).width(imageWidthAndHeigh).height(imageWidthAndHeigh).spaceBottom(spacingMedium).colspan(2);
rootTable.add(currentRoundTable).maxHeight(Gdx.graphics.getHeight()/5).colspan(2);
rootTable.row();
......@@ -139,7 +139,7 @@ public class ViewTournamentState extends MenuStateUnion {
rootTable.add(innerTable).colspan(2);
rootTable.row();
rootTable.add(makeBackBtn()).expand().bottom().left();
roundDeadline.setFontScale(0.8f);
roundDeadline.setFontScale(0.8f * super.scaleRatio);
rootTable.add(roundDeadline).expand().bottom().right();
stage.addActor(rootTable);
......
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