Jonathan Hager 5 years ago
commit 5df60717d7

@ -1,7 +1,6 @@
package com.trs.game;
import com.badlogic.gdx.ApplicationAdapter;
import com.badlogic.gdx.Game;
import com.badlogic.gdx.Gdx;
import com.badlogic.gdx.InputProcessor;
import com.badlogic.gdx.graphics.Color;
@ -17,13 +16,11 @@ import com.badlogic.gdx.graphics.g2d.TextureRegion;
import com.badlogic.gdx.graphics.g2d.freetype.FreeTypeFontGenerator;
import com.badlogic.gdx.graphics.glutils.ShapeRenderer;
import com.badlogic.gdx.math.Polygon;
import com.badlogic.gdx.math.Rectangle;
import com.badlogic.gdx.utils.Timer;
import com.trs.game.model.Model;
import com.trs.game.model.Projectile;
import com.trs.game.model.Wall;
import com.trs.game.view.View;
import com.trs.game.view.Button;
import com.trs.game.view.Screen;
import com.trs.game.view.Screens.EndScreen;
import com.trs.game.view.Screens.GameScreen;
@ -36,6 +33,8 @@ public class Controller extends ApplicationAdapter implements InputProcessor {
final int WALL_LIFETIME = 75;
int difficulty = 0;
SpriteBatch batch;
ShapeRenderer renderer;
PolygonSpriteBatch polygonSpriteBatch;
@ -53,7 +52,7 @@ public class Controller extends ApplicationAdapter implements InputProcessor {
batch = new SpriteBatch();
renderer = new ShapeRenderer();
polygonSpriteBatch = new PolygonSpriteBatch();
model = new Model();
model = new Model(difficulty);
view = new View();
wallTimer = new Timer();
@ -204,12 +203,24 @@ public class Controller extends ApplicationAdapter implements InputProcessor {
screen = new MainMenuScreen(GAME_WORLD_WIDTH,GAME_WORLD_HEIGHT);
break;
case 1: //GOTO GAMESCREEN
model = new Model();
model = new Model(difficulty);
screen = new GameScreen(GAME_WORLD_WIDTH,GAME_WORLD_HEIGHT);
break;
case 2: //GOTO ENDSCREEN
screen = new EndScreen(GAME_WORLD_WIDTH,GAME_WORLD_HEIGHT);
break;
case 3:
difficulty = 1;
break;
case 4:
difficulty = 2;
break;
case 5:
difficulty = 3;
break;
case 6:
difficulty = 4;
break;
}
}

@ -23,8 +23,8 @@ public class Model {
private int leftWallLength = 5000;
public Model(){
difficulty = 0;
public Model(int difficulty){
this.difficulty = difficulty;
monster = new Monster(250,150);
walls = new ArrayList<>();

@ -59,6 +59,14 @@ public class Button {
return new Rectangle(xPos,yPos,width,height);
}
public void setButtonColor(Color buttonColor) {
this.buttonColor = buttonColor;
}
public void setTextColor(Color textColor) {
this.textColor = textColor;
}
public float getTextWidth(BitmapFont font, String text){
GlyphLayout glyphLayout = new GlyphLayout();
glyphLayout.setText(font,text);

@ -17,6 +17,11 @@ public class MainMenuScreen extends Screen {
texts.add(new Text(GAME_WORLD_WIDTH/2, GAME_WORLD_HEIGHT/2, "Protect the Monster", Color.BLACK, 3, GAME_WORLD_HEIGHT/2 - 50,GAME_WORLD_HEIGHT/2 + 50));
buttons.add(new Button(-1,250,100,240,50,"Difficulty",Color.BLACK,Color.WHITE));
buttons.add(new Button(3,500,100,210,50,"Easy",Color.DARK_GRAY,Color.WHITE));
buttons.add(new Button(4,710,100,210,50,"Medium",Color.GRAY,Color.WHITE));
buttons.add(new Button(5,920,100,210,50,"Hard",Color.DARK_GRAY,Color.WHITE));
buttons.add(new Button(6,1130,100,210,50,"Impossible",Color.GRAY,Color.WHITE));
}
@Override
@ -42,7 +47,12 @@ public class MainMenuScreen extends Screen {
Rectangle r = new Rectangle(x,y,1,1);
for(Button button : buttons){
if(Intersector.overlaps(r, button.getRect())){
System.out.println(button.getId());
if(button.getId() == 3 || button.getId() == 4 || button.getId() == 5 || button.getId() == 6 ){
for(Button button2 : buttons){
button2.setTextColor(Color.WHITE);
}
button.setTextColor(Color.BLUE);
}
return button.getId();
}
}

Loading…
Cancel
Save