merge complete

master
Jonathan Hager 5 years ago
commit 9cbcce610c

@ -34,6 +34,8 @@ public class Controller extends ApplicationAdapter implements InputProcessor {
final int GAME_WORLD_WIDTH = 1600;
final int GAME_WORLD_HEIGHT = 900;
final int WALL_LIFETIME = 75;
SpriteBatch batch;
ShapeRenderer renderer;
PolygonSpriteBatch polygonSpriteBatch;
@ -77,10 +79,7 @@ public class Controller extends ApplicationAdapter implements InputProcessor {
//
//POLYGON STUFF
pix = new Pixmap(1, 1, Pixmap.Format.RGBA8888);
pix.setColor(Color.BLACK); // DE is red, AD is green and BE is blue.
pix.fill();
textureSolid = new Texture(pix);
screen = new MainMenuScreen(GAME_WORLD_WIDTH,GAME_WORLD_HEIGHT);
@ -90,6 +89,7 @@ public class Controller extends ApplicationAdapter implements InputProcessor {
@Override
public void render () {
Gdx.gl.glClearColor(1, 1, 1, 1);
//Gdx.gl.glClearColor(0, 0, 0, 1);
Gdx.gl.glClear(GL20.GL_COLOR_BUFFER_BIT);
// WORKAROUND, BECAUSE MOUSEMOVED NOT WORKING WHILE TOUCHDOWN
if(screen.getId() == 1) model.adjustWall(Gdx.input.getX(), GAME_WORLD_HEIGHT - Gdx.input.getY());
@ -100,56 +100,35 @@ public class Controller extends ApplicationAdapter implements InputProcessor {
if(screen.getId() == 1){
// DRAW WALLS
for(Wall wall : model.getWalls()){
PolygonSprite poly;
PolygonRegion polyReg = new PolygonRegion(new TextureRegion(textureSolid),
wall.getPolygon().getVertices(), new short[] {
0, 1, 2, // Two triangles using vertex indices.
0, 2, 3 // Take care of the counter-clockwise direction.
});
poly = new PolygonSprite(polyReg);
polygonSpriteBatch.begin();
poly.draw(polygonSpriteBatch);
polygonSpriteBatch.end();
if(wall.getLifetime() == -1){
drawPolygon(wall.getPolygon(),Color.BLACK);
}
else{
//float Value = ((float)(((float)wall.getLifetime() / (float)WALL_LIFETIME) * 255f))/255f);
float Value = 1f-(((float)wall.getLifetime()) / ((float)WALL_LIFETIME));
System.out.println(Value);
Color color = new Color(Value,Value,Value,1);
drawPolygon(wall.getPolygon(),color);
}
}
// DRAW PROJECTILES
renderer.begin(ShapeRenderer.ShapeType.Filled);
for(Projectile projectile : model.getProjectiles()){
PolygonSprite poly;
PolygonRegion polyReg = new PolygonRegion(new TextureRegion(textureSolid),
projectile.getPolygon().getVertices(), new short[] {
0, 1, 2, // Two triangles using vertex indices.
0, 2, 3 // Take care of the counter-clockwise direction.
});
poly = new PolygonSprite(polyReg);
polygonSpriteBatch.begin();
poly.draw(polygonSpriteBatch);
polygonSpriteBatch.end();
drawPolygon(projectile.getPolygon(), Color.BLACK);
}
// TEMP POLYGON
if(model.getTempPolygon() != null){
PolygonSprite poly2;
PolygonRegion polyReg = new PolygonRegion(new TextureRegion(textureSolid),
model.getTempPolygon().getVertices(), new short[]{
0, 1, 2, // Two triangles using vertex indices.
0, 2, 3 // Take care of the counter-clockwise direction.
});
poly2 = new PolygonSprite(polyReg);
polygonSpriteBatch.begin();
poly2.draw(polygonSpriteBatch);
polygonSpriteBatch.end();
drawPolygon(model.getTempPolygon(),Color.BLACK);
renderer.end();
batch.begin();
font.setColor(Color.GRAY);
if(model.getCurrentLength()!=0)font.draw(batch, ""+model.getCurrentLength(), Gdx.input.getX()+10, GAME_WORLD_HEIGHT - Gdx.input.getY()+10);
batch.end();
renderer.begin(ShapeRenderer.ShapeType.Filled);
// LENGTH
batch.begin();
font.setColor(Color.GRAY);
if(model.getCurrentLength()!=0)font.draw(batch, ""+model.getCurrentLength(), Gdx.input.getX()+10, GAME_WORLD_HEIGHT - Gdx.input.getY()+10);
batch.end();
}
//
renderer.end();
// write left Length
batch.begin();
font.setColor(Color.BLACK);
@ -233,4 +212,21 @@ public class Controller extends ApplicationAdapter implements InputProcessor {
break;
}
}
public void drawPolygon(Polygon polygon, Color color){
pix = new Pixmap(1, 1, Pixmap.Format.RGBA8888);
pix.setColor(color); // DE is red, AD is green and BE is blue.
pix.fill();
textureSolid = new Texture(pix);
PolygonSprite poly;
PolygonRegion polyReg = new PolygonRegion(new TextureRegion(textureSolid),
polygon.getVertices(), new short[] {
0, 1, 2, // Two triangles using vertex indices.
0, 2, 3 // Take care of the counter-clockwise direction.
});
poly = new PolygonSprite(polyReg);
polygonSpriteBatch.begin();
poly.draw(polygonSpriteBatch);
polygonSpriteBatch.end();
}
}

@ -8,6 +8,9 @@ import com.trs.game.StaticMath;
import java.util.ArrayList;
public class Model {
final int WALL_LIFETIME = 75;
private Monster monster;
private ArrayList<Wall> walls;
private ArrayList<Projectile> projectiles;
@ -18,7 +21,7 @@ public class Model {
private int difficulty;
private int leftWallLength = 2500;
private int leftWallLength = 5000;
public Model(){
difficulty = 0;
@ -31,20 +34,26 @@ public class Model {
projectiles.add(new Projectile(270, 500, 270, 0));
}
public void timerStep(){
public void timerStep() {
monster.move(walls, projectiles);
for(int i = projectiles.size() - 1; i >= 0; i--){
Projectile projectile = projectiles.get(i);
projectile.move(walls);
if(projectile.getxPos() < -110 || projectile.getxPos() > 1710 || projectile.getyPos() < -110 || projectile.getyPos() > 1010){
projectiles.remove(i);
}
}
for (int i = 0; i < walls.size(); i++) {
walls.get(i).timerStep();
if (walls.get(i).getLifetime() == 0) {
walls.remove(i);
i--;
}
if(monster.getIsDead()){
// TODO: Tod implementieren
if (monster.getIsDead()) {
// TODO: Tod implementieren
}
}
// Generation of new projectiles
@ -53,7 +62,7 @@ public class Model {
projectiles.add(spawnProjectile());
}
}
public void startWall(int x, int y){
if(!drawing){
tempPolygon = StaticMath.createPolygon(x,y,0,10,5);
@ -92,7 +101,7 @@ public class Model {
if(possible){
leftWallLength -= Vector2.dst(tempStart.x,tempStart.y,x,y);
walls.add(new TempWall(angle-Math.PI, tempPolygon, 500));
walls.add(new TempWall(angle-Math.PI, tempPolygon, WALL_LIFETIME));
}
}
tempPolygon = null;

@ -31,6 +31,11 @@ public class PermWall implements Wall {
return collisionPolygons;
}
@Override
public int getLifetime() {
return -1;
}
public void setRotation(double rotation) {
this.rotation = rotation;
}

@ -20,6 +20,7 @@ public class TempWall implements Wall {
@Override
public Wall timerStep() {
lifetime--;
return this;
}

@ -7,4 +7,5 @@ public interface Wall {
public Polygon getPolygon();
public double getRotation();
public Polygon[] getCollisionPolygons();
public int getLifetime();
}

Loading…
Cancel
Save