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

Merge branch '22-viewtournament-viewhighscore-createjointournament-state-classes' into 'dev'

Resolve "ViewTournament-, ViewHighscore-, CreateJoinTournament-, State Classes"

Closes #22

See merge request !8
parents e0e1fbdc f730be66
No related branches found
No related tags found
1 merge request!8Resolve "ViewTournament-, ViewHighscore-, CreateJoinTournament-, State Classes"
......@@ -4,22 +4,24 @@ import com.badlogic.gdx.ApplicationAdapter;
import com.badlogic.gdx.Gdx;
import com.badlogic.gdx.graphics.GL20;
import com.badlogic.gdx.graphics.g2d.SpriteBatch;
import com.gameware.game.states.CreateJoinTournamentState;
import com.gameware.game.states.GameStateManager;
import com.gameware.game.states.MenuState;
import com.gameware.game.states.ViewHighScoreState;
import com.gameware.game.states.ViewTournamentState;
import com.gameware.game.states.LoginState;
public class GameWare extends ApplicationAdapter {
private SpriteBatch batch;
private GameStateManager gsm;
public static final int WIDTH = 480;
public static final int HEIGHT = 800;
public static final String TITLE = "WackyWare!";
public static final String skinFilePath = "glassy/skin/glassy-ui.json";
private GameStateManager gsm;
private SpriteBatch batch;
// private Music music;
// TODO: Add music
private static GameWare instance = null;
//Singleton (lazy initialization)
public static GameWare getInstance(){
if( instance == null){
......@@ -47,6 +49,7 @@ public class GameWare extends ApplicationAdapter {
gsm.render(batch);
}
@Override
public void dispose () {
batch.dispose();
......
package com.gameware.game.sprites;
import com.badlogic.gdx.graphics.g2d.SpriteBatch;
import com.badlogic.gdx.math.Vector3;
public abstract class Sprite {
private Vector3 position;
private int width;
private int height;
private Object bounds;
protected Vector3 position;
protected int width;
protected int height;
protected Object bounds;
public abstract void reset();
public abstract Object report();
public abstract void draw();
public abstract void draw(SpriteBatch sb);
public abstract void update();
public abstract void dispose();
......
package com.gameware.game.states;
import com.badlogic.gdx.Gdx;
import com.badlogic.gdx.graphics.g2d.SpriteBatch;
import com.badlogic.gdx.math.Vector3;
import com.badlogic.gdx.scenes.scene2d.InputEvent;
import com.badlogic.gdx.scenes.scene2d.Stage;
import com.badlogic.gdx.scenes.scene2d.ui.Button;
import com.badlogic.gdx.scenes.scene2d.ui.Skin;
import com.badlogic.gdx.scenes.scene2d.ui.Table;
import com.badlogic.gdx.scenes.scene2d.ui.TextButton;
import com.badlogic.gdx.scenes.scene2d.utils.ClickListener;
import com.gameware.game.GameWare;
public class CreateJoinTournamentState extends State {
private Stage stage;
private Table table;
private int spacingOnBottom = Gdx.graphics.getHeight()/15;
private float fontScaleX = 3f;
private float fontScaleY = 3f;
private String backBtnText = "Back";
private String enterBtnText = "Enter";
public CreateJoinTournamentState(GameStateManager gsm) {
super(gsm);
System.out.println("Du er i create join tournament state :0");
stage = new Stage();
Gdx.input.setInputProcessor(stage);
Skin skin = new Skin(Gdx.files.internal(GameWare.skinFilePath));
skin.getFont("font").getData().setScale(fontScaleX,fontScaleY);
cam.setToOrtho(false, Gdx.graphics.getWidth()/2, Gdx.graphics.getHeight()/2);
table = new Table();
table.setFillParent(true);
table.row();
TextButton backBtn = new TextButton(backBtnText, skin);
backBtn.addListener(new ClickListener() {
@Override
public void clicked(InputEvent e, float x, float y){
handleBackBtnClick();
}
});
table.add(backBtn);
table.row();
TextButton enterBtn = new TextButton(enterBtnText, skin);
enterBtn.addListener(new ClickListener() {
@Override
public void clicked(InputEvent e, float x, float y){
handleEnterBtnClick();
}
});
table.add(enterBtn);
stage.addActor(table);
}
@Override
protected void handleInput() {
}
@Override
public void update(float dt) {
stage.act(dt);
}
@Override
public void render(SpriteBatch sb) {
stage.draw();
}
@Override
public void dispose() {
stage.dispose();
}
@Override
public void reset() {
}
@Override
public Object report() {
return this;
}
private void handleBackBtnClick(){
gsm.set(new MenuState(gsm));
}
private void handleEnterBtnClick(){
gsm.set(new ViewTournamentState(gsm));
}
}
......@@ -6,11 +6,9 @@ import java.util.Stack;
public class GameStateManager {
private Stack<State> states;
private Object returnObj;
public GameStateManager(){
states = new Stack<State>();
returnObj = new Object();
}
public void push(State state){
......@@ -36,7 +34,7 @@ public class GameStateManager {
public Object report(){
//Don't know what this method should do...
return returnObj;
return this;
}
......
package com.gameware.game.states;
import com.badlogic.gdx.Gdx;
import com.badlogic.gdx.graphics.g2d.SpriteBatch;
import com.badlogic.gdx.scenes.scene2d.InputEvent;
import com.badlogic.gdx.scenes.scene2d.Stage;
import com.badlogic.gdx.scenes.scene2d.ui.Skin;
import com.badlogic.gdx.scenes.scene2d.ui.Table;
import com.badlogic.gdx.scenes.scene2d.ui.TextButton;
import com.badlogic.gdx.scenes.scene2d.utils.ClickListener;
import com.gameware.game.GameWare;
public class MenuState extends State{
protected MenuState(GameStateManager gsm) {
private Stage stage;
private Table table;
private int spacingOnBottom = Gdx.graphics.getHeight()/15;
private float fontScaleX = 3f;
private float fontScaleY = 3f;
private String singlePlayerBtnText = "Single player";
private String multiPlayerBtnText = "Multi player";
private String highScoreBtnText = "High Scores";
private String optionBtnText = "Options";
private String logOutBtnText = "Log out";
public MenuState(GameStateManager gsm) {
super(gsm);
System.out.println("Du er i menu state :0");
stage = new Stage();
Gdx.input.setInputProcessor(stage);
Skin skin = new Skin(Gdx.files.internal(GameWare.skinFilePath));
skin.getFont("font").getData().setScale(fontScaleX,fontScaleY);
cam.setToOrtho(false, Gdx.graphics.getWidth()/2, Gdx.graphics.getHeight()/2);
table = new Table();
table.setFillParent(true);
table.row();
TextButton singlePlayerBtn = new TextButton(singlePlayerBtnText, skin);
singlePlayerBtn.addListener(new ClickListener() {
@Override
public void clicked(InputEvent e, float x, float y){ handleSingleBtnClick(); }
});
table.add(singlePlayerBtn);
table.row();
TextButton multiPlayerBtn = new TextButton(multiPlayerBtnText, skin);
multiPlayerBtn.addListener(new ClickListener() {
@Override
public void clicked(InputEvent e, float x, float y){ handleMultiBtnClick(); }
});
table.add(multiPlayerBtn);
table.row();
TextButton optionsBtn = new TextButton(optionBtnText, skin);
optionsBtn.addListener(new ClickListener() {
@Override
public void clicked(InputEvent e, float x, float y){ handleOptionsBtnClick(); }
});
table.add(optionsBtn);
table.row();
TextButton highScoreBtn = new TextButton(highScoreBtnText, skin);
highScoreBtn.addListener(new ClickListener() {
@Override
public void clicked(InputEvent e, float x, float y){ handleHighscoreBtnClick(); }
});
table.add(highScoreBtn);
stage.addActor(table);
}
@Override
......@@ -15,17 +80,17 @@ public class MenuState extends State{
@Override
public void update(float dt) {
stage.act(dt);
}
@Override
public void render(SpriteBatch sb) {
stage.draw();
}
@Override
public void dispose() {
stage.dispose();
}
@Override
......@@ -35,22 +100,26 @@ public class MenuState extends State{
@Override
public Object report() {
return null;
return this;
}
private void optionsBtnClick(){
private void handleOptionsBtnClick(){
}
private void multiBtnClick(){
private void handleMultiBtnClick(){
gsm.set(new CreateJoinTournamentState(gsm));
}
private void singleBtnClick(){
private void handleSingleBtnClick(){
}
private void handleHighscoreBtnClick(){
gsm.set(new ViewHighScoreState(gsm));
}
private void highscoreBtnClick(){
private void handleLogOutBtnClick(){
}
......
package com.gameware.game.states;
import com.badlogic.gdx.Gdx;
import com.badlogic.gdx.graphics.g2d.SpriteBatch;
import com.badlogic.gdx.math.Vector3;
import com.badlogic.gdx.scenes.scene2d.InputEvent;
import com.badlogic.gdx.scenes.scene2d.Stage;
import com.badlogic.gdx.scenes.scene2d.ui.Button;
import com.badlogic.gdx.scenes.scene2d.ui.Skin;
import com.badlogic.gdx.scenes.scene2d.ui.Table;
import com.badlogic.gdx.scenes.scene2d.ui.TextButton;
import com.badlogic.gdx.scenes.scene2d.utils.ClickListener;
import com.gameware.game.GameWare;
public class ViewHighScoreState extends State {
private Stage stage;
private Table table;
private int spacingOnBottom = Gdx.graphics.getHeight()/15;
private float fontScaleX = 3f;
private float fontScaleY = 3f;
private String backBtnText = "Back";
private String colorRushHighScoreBtnText = "Color Rush";
private String bubbleWrapHighScoreBtnText = "Bubble Wrap";
public ViewHighScoreState(GameStateManager gsm) {
super(gsm);
System.out.println("Du er i view high score state :0");
stage = new Stage();
Gdx.input.setInputProcessor(stage);
Skin skin = new Skin(Gdx.files.internal(GameWare.skinFilePath));
skin.getFont("font").getData().setScale(fontScaleX,fontScaleY);
cam.setToOrtho(false, Gdx.graphics.getWidth()/2, Gdx.graphics.getHeight()/2);
table = new Table();
table.setFillParent(true);
table.row();
TextButton backBtn = new TextButton(backBtnText, skin);
backBtn.addListener(new ClickListener() {
@Override
public void clicked(InputEvent e, float x, float y){ handleBackBtnClick(); }
});
table.add(backBtn);
table.row();
TextButton colorRushBtn = new TextButton(colorRushHighScoreBtnText, skin);
colorRushBtn.addListener(new ClickListener() {
@Override
public void clicked(InputEvent e, float x, float y){ handleColorRushBtnClick(); }
});
table.add(colorRushBtn);
table.row();
TextButton bubbleWrapBtn = new TextButton(bubbleWrapHighScoreBtnText, skin);
bubbleWrapBtn.addListener(new ClickListener() {
@Override
public void clicked(InputEvent e, float x, float y){ handleBubbleWrapBtnClick(); }
});
table.add(bubbleWrapBtn);
stage.addActor(table);
}
@Override
protected void handleInput() {
}
@Override
public void update(float dt) {
stage.act(dt);
}
@Override
public void render(SpriteBatch sb) {
stage.draw();
}
@Override
public void dispose() {
stage.dispose();
}
@Override
public void reset() {
}
@Override
public Object report() {
return this;
}
private void handleBackBtnClick(){
gsm.set(new MenuState(gsm));
}
private void handleColorRushBtnClick(){}
private void handleBubbleWrapBtnClick(){}
}
\ No newline at end of file
package com.gameware.game.states;
import com.badlogic.gdx.Gdx;
import com.badlogic.gdx.graphics.g2d.SpriteBatch;
import com.badlogic.gdx.math.Vector2;
import com.badlogic.gdx.math.Vector3;
import com.badlogic.gdx.scenes.scene2d.InputEvent;
import com.badlogic.gdx.scenes.scene2d.Stage;
import com.badlogic.gdx.scenes.scene2d.ui.Button;
import com.badlogic.gdx.scenes.scene2d.ui.Skin;
import com.badlogic.gdx.scenes.scene2d.ui.Table;
import com.badlogic.gdx.scenes.scene2d.ui.TextButton;
import com.badlogic.gdx.scenes.scene2d.utils.ClickListener;
import com.gameware.game.GameWare;
public class ViewTournamentState extends State {
private Stage stage;
private Table table;
private int spacingOnBottom = Gdx.graphics.getHeight()/15;
private float fontScaleX = 3f;
private float fontScaleY = 3f;
private String backBtnText = "Back";
public ViewTournamentState(GameStateManager gsm) {
super(gsm);
System.out.println("Du er i view tournament state :0");
stage = new Stage();
Gdx.input.setInputProcessor(stage);
Skin skin = new Skin(Gdx.files.internal(GameWare.skinFilePath));
skin.getFont("font").getData().setScale(fontScaleX,fontScaleY);
cam.setToOrtho(false, Gdx.graphics.getWidth()/2, Gdx.graphics.getHeight()/2);
table = new Table();
table.setFillParent(true);
table.row();
TextButton backBtn = new TextButton(backBtnText, skin);
backBtn.addListener(new ClickListener() {
@Override
public void clicked(InputEvent e, float x, float y){
handleBackBtnClick();
}
});
table.add(backBtn);
stage.addActor(table);
}
@Override
protected void handleInput() {
}
@Override
public void update(float dt) {
stage.act(dt);
}
@Override
public void render(SpriteBatch sb) {
stage.draw();
}
@Override
public void dispose() {
stage.dispose();
}
@Override
public void reset() {
}
@Override
public Object report() {
return this;
}
private void handleBackBtnClick(){
gsm.set(new CreateJoinTournamentState(gsm));
}
}
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment