master
GammelJAN 5 years ago
parent 9cbcce610c
commit e8eb44889b

@ -1,7 +1,6 @@
package com.trs.game; package com.trs.game;
import com.badlogic.gdx.ApplicationAdapter; import com.badlogic.gdx.ApplicationAdapter;
import com.badlogic.gdx.Game;
import com.badlogic.gdx.Gdx; import com.badlogic.gdx.Gdx;
import com.badlogic.gdx.InputProcessor; import com.badlogic.gdx.InputProcessor;
import com.badlogic.gdx.graphics.Color; 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.g2d.freetype.FreeTypeFontGenerator;
import com.badlogic.gdx.graphics.glutils.ShapeRenderer; import com.badlogic.gdx.graphics.glutils.ShapeRenderer;
import com.badlogic.gdx.math.Polygon; import com.badlogic.gdx.math.Polygon;
import com.badlogic.gdx.math.Rectangle;
import com.badlogic.gdx.utils.Timer; import com.badlogic.gdx.utils.Timer;
import com.trs.game.model.Model; import com.trs.game.model.Model;
import com.trs.game.model.Projectile; import com.trs.game.model.Projectile;
import com.trs.game.model.Wall; import com.trs.game.model.Wall;
import com.trs.game.view.View; import com.trs.game.view.View;
import com.trs.game.view.Button;
import com.trs.game.view.Screen; import com.trs.game.view.Screen;
import com.trs.game.view.Screens.EndScreen; import com.trs.game.view.Screens.EndScreen;
import com.trs.game.view.Screens.GameScreen; import com.trs.game.view.Screens.GameScreen;
@ -36,6 +33,8 @@ public class Controller extends ApplicationAdapter implements InputProcessor {
final int WALL_LIFETIME = 75; final int WALL_LIFETIME = 75;
int difficulty = 0;
SpriteBatch batch; SpriteBatch batch;
ShapeRenderer renderer; ShapeRenderer renderer;
PolygonSpriteBatch polygonSpriteBatch; PolygonSpriteBatch polygonSpriteBatch;
@ -53,7 +52,7 @@ public class Controller extends ApplicationAdapter implements InputProcessor {
batch = new SpriteBatch(); batch = new SpriteBatch();
renderer = new ShapeRenderer(); renderer = new ShapeRenderer();
polygonSpriteBatch = new PolygonSpriteBatch(); polygonSpriteBatch = new PolygonSpriteBatch();
model = new Model(); model = new Model(difficulty);
view = new View(); view = new View();
wallTimer = new Timer(); wallTimer = new Timer();
@ -204,12 +203,24 @@ public class Controller extends ApplicationAdapter implements InputProcessor {
screen = new MainMenuScreen(GAME_WORLD_WIDTH,GAME_WORLD_HEIGHT); screen = new MainMenuScreen(GAME_WORLD_WIDTH,GAME_WORLD_HEIGHT);
break; break;
case 1: //GOTO GAMESCREEN case 1: //GOTO GAMESCREEN
model = new Model(); model = new Model(difficulty);
screen = new GameScreen(GAME_WORLD_WIDTH,GAME_WORLD_HEIGHT); screen = new GameScreen(GAME_WORLD_WIDTH,GAME_WORLD_HEIGHT);
break; break;
case 2: //GOTO ENDSCREEN case 2: //GOTO ENDSCREEN
screen = new EndScreen(GAME_WORLD_WIDTH,GAME_WORLD_HEIGHT); screen = new EndScreen(GAME_WORLD_WIDTH,GAME_WORLD_HEIGHT);
break; 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; private int leftWallLength = 5000;
public Model(){ public Model(int difficulty){
difficulty = 0; this.difficulty = difficulty;
monster = new Monster(250,150); monster = new Monster(250,150);
walls = new ArrayList<>(); walls = new ArrayList<>();

@ -59,6 +59,14 @@ public class Button {
return new Rectangle(xPos,yPos,width,height); 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){ public float getTextWidth(BitmapFont font, String text){
GlyphLayout glyphLayout = new GlyphLayout(); GlyphLayout glyphLayout = new GlyphLayout();
glyphLayout.setText(font,text); 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)); 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 @Override
@ -42,7 +47,12 @@ public class MainMenuScreen extends Screen {
Rectangle r = new Rectangle(x,y,1,1); Rectangle r = new Rectangle(x,y,1,1);
for(Button button : buttons){ for(Button button : buttons){
if(Intersector.overlaps(r, button.getRect())){ 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(); return button.getId();
} }
} }

Loading…
Cancel
Save