Skip to content
Snippets Groups Projects
Commit 37a60481 authored by marcus's avatar marcus
Browse files

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

parent ed8a50f0
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 {
google()
}
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'
......
......@@ -74,11 +74,12 @@ public class FinalLeaderBoardController {
}
public int calculateBackgroundRenders(){
private int calculateBackgroundRenders(){
return 1 +lenLeaderBordPage / WordBattle.HEIGHT;
}
public void dispose(){
finalLeaderBoardView.dispose();
}
......
......@@ -75,11 +75,13 @@ public class LeaderBoardController {
}
public int calculateBackgroundRenders(){
private int calculateBackgroundRenders(){
return 1+ lenLeaderBordPage / WordBattle.HEIGHT;
}
public void dispose(){
leaderBoardView.dispose();
}
}
......@@ -12,6 +12,7 @@ import com.wordbattle.game.states.MainMenuState;
import com.wordbattle.game.states.StartState;
import com.wordbattle.game.states.StartingGameState;
import com.wordbattle.game.states.StateManager;
import com.wordbattle.game.states.WaitForHostState;
import com.wordbattle.game.view.MainMenuView;
import java.util.logging.Logger;
......@@ -46,7 +47,7 @@ public class MainMenuController {
// Button checks
if (joinGameButtonBounds.contains(touchPos.x, touchPos.y)) {
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)) {
......
package com.wordbattle.game.controller;
import com.badlogic.gdx.Gdx;
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.view.WaitForHostView;
......@@ -9,15 +13,38 @@ public class WaitForHostController {
WaitForHostState state;
WaitForHostView view;
int lenWaitingPage;
public WaitForHostController(WaitForHostState state){
this.state=state;
view= new WaitForHostView(state.getCam());
lenWaitingPage=2500;
view.setNumBackgroundRenders(calculateBackgroundRenders());
}
int mouseYCoordinate;
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){
......@@ -28,7 +55,12 @@ public class WaitForHostController {
view.render(spriteBatch);
}
private int calculateBackgroundRenders(){
return 1+ lenWaitingPage / WordBattle.HEIGHT;
}
public void dispose(){
view.dispose();
}
......
......@@ -26,7 +26,6 @@ public class WaitingLobbyController {
}
public void update(float dt){
handleInput();
}
......
......@@ -10,7 +10,7 @@ public class WaitForHostState extends BaseState {
WaitForHostController controller;
OrthographicCamera cam;
public WaitForHostState(StateManager gsm) {
super(gsm);
......
......@@ -170,6 +170,9 @@ public class JoinGameView {
public void dispose() {
backgroundTexture.dispose();
joinGameButton.dispose();
pinTexture.dispose();
nicknameTexture.dispose();
}
......
......@@ -64,6 +64,9 @@ public class StartingGameView {
}
public void dispose(){
font.dispose();
backArrowTexture.dispose();
backgroundTexture.dispose();
}
}
package com.wordbattle.game.view;
import com.badlogic.gdx.Gdx;
import com.badlogic.gdx.graphics.Color;
import com.badlogic.gdx.graphics.GL20;
import com.badlogic.gdx.graphics.OrthographicCamera;
import com.badlogic.gdx.graphics.Texture;
......@@ -16,11 +17,15 @@ public class WaitForHostView {
String pin;
private Texture background;
private BitmapFont font;
private BitmapFont titleFont;
private BitmapFont messageFont;
private BitmapFont playerFont;
private OrthographicCamera cam;
private int numBackgroundRenders;
public WaitForHostView(OrthographicCamera cam){
this.cam=cam;
......@@ -31,11 +36,26 @@ public class WaitForHostView {
FreeTypeFontGenerator generator = new FreeTypeFontGenerator(Gdx.files.internal("Knewave-Regular.ttf"));
FreeTypeFontGenerator.FreeTypeFontParameter parameter = new FreeTypeFontGenerator.FreeTypeFontParameter();
parameter.size = 52;
titleFont = generator.generateFont(parameter);
titleFont.setColor(Color.PINK);
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();
}
......@@ -48,19 +68,36 @@ public class WaitForHostView {
spriteBatch.setProjectionMatrix(cam.combined);
spriteBatch.begin();
spriteBatch.draw(background,0,0, WordBattle.WIDTH,WordBattle.HEIGHT);
font.draw(spriteBatch,"PIN "+pin,100,700);
font.draw(spriteBatch,"Players",100,650);
font.draw(spriteBatch,"waiting on host to start the game", 5, 150);
for (int i = 0; i < numBackgroundRenders ; i++) {
spriteBatch.draw(background,0,0-(i*WordBattle.HEIGHT), WordBattle.WIDTH,WordBattle.HEIGHT);
}
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();
}
public void setNumBackgroundRenders(int numBackgroundRenders) {
this.numBackgroundRenders = numBackgroundRenders;
}
public OrthographicCamera getCam() {
return cam;
}
public void 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