Skip to content
Snippets Groups Projects
Commit 7da223ce authored by Sixten Müller's avatar Sixten Müller
Browse files

Merge branch 'WaitForHost' into 'main'

finished waitforhost classes+some minor changes to previous classes i made

See merge request !15
parents 64fc1e10 37a60481
No related branches found
No related tags found
1 merge request!15finished waitforhost classes+some minor changes to previous classes i made
Showing with 93 additions and 15 deletions
...@@ -7,7 +7,7 @@ buildscript { ...@@ -7,7 +7,7 @@ buildscript {
google() google()
} }
dependencies { dependencies {
classpath 'com.android.tools.build:gradle:8.1.4' classpath 'com.android.tools.build:gradle:8.3.0'
classpath 'com.google.gms:google-services:4.4.1' classpath 'com.google.gms:google-services:4.4.1'
......
...@@ -76,11 +76,12 @@ public class FinalLeaderBoardController { ...@@ -76,11 +76,12 @@ public class FinalLeaderBoardController {
} }
public int calculateBackgroundRenders(){ private int calculateBackgroundRenders(){
return 1 +lenLeaderBordPage / WordBattle.HEIGHT; return 1 +lenLeaderBordPage / WordBattle.HEIGHT;
} }
public void dispose(){ public void dispose(){
finalLeaderBoardView.dispose();
} }
......
...@@ -77,11 +77,13 @@ public class LeaderBoardController { ...@@ -77,11 +77,13 @@ public class LeaderBoardController {
} }
public int calculateBackgroundRenders(){ private int calculateBackgroundRenders(){
return 1+ lenLeaderBordPage / WordBattle.HEIGHT; return 1+ lenLeaderBordPage / WordBattle.HEIGHT;
} }
public void dispose(){ public void dispose(){
leaderBoardView.dispose();
} }
} }
...@@ -15,6 +15,7 @@ import com.wordbattle.game.states.MainMenuState; ...@@ -15,6 +15,7 @@ import com.wordbattle.game.states.MainMenuState;
import com.wordbattle.game.states.StartState; import com.wordbattle.game.states.StartState;
import com.wordbattle.game.states.StartingGameState; import com.wordbattle.game.states.StartingGameState;
import com.wordbattle.game.states.StateManager; import com.wordbattle.game.states.StateManager;
import com.wordbattle.game.states.WaitForHostState;
import com.wordbattle.game.view.MainMenuView; import com.wordbattle.game.view.MainMenuView;
import java.util.logging.Logger; import java.util.logging.Logger;
...@@ -53,7 +54,7 @@ public class MainMenuController { ...@@ -53,7 +54,7 @@ public class MainMenuController {
// Button checks // Button checks
if (joinGameButtonBounds.contains(touchPos.x, touchPos.y)) { if (joinGameButtonBounds.contains(touchPos.x, touchPos.y)) {
System.out.println("Join Game Button Pressed"); System.out.println("Join Game Button Pressed");
state.getStateManager().setState(new JoinGameState(state.getStateManager())); state.getStateManager().setState(new WaitForHostState(state.getStateManager()));
} }
if (newGameButtonBounds.contains(touchPos.x, touchPos.y)) { if (newGameButtonBounds.contains(touchPos.x, touchPos.y)) {
......
package com.wordbattle.game.controller; package com.wordbattle.game.controller;
import com.badlogic.gdx.Gdx;
import com.badlogic.gdx.graphics.g2d.SpriteBatch; import com.badlogic.gdx.graphics.g2d.SpriteBatch;
import com.badlogic.gdx.math.Vector3;
import com.wordbattle.game.WordBattle;
import com.wordbattle.game.states.CreateGameState;
import com.wordbattle.game.states.WaitForHostState; import com.wordbattle.game.states.WaitForHostState;
import com.wordbattle.game.view.WaitForHostView; import com.wordbattle.game.view.WaitForHostView;
...@@ -9,15 +13,38 @@ public class WaitForHostController { ...@@ -9,15 +13,38 @@ public class WaitForHostController {
WaitForHostState state; WaitForHostState state;
WaitForHostView view; WaitForHostView view;
int lenWaitingPage;
public WaitForHostController(WaitForHostState state){ public WaitForHostController(WaitForHostState state){
this.state=state; this.state=state;
view= new WaitForHostView(state.getCam()); view= new WaitForHostView(state.getCam());
lenWaitingPage=2500;
view.setNumBackgroundRenders(calculateBackgroundRenders());
} }
int mouseYCoordinate;
private void handleInput(){ private void handleInput(){
if (Gdx.input.justTouched()){
mouseYCoordinate =Gdx.input.getY();
}
if (Gdx.input.isTouched()){
int scrollDistance=mouseYCoordinate-Gdx.input.getY();
mouseYCoordinate=Gdx.input.getY();
if( (view.getCam().viewportHeight/2 + view.getCam().position.y) -scrollDistance < WordBattle.HEIGHT && ( (-view.getCam().viewportHeight/2) + view.getCam().position.y) -scrollDistance > WordBattle.HEIGHT-lenWaitingPage ){
view.getCam().translate(0,-scrollDistance);
}
}
} }
public void update(float dt){ public void update(float dt){
...@@ -28,7 +55,12 @@ public class WaitForHostController { ...@@ -28,7 +55,12 @@ public class WaitForHostController {
view.render(spriteBatch); view.render(spriteBatch);
} }
private int calculateBackgroundRenders(){
return 1+ lenWaitingPage / WordBattle.HEIGHT;
}
public void dispose(){ public void dispose(){
view.dispose();
} }
......
...@@ -29,7 +29,6 @@ public class WaitingLobbyController { ...@@ -29,7 +29,6 @@ public class WaitingLobbyController {
} }
public void update(float dt){ public void update(float dt){
handleInput(); handleInput();
} }
......
...@@ -10,7 +10,7 @@ public class WaitForHostState extends BaseState { ...@@ -10,7 +10,7 @@ public class WaitForHostState extends BaseState {
WaitForHostController controller; WaitForHostController controller;
OrthographicCamera cam;
public WaitForHostState(StateManager gsm) { public WaitForHostState(StateManager gsm) {
super(gsm); super(gsm);
......
...@@ -170,6 +170,9 @@ public class JoinGameView { ...@@ -170,6 +170,9 @@ public class JoinGameView {
public void dispose() { public void dispose() {
backgroundTexture.dispose(); backgroundTexture.dispose();
joinGameButton.dispose(); joinGameButton.dispose();
pinTexture.dispose();
nicknameTexture.dispose();
} }
......
...@@ -64,6 +64,9 @@ public class StartingGameView { ...@@ -64,6 +64,9 @@ public class StartingGameView {
} }
public void dispose(){ public void dispose(){
font.dispose();
backArrowTexture.dispose();
backgroundTexture.dispose();
} }
} }
package com.wordbattle.game.view; package com.wordbattle.game.view;
import com.badlogic.gdx.Gdx; import com.badlogic.gdx.Gdx;
import com.badlogic.gdx.graphics.Color;
import com.badlogic.gdx.graphics.GL20; import com.badlogic.gdx.graphics.GL20;
import com.badlogic.gdx.graphics.OrthographicCamera; import com.badlogic.gdx.graphics.OrthographicCamera;
import com.badlogic.gdx.graphics.Texture; import com.badlogic.gdx.graphics.Texture;
...@@ -16,11 +17,15 @@ public class WaitForHostView { ...@@ -16,11 +17,15 @@ public class WaitForHostView {
String pin; String pin;
private Texture background; private Texture background;
private BitmapFont font; private BitmapFont titleFont;
private BitmapFont messageFont;
private BitmapFont playerFont;
private OrthographicCamera cam; private OrthographicCamera cam;
private int numBackgroundRenders;
public WaitForHostView(OrthographicCamera cam){ public WaitForHostView(OrthographicCamera cam){
this.cam=cam; this.cam=cam;
...@@ -31,11 +36,26 @@ public class WaitForHostView { ...@@ -31,11 +36,26 @@ public class WaitForHostView {
FreeTypeFontGenerator generator = new FreeTypeFontGenerator(Gdx.files.internal("Knewave-Regular.ttf")); FreeTypeFontGenerator generator = new FreeTypeFontGenerator(Gdx.files.internal("Knewave-Regular.ttf"));
FreeTypeFontGenerator.FreeTypeFontParameter parameter = new FreeTypeFontGenerator.FreeTypeFontParameter(); FreeTypeFontGenerator.FreeTypeFontParameter parameter = new FreeTypeFontGenerator.FreeTypeFontParameter();
parameter.size = 52;
titleFont = generator.generateFont(parameter);
titleFont.setColor(Color.PINK);
parameter.size=36; parameter.size=36;
font = generator.generateFont(parameter); messageFont=generator.generateFont(parameter);
messageFont.setColor(Color.YELLOW);
parameter.size=46;
playerFont=generator.generateFont(parameter);
playerFont.setColor(Color.YELLOW);
generator.dispose(); generator.dispose();
} }
...@@ -48,19 +68,36 @@ public class WaitForHostView { ...@@ -48,19 +68,36 @@ public class WaitForHostView {
spriteBatch.setProjectionMatrix(cam.combined); spriteBatch.setProjectionMatrix(cam.combined);
spriteBatch.begin(); spriteBatch.begin();
spriteBatch.draw(background,0,0, WordBattle.WIDTH,WordBattle.HEIGHT); for (int i = 0; i < numBackgroundRenders ; i++) {
font.draw(spriteBatch,"PIN "+pin,100,700); spriteBatch.draw(background,0,0-(i*WordBattle.HEIGHT), WordBattle.WIDTH,WordBattle.HEIGHT);
font.draw(spriteBatch,"Players",100,650); }
font.draw(spriteBatch,"waiting on host to start the game", 5, 150);
titleFont.draw(spriteBatch,"PIN "+pin,110,770);
messageFont.draw(spriteBatch,"waiting for host" + "\r\n" + "to start the game...", 75, 670);
titleFont.draw(spriteBatch,"Players",125,500);
playerFont.draw(spriteBatch,"ole",160,410);
spriteBatch.end(); spriteBatch.end();
} }
public void setNumBackgroundRenders(int numBackgroundRenders) {
this.numBackgroundRenders = numBackgroundRenders;
}
public OrthographicCamera getCam() {
return cam;
}
public void dispose(){ public void dispose(){
background.dispose(); background.dispose();
font.dispose(); titleFont.dispose();
messageFont.dispose();
playerFont.dispose();
} }
} }
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment